]> git.lizzy.rs Git - rust.git/commitdiff
peel derives when checking normalized is expected
authorSNCPlay42 <SNCPlay42@gmail.com>
Fri, 8 Jan 2021 22:16:24 +0000 (22:16 +0000)
committerSNCPlay42 <SNCPlay42@gmail.com>
Tue, 16 Mar 2021 16:55:11 +0000 (16:55 +0000)
compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
src/test/ui/associated-types/issue-44153.stderr
src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs [new file with mode: 0644]
src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr [new file with mode: 0644]
src/test/ui/issues/issue-33941.stderr
src/test/ui/issues/issue-39970.stderr

index 5de4fb1ce8c6aadc95cd51934de10e160f911ebd..9dc3a143884db14b51be5a99f412ffb31eee59aa 100644 (file)
@@ -1190,7 +1190,7 @@ fn report_projection_error(
                 );
 
                 let is_normalized_ty_expected = !matches!(
-                    obligation.cause.code,
+                    obligation.cause.code.peel_derives(),
                     ObligationCauseCode::ItemObligation(_)
                         | ObligationCauseCode::BindingObligation(_, _)
                         | ObligationCauseCode::ObjectCastObligation(_)
index 8ef71087958ca5b2988b61456354d654d0fd82b2..cafc8ec52ca7601414cc26c7db6346e7c70f1539 100644 (file)
@@ -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 `()`
 
diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs
new file mode 100644 (file)
index 0000000..b4fd6b3
--- /dev/null
@@ -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();
+}
diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
new file mode 100644 (file)
index 0000000..d1956a9
--- /dev/null
@@ -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`.
index e91dae08b3a331b36eeee730681efd1c3f6fc6a0..043658c9508f3721a52cfa2746099d246eceedc9 100644 (file)
@@ -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`
 
index 6f342b459c076a1b04bea14afceb398e3ec24a87..8ecde9d1e68e1b2e986e8c02e7caac365bc8a9d8 100644 (file)
@@ -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 `()`