Skip to content

Commit 525e23a

Browse files
committed
peel derives when checking normalized is expected
1 parent 770a9cf commit 525e23a

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
11901190
);
11911191

11921192
let is_normalized_ty_expected = !matches!(
1193-
obligation.cause.code,
1193+
obligation.cause.code.peel_derives(),
11941194
ObligationCauseCode::ItemObligation(_)
11951195
| ObligationCauseCode::BindingObligation(_, _)
11961196
| ObligationCauseCode::ObjectCastObligation(_)

src/test/ui/associated-types/issue-44153.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn visit() {}
55
| ---------- required by `Visit::visit`
66
...
77
LL | <() as Visit>::visit();
8-
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()`
8+
| ^^^^^^^^^^^^^^^^^^^^ expected `&()`, found `()`
99
|
1010
= note: required because of the requirements on the impl of `Visit` for `()`
1111

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pub trait Super {
2+
type Assoc;
3+
}
4+
5+
impl Super for () {
6+
type Assoc = u8;
7+
}
8+
9+
pub trait Test {}
10+
11+
impl<T> Test for T where T: Super<Assoc = ()> {}
12+
13+
fn test() -> impl Test {
14+
//~^ERROR type mismatch resolving `<() as Super>::Assoc == ()`
15+
()
16+
}
17+
18+
fn main() {
19+
let a = test();
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()`
2+
--> $DIR/projection-mismatch-in-impl-where-clause.rs:13:14
3+
|
4+
LL | fn test() -> impl Test {
5+
| ^^^^^^^^^ expected `()`, found `u8`
6+
|
7+
= note: required because of the requirements on the impl of `Test` for `()`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0271`.

src/test/ui/issues/issue-33941.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
1111
--> $DIR/issue-33941.rs:4:14
1212
|
1313
LL | for _ in HashMap::new().iter().cloned() {}
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found tuple
1515
|
16-
= note: expected tuple `(&_, &_)`
17-
found reference `&_`
16+
= note: expected reference `&_`
17+
found tuple `(&_, &_)`
1818
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
1919
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
2020
= note: required by `into_iter`
@@ -23,10 +23,10 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
2323
--> $DIR/issue-33941.rs:4:14
2424
|
2525
LL | for _ in HashMap::new().iter().cloned() {}
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found tuple
2727
|
28-
= note: expected tuple `(&_, &_)`
29-
found reference `&_`
28+
= note: expected reference `&_`
29+
found tuple `(&_, &_)`
3030
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
3131
= note: required by `std::iter::Iterator::next`
3232

src/test/ui/issues/issue-39970.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn visit() {}
55
| ---------- required by `Visit::visit`
66
...
77
LL | <() as Visit>::visit();
8-
| ^^^^^^^^^^^^^^^^^^^^ expected `&()`, found `()`
8+
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()`
99
|
1010
= note: required because of the requirements on the impl of `Visit` for `()`
1111

0 commit comments

Comments
 (0)