]> git.lizzy.rs Git - rust.git/commitdiff
Fix rebase damage
authorJonas Schievink <jonasschievink@gmail.com>
Mon, 7 Oct 2019 23:14:45 +0000 (01:14 +0200)
committerJonas Schievink <jonasschievink@gmail.com>
Fri, 21 Feb 2020 18:41:22 +0000 (19:41 +0100)
src/librustc_typeck/check/wfcheck.rs
src/test/ui/associated-types/defaults-in-other-trait-items.rs
src/test/ui/associated-types/defaults-in-other-trait-items.stderr
src/test/ui/associated-types/defaults-specialization.rs
src/test/ui/associated-types/defaults-specialization.stderr
src/test/ui/associated-types/defaults-suitability.stderr
src/test/ui/associated-types/defaults-unsound-62211-1.stderr
src/test/ui/associated-types/defaults-unsound-62211-2.stderr
src/test/ui/associated-types/issue-26681.stderr
src/test/ui/associated-types/issue-63593.stderr

index e39beb547d1a78405928937014a84f8253aab2b3..a6189a346645dd51da74fbb7d0153b546388ff91 100644 (file)
@@ -496,7 +496,7 @@ fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
         }
 
         fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
-            match t.sty {
+            match t.kind {
                 ty::Projection(proj_ty) => {
                     if let Some(default) = self.map.get(&proj_ty) {
                         default
index 0455997b168087ff47f03d505c62d232a1deedd7..9f2e8aca47712a0f2809d8b4e545c73427a51b82 100644 (file)
@@ -10,7 +10,7 @@ fn f(p: Self::A) {
         //~^ ERROR mismatched types
         //~| NOTE expected associated type, found `()`
         //~| NOTE expected associated type `<Self as Tr>::A`
-        //~| NOTE consider constraining
+        //~| NOTE consider constraining the associated type
         //~| NOTE for more information, visit
     }
 }
@@ -38,7 +38,7 @@ trait AssocConst {
     //~^ ERROR mismatched types
     //~| NOTE expected associated type, found `u8`
     //~| NOTE expected associated type `<Self as AssocConst>::Ty`
-    //~| NOTE consider constraining
+    //~| NOTE consider constraining the associated type
     //~| NOTE for more information, visit
 }
 
index 9ecfe49c2b571bbd2781fc35dd3262d5a299744b..b759276d2484b6151d44150c6008d1a8d9b13849 100644 (file)
@@ -10,7 +10,7 @@ LL |         let () = p;
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
-  --> $DIR/defaults-in-other-trait-items.rs:37:25
+  --> $DIR/defaults-in-other-trait-items.rs:39:25
    |
 LL |     const C: Self::Ty = 0u8;
    |                         ^^^ expected associated type, found `u8`
index 833981fc8e3c89a2570c55006586394f94a18583..cb0d231bfcd7c1bfaee9d72f25fc57812ee4dad5 100644 (file)
@@ -66,6 +66,7 @@ fn make() -> u8 { 255 }
 
 struct E<T>(T);
 impl<T> Tr for E<T> {
+    default type Ty = bool;
     default fn make() -> Self::Ty { panic!(); }
 }
 
index bd0fd7166f6681ee565b69aa243210ed4b42cd89..9b10940cbc485fe621ab66a90fde299a5babfba4 100644 (file)
@@ -5,10 +5,12 @@ LL |     fn make() -> Self::Ty {
    |                  -------- type in trait
 ...
 LL |     fn make() -> u8 { 0 }
-   |                  ^^ expected associated type, found u8
+   |                  ^^ expected associated type, found `u8`
    |
-   = note: expected type `fn() -> <A<T> as Tr>::Ty`
-              found type `fn() -> u8`
+   = note: expected fn pointer `fn() -> <A<T> as Tr>::Ty`
+              found fn pointer `fn() -> u8`
+   = note: consider constraining the associated type `<A<T> as Tr>::Ty` to `u8` or calling a method that returns `<A<T> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0053]: method `make` has an incompatible type for trait
   --> $DIR/defaults-specialization.rs:36:18
@@ -17,10 +19,12 @@ LL |     fn make() -> Self::Ty {
    |                  -------- type in trait
 ...
 LL |     fn make() -> bool { true }
-   |                  ^^^^ expected associated type, found bool
+   |                  ^^^^ expected associated type, found `bool`
    |
-   = note: expected type `fn() -> <B<T> as Tr>::Ty`
-              found type `fn() -> bool`
+   = note: expected fn pointer `fn() -> <B<T> as Tr>::Ty`
+              found fn pointer `fn() -> bool`
+   = note: consider constraining the associated type `<B<T> as Tr>::Ty` to `bool` or calling a method that returns `<B<T> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
   --> $DIR/defaults-specialization.rs:11:9
@@ -28,68 +32,82 @@ error[E0308]: mismatched types
 LL |     fn make() -> Self::Ty {
    |                  -------- expected `<Self as Tr>::Ty` because of return type
 LL |         0u8
-   |         ^^^ expected associated type, found u8
+   |         ^^^ expected associated type, found `u8`
    |
-   = note: expected type `<Self as Tr>::Ty`
-              found type `u8`
+   = note: expected associated type `<Self as Tr>::Ty`
+                         found type `u8`
+   = note: consider constraining the associated type `<Self as Tr>::Ty` to `u8` or calling a method that returns `<Self as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
   --> $DIR/defaults-specialization.rs:27:29
    |
 LL |     fn make() -> Self::Ty { 0u8 }
-   |                  --------   ^^^ expected associated type, found u8
+   |                  --------   ^^^ expected associated type, found `u8`
    |                  |
    |                  expected `<A2<T> as Tr>::Ty` because of return type
    |
-   = note: expected type `<A2<T> as Tr>::Ty`
-              found type `u8`
+   = note: expected associated type `<A2<T> as Tr>::Ty`
+                         found type `u8`
+   = note: consider constraining the associated type `<A2<T> as Tr>::Ty` to `u8` or calling a method that returns `<A2<T> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
   --> $DIR/defaults-specialization.rs:45:29
    |
 LL |     fn make() -> Self::Ty { true }
-   |                  --------   ^^^^ expected associated type, found bool
+   |                  --------   ^^^^ expected associated type, found `bool`
    |                  |
    |                  expected `<B2<T> as Tr>::Ty` because of return type
    |
-   = note: expected type `<B2<T> as Tr>::Ty`
-              found type `bool`
+   = note: expected associated type `<B2<T> as Tr>::Ty`
+                         found type `bool`
+   = note: consider constraining the associated type `<B2<T> as Tr>::Ty` to `bool` or calling a method that returns `<B2<T> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
-  --> $DIR/defaults-specialization.rs:87:32
+  --> $DIR/defaults-specialization.rs:88:32
    |
 LL |     let _: <B<()> as Tr>::Ty = 0u8;
-   |                                ^^^ expected associated type, found u8
+   |                                ^^^ expected associated type, found `u8`
    |
-   = note: expected type `<B<()> as Tr>::Ty`
-              found type `u8`
+   = note: expected associated type `<B<()> as Tr>::Ty`
+                         found type `u8`
+   = note: consider constraining the associated type `<B<()> as Tr>::Ty` to `u8` or calling a method that returns `<B<()> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
-  --> $DIR/defaults-specialization.rs:88:32
+  --> $DIR/defaults-specialization.rs:89:32
    |
 LL |     let _: <B<()> as Tr>::Ty = true;
-   |                                ^^^^ expected associated type, found bool
+   |                                ^^^^ expected associated type, found `bool`
    |
-   = note: expected type `<B<()> as Tr>::Ty`
-              found type `bool`
+   = note: expected associated type `<B<()> as Tr>::Ty`
+                         found type `bool`
+   = note: consider constraining the associated type `<B<()> as Tr>::Ty` to `bool` or calling a method that returns `<B<()> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
-  --> $DIR/defaults-specialization.rs:89:33
+  --> $DIR/defaults-specialization.rs:90:33
    |
 LL |     let _: <B2<()> as Tr>::Ty = 0u8;
-   |                                 ^^^ expected associated type, found u8
+   |                                 ^^^ expected associated type, found `u8`
    |
-   = note: expected type `<B2<()> as Tr>::Ty`
-              found type `u8`
+   = note: expected associated type `<B2<()> as Tr>::Ty`
+                         found type `u8`
+   = note: consider constraining the associated type `<B2<()> as Tr>::Ty` to `u8` or calling a method that returns `<B2<()> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error[E0308]: mismatched types
-  --> $DIR/defaults-specialization.rs:90:33
+  --> $DIR/defaults-specialization.rs:91:33
    |
 LL |     let _: <B2<()> as Tr>::Ty = true;
-   |                                 ^^^^ expected associated type, found bool
+   |                                 ^^^^ expected associated type, found `bool`
    |
-   = note: expected type `<B2<()> as Tr>::Ty`
-              found type `bool`
+   = note: expected associated type `<B2<()> as Tr>::Ty`
+                         found type `bool`
+   = note: consider constraining the associated type `<B2<()> as Tr>::Ty` to `bool` or calling a method that returns `<B2<()> as Tr>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error: aborting due to 9 previous errors
 
index dd45c9e4436680b01142b28106dcc6f92c3de095..861f178fd194a7fca1012446f2bd16676328e5bd 100644 (file)
@@ -19,11 +19,13 @@ error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
   --> $DIR/defaults-suitability.rs:35:15
    |
 LL | trait Foo<T> {
-   | ------------ required by `Foo`
+   | ------------
+   | |         |
+   | |         help: consider restricting this bound: `T: std::clone::Clone`
+   | required by `Foo`
 LL |     type Bar: Clone = Vec<T>;
    |               ^^^^^ the trait `std::clone::Clone` is not implemented for `T`
    |
-   = help: consider adding a `where T: std::clone::Clone` bound
    = note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<T>`
 
 error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
@@ -82,22 +84,24 @@ error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: std::clone::Clone` is not
   --> $DIR/defaults-suitability.rs:74:15
    |
 LL | trait Foo2<T> {
-   | ------------- required by `Foo2`
+   | -------------- help: consider further restricting the associated type: `where <Self as Foo2<T>>::Baz: std::clone::Clone`
+   | |
+   | required by `Foo2`
 LL |     type Bar: Clone = Vec<Self::Baz>;
    |               ^^^^^ the trait `std::clone::Clone` is not implemented for `<Self as Foo2<T>>::Baz`
    |
-   = help: consider adding a `where <Self as Foo2<T>>::Baz: std::clone::Clone` bound
    = note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo2<T>>::Baz>`
 
 error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: std::clone::Clone` is not satisfied
   --> $DIR/defaults-suitability.rs:83:15
    |
 LL | trait Foo25<T: Clone> {
-   | --------------------- required by `Foo25`
+   | ---------------------- help: consider further restricting the associated type: `where <Self as Foo25<T>>::Baz: std::clone::Clone`
+   | |
+   | required by `Foo25`
 LL |     type Bar: Clone = Vec<Self::Baz>;
    |               ^^^^^ the trait `std::clone::Clone` is not implemented for `<Self as Foo25<T>>::Baz`
    |
-   = help: consider adding a `where <Self as Foo25<T>>::Baz: std::clone::Clone` bound
    = note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo25<T>>::Baz>`
 
 error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
@@ -106,14 +110,14 @@ error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
 LL | / trait Foo3<T> where
 LL | |     Self::Bar: Clone,
 LL | |     Self::Baz: Clone,
-   | |                ^^^^^ the trait `std::clone::Clone` is not implemented for `T`
+   | |                ^^^^^ - help: consider further restricting type parameter `T`: `, T: std::clone::Clone`
+   | |                |
+   | |                the trait `std::clone::Clone` is not implemented for `T`
 LL | |
 ...  |
 LL | |     type Baz = T;
 LL | | }
    | |_- required by `Foo3`
-   |
-   = help: consider adding a `where T: std::clone::Clone` bound
 
 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
   --> $DIR/defaults-suitability.rs:29:5
index e8eb085b791463548e44a90913fc3d60332fb01f..35164c4f3d37e5a73248bc50945a00592df505a4 100644 (file)
@@ -6,8 +6,6 @@ LL | trait UncheckedCopy: Sized {
 ...
 LL |     type Output: Copy
    |                  ^^^^ the trait `std::marker::Copy` is not implemented for `Self`
-   |
-   = help: consider adding a `where Self: std::marker::Copy` bound
 
 error[E0277]: cannot add-assign `&'static str` to `Self`
   --> $DIR/defaults-unsound-62211-1.rs:27:7
@@ -19,7 +17,6 @@ LL |     + AddAssign<&'static str>
    |       ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
    |
    = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
-   = help: consider adding a `where Self: std::ops::AddAssign<&'static str>` bound
 
 error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
   --> $DIR/defaults-unsound-62211-1.rs:25:7
@@ -29,8 +26,6 @@ LL | trait UncheckedCopy: Sized {
 ...
 LL |     + Deref<Target = str>
    |       ^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `Self`
-   |
-   = help: consider adding a `where Self: std::ops::Deref` bound
 
 error[E0277]: `Self` doesn't implement `std::fmt::Display`
   --> $DIR/defaults-unsound-62211-1.rs:30:7
@@ -43,42 +38,43 @@ LL |     + Display = Self;
    |
    = help: the trait `std::fmt::Display` is not implemented for `Self`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
-   = help: consider adding a `where Self: std::fmt::Display` bound
 
 error[E0277]: `T` doesn't implement `std::fmt::Display`
   --> $DIR/defaults-unsound-62211-1.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
+   |      -  ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
+   |      |
+   |      help: consider restricting this bound: `T: std::fmt::Display`
    |
    = help: the trait `std::fmt::Display` is not implemented for `T`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
-   = help: consider adding a `where T: std::fmt::Display` bound
 
 error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied
   --> $DIR/defaults-unsound-62211-1.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T`
-   |
-   = help: consider adding a `where T: std::ops::Deref` bound
+   |      -  ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T`
+   |      |
+   |      help: consider restricting this bound: `T: std::ops::Deref`
 
 error[E0277]: cannot add-assign `&'static str` to `T`
   --> $DIR/defaults-unsound-62211-1.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ no implementation for `T += &'static str`
+   |      -  ^^^^^^^^^^^^^ no implementation for `T += &'static str`
+   |      |
+   |      help: consider restricting this bound: `T: std::ops::AddAssign<&'static str>`
    |
    = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T`
-   = help: consider adding a `where T: std::ops::AddAssign<&'static str>` bound
 
 error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
   --> $DIR/defaults-unsound-62211-1.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
-   |
-   = help: consider adding a `where T: std::marker::Copy` bound
+   |      -  ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
+   |      |
+   |      help: consider restricting this bound: `T: std::marker::Copy`
 
 error: aborting due to 8 previous errors
 
index a0b5d6b9cbb46e774ee2c45ceda743368a94bc8b..af66ee117a3a3d6cda7d02d691822a31b703669a 100644 (file)
@@ -6,8 +6,6 @@ LL | trait UncheckedCopy: Sized {
 ...
 LL |     type Output: Copy
    |                  ^^^^ the trait `std::marker::Copy` is not implemented for `Self`
-   |
-   = help: consider adding a `where Self: std::marker::Copy` bound
 
 error[E0277]: cannot add-assign `&'static str` to `Self`
   --> $DIR/defaults-unsound-62211-2.rs:27:7
@@ -19,7 +17,6 @@ LL |     + AddAssign<&'static str>
    |       ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
    |
    = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
-   = help: consider adding a `where Self: std::ops::AddAssign<&'static str>` bound
 
 error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
   --> $DIR/defaults-unsound-62211-2.rs:25:7
@@ -29,8 +26,6 @@ LL | trait UncheckedCopy: Sized {
 ...
 LL |     + Deref<Target = str>
    |       ^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `Self`
-   |
-   = help: consider adding a `where Self: std::ops::Deref` bound
 
 error[E0277]: `Self` doesn't implement `std::fmt::Display`
   --> $DIR/defaults-unsound-62211-2.rs:30:7
@@ -43,42 +38,43 @@ LL |     + Display = Self;
    |
    = help: the trait `std::fmt::Display` is not implemented for `Self`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
-   = help: consider adding a `where Self: std::fmt::Display` bound
 
 error[E0277]: `T` doesn't implement `std::fmt::Display`
   --> $DIR/defaults-unsound-62211-2.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
+   |      -  ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
+   |      |
+   |      help: consider restricting this bound: `T: std::fmt::Display`
    |
    = help: the trait `std::fmt::Display` is not implemented for `T`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
-   = help: consider adding a `where T: std::fmt::Display` bound
 
 error[E0277]: the trait bound `T: std::ops::Deref` is not satisfied
   --> $DIR/defaults-unsound-62211-2.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T`
-   |
-   = help: consider adding a `where T: std::ops::Deref` bound
+   |      -  ^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `T`
+   |      |
+   |      help: consider restricting this bound: `T: std::ops::Deref`
 
 error[E0277]: cannot add-assign `&'static str` to `T`
   --> $DIR/defaults-unsound-62211-2.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ no implementation for `T += &'static str`
+   |      -  ^^^^^^^^^^^^^ no implementation for `T += &'static str`
+   |      |
+   |      help: consider restricting this bound: `T: std::ops::AddAssign<&'static str>`
    |
    = help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `T`
-   = help: consider adding a `where T: std::ops::AddAssign<&'static str>` bound
 
 error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
   --> $DIR/defaults-unsound-62211-2.rs:43:9
    |
 LL | impl<T> UncheckedCopy for T {}
-   |         ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
-   |
-   = help: consider adding a `where T: std::marker::Copy` bound
+   |      -  ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
+   |      |
+   |      help: consider restricting this bound: `T: std::marker::Copy`
 
 error: aborting due to 8 previous errors
 
index 27175a247fa8a30698d139d8001a8b8ceeda4175..da10933df92b0d044443cc497f9bc85139b6eebf 100644 (file)
@@ -4,8 +4,10 @@ error[E0308]: mismatched types
 LL |     const C: <Self::Fv as Foo>::Bar = 6665;
    |                                       ^^^^ expected associated type, found integer
    |
-   = note: expected type `<<Self as Baz>::Fv as Foo>::Bar`
-              found type `{integer}`
+   = note: expected associated type `<<Self as Baz>::Fv as Foo>::Bar`
+                         found type `{integer}`
+   = note: consider constraining the associated type `<<Self as Baz>::Fv as Foo>::Bar` to `{integer}` or calling a method that returns `<<Self as Baz>::Fv as Foo>::Bar`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 
 error: aborting due to previous error
 
index 37dd52980d996efbe98d0d7c541a9e0e96ee4d0f..c27800f5a3fb1350bfeaa261e4cfe1792c61dc37 100644 (file)
@@ -8,7 +8,6 @@ LL |     type This = Self;
    |
    = help: the trait `std::marker::Sized` is not implemented for `Self`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
-   = help: consider adding a `where Self: std::marker::Sized` bound
 
 error: aborting due to previous error