peel derives when checking normalized is expected
This commit is contained in:
parent
770a9cf780
commit
525e23adaf
6 changed files with 40 additions and 9 deletions
|
@ -1190,7 +1190,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
let is_normalized_ty_expected = !matches!(
|
||||
obligation.cause.code,
|
||||
obligation.cause.code.peel_derives(),
|
||||
ObligationCauseCode::ItemObligation(_)
|
||||
| ObligationCauseCode::BindingObligation(_, _)
|
||||
| ObligationCauseCode::ObjectCastObligation(_)
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn visit() {}
|
|||
| ---------- required by `Visit::visit`
|
||||
...
|
||||
LL | <() as Visit>::visit();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `&()`, found `()`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Visit` for `()`
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
pub trait Super {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl Super for () {
|
||||
type Assoc = u8;
|
||||
}
|
||||
|
||||
pub trait Test {}
|
||||
|
||||
impl<T> Test for T where T: Super<Assoc = ()> {}
|
||||
|
||||
fn test() -> impl Test {
|
||||
//~^ERROR type mismatch resolving `<() as Super>::Assoc == ()`
|
||||
()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = test();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()`
|
||||
--> $DIR/projection-mismatch-in-impl-where-clause.rs:13:14
|
||||
|
|
||||
LL | fn test() -> impl Test {
|
||||
| ^^^^^^^^^ expected `()`, found `u8`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Test` for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0271`.
|
|
@ -11,10 +11,10 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
|
|||
--> $DIR/issue-33941.rs:4:14
|
||||
|
|
||||
LL | for _ in HashMap::new().iter().cloned() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found tuple
|
||||
|
|
||||
= note: expected tuple `(&_, &_)`
|
||||
found reference `&_`
|
||||
= note: expected reference `&_`
|
||||
found tuple `(&_, &_)`
|
||||
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required by `into_iter`
|
||||
|
@ -23,10 +23,10 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
|
|||
--> $DIR/issue-33941.rs:4:14
|
||||
|
|
||||
LL | for _ in HashMap::new().iter().cloned() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found tuple
|
||||
|
|
||||
= note: expected tuple `(&_, &_)`
|
||||
found reference `&_`
|
||||
= note: expected reference `&_`
|
||||
found tuple `(&_, &_)`
|
||||
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
|
||||
= note: required by `std::iter::Iterator::next`
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn visit() {}
|
|||
| ---------- required by `Visit::visit`
|
||||
...
|
||||
LL | <() as Visit>::visit();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `&()`, found `()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Visit` for `()`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue