about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCharles Lew <crlf0710@gmail.com>2021-07-31 23:08:56 +0800
committerCharles Lew <crlf0710@gmail.com>2021-08-03 01:09:38 +0800
commit3cb625e4683c43991de6fc27d6b4e0db5a34011f (patch)
tree24fe8c252757e305e94b55febe728ff29b9089d3
parenta14433347945af2c514074c1d66066ee9f5e8a72 (diff)
downloadrust-3cb625e4683c43991de6fc27d6b4e0db5a34011f.tar.gz
rust-3cb625e4683c43991de6fc27d6b4e0db5a34011f.zip
Various adjustments to historic tests and documents.
-rw-r--r--src/doc/unstable-book/src/language-features/trait-upcasting.md13
-rw-r--r--src/test/ui/traits/trait-upcasting/basic.rs49
-rw-r--r--src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.rs2
-rw-r--r--src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr11
-rw-r--r--src/test/ui/traits/trait-upcasting/diamond.rs67
-rw-r--r--src/test/ui/traits/trait-upcasting/invalid-upcast.rs67
-rw-r--r--src/test/ui/traits/trait-upcasting/invalid-upcast.stderr179
-rw-r--r--src/test/ui/traits/trait-upcasting/lifetime.rs50
-rw-r--r--src/test/ui/traits/trait-upcasting/struct.rs37
-rw-r--r--src/test/ui/traits/trait-upcasting/subtrait-method.rs37
-rw-r--r--src/test/ui/traits/trait-upcasting/subtrait-method.stderr20
11 files changed, 334 insertions, 198 deletions
diff --git a/src/doc/unstable-book/src/language-features/trait-upcasting.md b/src/doc/unstable-book/src/language-features/trait-upcasting.md
index b7aafe58c31..3697ae38f9d 100644
--- a/src/doc/unstable-book/src/language-features/trait-upcasting.md
+++ b/src/doc/unstable-book/src/language-features/trait-upcasting.md
@@ -1,17 +1,18 @@
 # `trait_upcasting`
 
-The tracking issue for this feature is: [#31436]
+The tracking issue for this feature is: [#65991]
 
 [#65991]: https://github.com/rust-lang/rust/issues/65991
 
 ------------------------
 
-The `trait_upcasting` feature adds support for trait upcasting. This allows a
-trait object of type `dyn Foo` to be cast to a trait object of type `dyn Bar`
-so long as `Foo: Bar`.
+The `trait_upcasting` feature adds support for trait upcasting coercion. This allows a
+trait object of type `dyn Bar` to be cast to a trait object of type `dyn Foo`
+so long as `Bar: Foo`.
 
 ```rust,edition2018
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 trait Foo {}
 
@@ -21,6 +22,6 @@ impl Foo for i32 {}
 
 impl<T: Foo + ?Sized> Bar for T {}
 
-let foo: &dyn Foo = &123;
-let bar: &dyn Bar = foo;
+let bar: &dyn Bar = &123;
+let foo: &dyn Foo = bar;
 ```
diff --git a/src/test/ui/traits/trait-upcasting/basic.rs b/src/test/ui/traits/trait-upcasting/basic.rs
index 78ddbe08888..484a222bc01 100644
--- a/src/test/ui/traits/trait-upcasting/basic.rs
+++ b/src/test/ui/traits/trait-upcasting/basic.rs
@@ -1,43 +1,59 @@
 // run-pass
 
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
-    fn a(&self) -> i32 { 10 }
+    fn a(&self) -> i32 {
+        10
+    }
 
-    fn z(&self) -> i32 { 11 }
+    fn z(&self) -> i32 {
+        11
+    }
 
-    fn y(&self) -> i32 { 12 }
+    fn y(&self) -> i32 {
+        12
+    }
 }
 
 trait Bar: Foo {
-    fn b(&self) -> i32 { 20 }
+    fn b(&self) -> i32 {
+        20
+    }
 
-    fn w(&self) -> i32 { 21 }
+    fn w(&self) -> i32 {
+        21
+    }
 }
 
 trait Baz: Bar {
-    fn c(&self) -> i32 { 30 }
+    fn c(&self) -> i32 {
+        30
+    }
 }
 
 impl Foo for i32 {
-    fn a(&self) -> i32 { 100 }
+    fn a(&self) -> i32 {
+        100
+    }
 }
 
 impl Bar for i32 {
-    fn b(&self) -> i32 { 200 }
+    fn b(&self) -> i32 {
+        200
+    }
 }
 
 impl Baz for i32 {
-    fn c(&self) -> i32 { 300 }
+    fn c(&self) -> i32 {
+        300
+    }
 }
 
 fn main() {
     let baz: &dyn Baz = &1;
     let _: &dyn std::fmt::Debug = baz;
-    let _: &(dyn Send + Sync) = baz;
-    let _: &dyn Send = baz;
-    let _: &dyn Sync = baz;
     assert_eq!(*baz, 1);
     assert_eq!(baz.a(), 100);
     assert_eq!(baz.b(), 200);
@@ -48,9 +64,6 @@ fn main() {
 
     let bar: &dyn Bar = baz;
     let _: &dyn std::fmt::Debug = bar;
-    let _: &(dyn Send + Sync) = bar;
-    let _: &dyn Send = bar;
-    let _: &dyn Sync = bar;
     assert_eq!(*bar, 1);
     assert_eq!(bar.a(), 100);
     assert_eq!(bar.b(), 200);
@@ -60,9 +73,6 @@ fn main() {
 
     let foo: &dyn Foo = baz;
     let _: &dyn std::fmt::Debug = foo;
-    let _: &(dyn Send + Sync) = foo;
-    let _: &dyn Send = foo;
-    let _: &dyn Sync = foo;
     assert_eq!(*foo, 1);
     assert_eq!(foo.a(), 100);
     assert_eq!(foo.z(), 11);
@@ -70,9 +80,6 @@ fn main() {
 
     let foo: &dyn Foo = bar;
     let _: &dyn std::fmt::Debug = foo;
-    let _: &(dyn Send + Sync) = foo;
-    let _: &dyn Send = foo;
-    let _: &dyn Sync = foo;
     assert_eq!(*foo, 1);
     assert_eq!(foo.a(), 100);
     assert_eq!(foo.z(), 11);
diff --git a/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.rs b/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.rs
index 1666b7ba292..511e41562b2 100644
--- a/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.rs
+++ b/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.rs
@@ -1,5 +1,5 @@
 trait A: B + A {}
-//~^ ERROR cycle detected when computing the supertraits of `A` [E0391]
+//~^ ERROR cycle detected when computing the super predicates of `A` [E0391]
 
 trait B {}
 
diff --git a/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr b/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr
index 7a04c5d0dbb..ac005725ab4 100644
--- a/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr
+++ b/src/test/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr
@@ -1,10 +1,15 @@
-error[E0391]: cycle detected when computing the supertraits of `A`
+error[E0391]: cycle detected when computing the super predicates of `A`
+  --> $DIR/cyclic-trait-resolution.rs:1:1
+   |
+LL | trait A: B + A {}
+   | ^^^^^^^^^^^^^^
+   |
+note: ...which requires computing the super traits of `A`...
   --> $DIR/cyclic-trait-resolution.rs:1:14
    |
 LL | trait A: B + A {}
    |              ^
-   |
-   = note: ...which again requires computing the supertraits of `A`, completing the cycle
+   = note: ...which again requires computing the super predicates of `A`, completing the cycle
 note: cycle used when collecting item types in top-level module
   --> $DIR/cyclic-trait-resolution.rs:1:1
    |
diff --git a/src/test/ui/traits/trait-upcasting/diamond.rs b/src/test/ui/traits/trait-upcasting/diamond.rs
index 531b40d83f9..e4e23c1a26e 100644
--- a/src/test/ui/traits/trait-upcasting/diamond.rs
+++ b/src/test/ui/traits/trait-upcasting/diamond.rs
@@ -1,53 +1,75 @@
 // run-pass
 
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
-    fn a(&self) -> i32 { 10 }
+    fn a(&self) -> i32 {
+        10
+    }
 
-    fn z(&self) -> i32 { 11 }
+    fn z(&self) -> i32 {
+        11
+    }
 
-    fn y(&self) -> i32 { 12 }
+    fn y(&self) -> i32 {
+        12
+    }
 }
 
 trait Bar1: Foo {
-    fn b(&self) -> i32 { 20 }
+    fn b(&self) -> i32 {
+        20
+    }
 
-    fn w(&self) -> i32 { 21 }
+    fn w(&self) -> i32 {
+        21
+    }
 }
 
 trait Bar2: Foo {
-    fn c(&self) -> i32 { 30 }
+    fn c(&self) -> i32 {
+        30
+    }
 
-    fn v(&self) -> i32 { 31 }
+    fn v(&self) -> i32 {
+        31
+    }
 }
 
 trait Baz: Bar1 + Bar2 {
-    fn d(&self) -> i32 { 40 }
+    fn d(&self) -> i32 {
+        40
+    }
 }
 
 impl Foo for i32 {
-    fn a(&self) -> i32 { 100 }
+    fn a(&self) -> i32 {
+        100
+    }
 }
 
 impl Bar1 for i32 {
-    fn b(&self) -> i32 { 200 }
+    fn b(&self) -> i32 {
+        200
+    }
 }
 
 impl Bar2 for i32 {
-    fn c(&self) -> i32 { 300 }
+    fn c(&self) -> i32 {
+        300
+    }
 }
 
 impl Baz for i32 {
-    fn d(&self) -> i32 { 400 }
+    fn d(&self) -> i32 {
+        400
+    }
 }
 
 fn main() {
     let baz: &dyn Baz = &1;
     let _: &dyn std::fmt::Debug = baz;
-    let _: &(dyn Send + Sync) = baz;
-    let _: &dyn Send = baz;
-    let _: &dyn Sync = baz;
     assert_eq!(*baz, 1);
     assert_eq!(baz.a(), 100);
     assert_eq!(baz.b(), 200);
@@ -60,9 +82,6 @@ fn main() {
 
     let bar1: &dyn Bar1 = baz;
     let _: &dyn std::fmt::Debug = bar1;
-    let _: &(dyn Send + Sync) = bar1;
-    let _: &dyn Send = bar1;
-    let _: &dyn Sync = bar1;
     assert_eq!(*bar1, 1);
     assert_eq!(bar1.a(), 100);
     assert_eq!(bar1.b(), 200);
@@ -72,9 +91,6 @@ fn main() {
 
     let bar2: &dyn Bar2 = baz;
     let _: &dyn std::fmt::Debug = bar2;
-    let _: &(dyn Send + Sync) = bar2;
-    let _: &dyn Send = bar2;
-    let _: &dyn Sync = bar2;
     assert_eq!(*bar2, 1);
     assert_eq!(bar2.a(), 100);
     assert_eq!(bar2.c(), 300);
@@ -84,25 +100,16 @@ fn main() {
 
     let foo: &dyn Foo = baz;
     let _: &dyn std::fmt::Debug = foo;
-    let _: &(dyn Send + Sync) = foo;
-    let _: &dyn Send = foo;
-    let _: &dyn Sync = foo;
     assert_eq!(*foo, 1);
     assert_eq!(foo.a(), 100);
 
     let foo: &dyn Foo = bar1;
     let _: &dyn std::fmt::Debug = foo;
-    let _: &(dyn Send + Sync) = foo;
-    let _: &dyn Send = foo;
-    let _: &dyn Sync = foo;
     assert_eq!(*foo, 1);
     assert_eq!(foo.a(), 100);
 
     let foo: &dyn Foo = bar2;
     let _: &dyn std::fmt::Debug = foo;
-    let _: &(dyn Send + Sync) = foo;
-    let _: &dyn Send = foo;
-    let _: &dyn Sync = foo;
     assert_eq!(*foo, 1);
     assert_eq!(foo.a(), 100);
 }
diff --git a/src/test/ui/traits/trait-upcasting/invalid-upcast.rs b/src/test/ui/traits/trait-upcasting/invalid-upcast.rs
index ac1ef6313fc..24022450406 100644
--- a/src/test/ui/traits/trait-upcasting/invalid-upcast.rs
+++ b/src/test/ui/traits/trait-upcasting/invalid-upcast.rs
@@ -1,68 +1,87 @@
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 trait Foo {
-    fn a(&self) -> i32 { 10 }
+    fn a(&self) -> i32 {
+        10
+    }
 
-    fn z(&self) -> i32 { 11 }
+    fn z(&self) -> i32 {
+        11
+    }
 
-    fn y(&self) -> i32 { 12 }
+    fn y(&self) -> i32 {
+        12
+    }
 }
 
 trait Bar {
-    fn b(&self) -> i32 { 20 }
+    fn b(&self) -> i32 {
+        20
+    }
 
-    fn w(&self) -> i32 { 21 }
+    fn w(&self) -> i32 {
+        21
+    }
 }
 
 trait Baz {
-    fn c(&self) -> i32 { 30 }
+    fn c(&self) -> i32 {
+        30
+    }
 }
 
 impl Foo for i32 {
-    fn a(&self) -> i32 { 100 }
+    fn a(&self) -> i32 {
+        100
+    }
 }
 
 impl Bar for i32 {
-    fn b(&self) -> i32 { 200 }
+    fn b(&self) -> i32 {
+        200
+    }
 }
 
 impl Baz for i32 {
-    fn c(&self) -> i32 { 300 }
+    fn c(&self) -> i32 {
+        300
+    }
 }
 
 fn main() {
     let baz: &dyn Baz = &1;
     let _: &dyn std::fmt::Debug = baz;
-    //~^ ERROR `dyn Baz` doesn't implement `std::fmt::Debug` [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Send = baz;
-    //~^ ERROR `dyn Baz` cannot be sent between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Sync = baz;
-    //~^ ERROR `dyn Baz` cannot be shared between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
 
     let bar: &dyn Bar = baz;
-    //~^ ERROR the trait bound `dyn Baz: Bar` is not satisfied [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn std::fmt::Debug = bar;
-    //~^ ERROR `dyn Bar` doesn't implement `std::fmt::Debug` [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Send = bar;
-    //~^ ERROR `dyn Bar` cannot be sent between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Sync = bar;
-    //~^ ERROR `dyn Bar` cannot be shared between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
 
     let foo: &dyn Foo = baz;
-    //~^ ERROR the trait bound `dyn Baz: Foo` is not satisfied [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn std::fmt::Debug = foo;
-    //~^ ERROR `dyn Foo` doesn't implement `std::fmt::Debug` [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Send = foo;
-    //~^ ERROR `dyn Foo` cannot be sent between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Sync = foo;
-    //~^ ERROR `dyn Foo` cannot be shared between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
 
     let foo: &dyn Foo = bar;
-    //~^ ERROR the trait bound `dyn Bar: Foo` is not satisfied [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn std::fmt::Debug = foo;
-    //~^ ERROR `dyn Foo` doesn't implement `std::fmt::Debug` [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Send = foo;
-    //~^ ERROR `dyn Foo` cannot be sent between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
     let _: &dyn Sync = foo;
-    //~^ ERROR `dyn Foo` cannot be shared between threads safely [E0277]
+    //~^ ERROR mismatched types [E0308]
 }
diff --git a/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr b/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr
index 731394d480a..b4530ed0c3a 100644
--- a/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr
+++ b/src/test/ui/traits/trait-upcasting/invalid-upcast.stderr
@@ -1,135 +1,168 @@
-error[E0277]: `dyn Baz` doesn't implement `std::fmt::Debug`
-  --> $DIR/invalid-upcast.rs:35:35
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:54:35
    |
 LL |     let _: &dyn std::fmt::Debug = baz;
-   |                                   ^^^ `dyn Baz` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |            --------------------   ^^^ expected trait `Debug`, found trait `Baz`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::fmt::Debug` is not implemented for `dyn Baz`
-   = note: required for the cast to the object type `dyn std::fmt::Debug`
+   = note: expected reference `&dyn Debug`
+              found reference `&dyn Baz`
 
-error[E0277]: `dyn Baz` cannot be sent between threads safely
-  --> $DIR/invalid-upcast.rs:37:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:56:24
    |
 LL |     let _: &dyn Send = baz;
-   |                        ^^^ `dyn Baz` cannot be sent between threads safely
+   |            ---------   ^^^ expected trait `Send`, found trait `Baz`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Send` is not implemented for `dyn Baz`
-   = note: required for the cast to the object type `dyn std::marker::Send`
+   = note: expected reference `&dyn Send`
+              found reference `&dyn Baz`
 
-error[E0277]: `dyn Baz` cannot be shared between threads safely
-  --> $DIR/invalid-upcast.rs:39:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:58:24
    |
 LL |     let _: &dyn Sync = baz;
-   |                        ^^^ `dyn Baz` cannot be shared between threads safely
+   |            ---------   ^^^ expected trait `Sync`, found trait `Baz`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Sync` is not implemented for `dyn Baz`
-   = note: required for the cast to the object type `dyn std::marker::Sync`
+   = note: expected reference `&dyn Sync`
+              found reference `&dyn Baz`
 
-error[E0277]: the trait bound `dyn Baz: Bar` is not satisfied
-  --> $DIR/invalid-upcast.rs:42:25
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:61:25
    |
 LL |     let bar: &dyn Bar = baz;
-   |                         ^^^ the trait `Bar` is not implemented for `dyn Baz`
+   |              --------   ^^^ expected trait `Bar`, found trait `Baz`
+   |              |
+   |              expected due to this
    |
-   = note: required for the cast to the object type `dyn Bar`
+   = note: expected reference `&dyn Bar`
+              found reference `&dyn Baz`
 
-error[E0277]: `dyn Bar` doesn't implement `std::fmt::Debug`
-  --> $DIR/invalid-upcast.rs:44:35
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:63:35
    |
 LL |     let _: &dyn std::fmt::Debug = bar;
-   |                                   ^^^ `dyn Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |            --------------------   ^^^ expected trait `Debug`, found trait `Bar`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::fmt::Debug` is not implemented for `dyn Bar`
-   = note: required for the cast to the object type `dyn std::fmt::Debug`
+   = note: expected reference `&dyn Debug`
+              found reference `&dyn Bar`
 
-error[E0277]: `dyn Bar` cannot be sent between threads safely
-  --> $DIR/invalid-upcast.rs:46:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:65:24
    |
 LL |     let _: &dyn Send = bar;
-   |                        ^^^ `dyn Bar` cannot be sent between threads safely
+   |            ---------   ^^^ expected trait `Send`, found trait `Bar`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Send` is not implemented for `dyn Bar`
-   = note: required for the cast to the object type `dyn std::marker::Send`
+   = note: expected reference `&dyn Send`
+              found reference `&dyn Bar`
 
-error[E0277]: `dyn Bar` cannot be shared between threads safely
-  --> $DIR/invalid-upcast.rs:48:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:67:24
    |
 LL |     let _: &dyn Sync = bar;
-   |                        ^^^ `dyn Bar` cannot be shared between threads safely
+   |            ---------   ^^^ expected trait `Sync`, found trait `Bar`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Sync` is not implemented for `dyn Bar`
-   = note: required for the cast to the object type `dyn std::marker::Sync`
+   = note: expected reference `&dyn Sync`
+              found reference `&dyn Bar`
 
-error[E0277]: the trait bound `dyn Baz: Foo` is not satisfied
-  --> $DIR/invalid-upcast.rs:51:25
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:70:25
    |
 LL |     let foo: &dyn Foo = baz;
-   |                         ^^^ the trait `Foo` is not implemented for `dyn Baz`
+   |              --------   ^^^ expected trait `Foo`, found trait `Baz`
+   |              |
+   |              expected due to this
    |
-   = note: required for the cast to the object type `dyn Foo`
+   = note: expected reference `&dyn Foo`
+              found reference `&dyn Baz`
 
-error[E0277]: `dyn Foo` doesn't implement `std::fmt::Debug`
-  --> $DIR/invalid-upcast.rs:53:35
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:72:35
    |
 LL |     let _: &dyn std::fmt::Debug = foo;
-   |                                   ^^^ `dyn Foo` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |            --------------------   ^^^ expected trait `Debug`, found trait `Foo`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::fmt::Debug` is not implemented for `dyn Foo`
-   = note: required for the cast to the object type `dyn std::fmt::Debug`
+   = note: expected reference `&dyn Debug`
+              found reference `&dyn Foo`
 
-error[E0277]: `dyn Foo` cannot be sent between threads safely
-  --> $DIR/invalid-upcast.rs:55:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:74:24
    |
 LL |     let _: &dyn Send = foo;
-   |                        ^^^ `dyn Foo` cannot be sent between threads safely
+   |            ---------   ^^^ expected trait `Send`, found trait `Foo`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Send` is not implemented for `dyn Foo`
-   = note: required for the cast to the object type `dyn std::marker::Send`
+   = note: expected reference `&dyn Send`
+              found reference `&dyn Foo`
 
-error[E0277]: `dyn Foo` cannot be shared between threads safely
-  --> $DIR/invalid-upcast.rs:57:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:76:24
    |
 LL |     let _: &dyn Sync = foo;
-   |                        ^^^ `dyn Foo` cannot be shared between threads safely
+   |            ---------   ^^^ expected trait `Sync`, found trait `Foo`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Sync` is not implemented for `dyn Foo`
-   = note: required for the cast to the object type `dyn std::marker::Sync`
+   = note: expected reference `&dyn Sync`
+              found reference `&dyn Foo`
 
-error[E0277]: the trait bound `dyn Bar: Foo` is not satisfied
-  --> $DIR/invalid-upcast.rs:60:25
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:79:25
    |
 LL |     let foo: &dyn Foo = bar;
-   |                         ^^^ the trait `Foo` is not implemented for `dyn Bar`
+   |              --------   ^^^ expected trait `Foo`, found trait `Bar`
+   |              |
+   |              expected due to this
    |
-   = note: required for the cast to the object type `dyn Foo`
+   = note: expected reference `&dyn Foo`
+              found reference `&dyn Bar`
 
-error[E0277]: `dyn Foo` doesn't implement `std::fmt::Debug`
-  --> $DIR/invalid-upcast.rs:62:35
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:81:35
    |
 LL |     let _: &dyn std::fmt::Debug = foo;
-   |                                   ^^^ `dyn Foo` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |            --------------------   ^^^ expected trait `Debug`, found trait `Foo`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::fmt::Debug` is not implemented for `dyn Foo`
-   = note: required for the cast to the object type `dyn std::fmt::Debug`
+   = note: expected reference `&dyn Debug`
+              found reference `&dyn Foo`
 
-error[E0277]: `dyn Foo` cannot be sent between threads safely
-  --> $DIR/invalid-upcast.rs:64:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:83:24
    |
 LL |     let _: &dyn Send = foo;
-   |                        ^^^ `dyn Foo` cannot be sent between threads safely
+   |            ---------   ^^^ expected trait `Send`, found trait `Foo`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Send` is not implemented for `dyn Foo`
-   = note: required for the cast to the object type `dyn std::marker::Send`
+   = note: expected reference `&dyn Send`
+              found reference `&dyn Foo`
 
-error[E0277]: `dyn Foo` cannot be shared between threads safely
-  --> $DIR/invalid-upcast.rs:66:24
+error[E0308]: mismatched types
+  --> $DIR/invalid-upcast.rs:85:24
    |
 LL |     let _: &dyn Sync = foo;
-   |                        ^^^ `dyn Foo` cannot be shared between threads safely
+   |            ---------   ^^^ expected trait `Sync`, found trait `Foo`
+   |            |
+   |            expected due to this
    |
-   = help: the trait `std::marker::Sync` is not implemented for `dyn Foo`
-   = note: required for the cast to the object type `dyn std::marker::Sync`
+   = note: expected reference `&dyn Sync`
+              found reference `&dyn Foo`
 
 error: aborting due to 15 previous errors
 
-For more information about this error, try `rustc --explain E0277`.
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/trait-upcasting/lifetime.rs b/src/test/ui/traits/trait-upcasting/lifetime.rs
index 46b461583db..052f090102e 100644
--- a/src/test/ui/traits/trait-upcasting/lifetime.rs
+++ b/src/test/ui/traits/trait-upcasting/lifetime.rs
@@ -1,41 +1,67 @@
 // run-pass
+// ignore-compare-mode-nll
 
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
-    fn a(&self) -> i32 { 10 }
+    fn a(&self) -> i32 {
+        10
+    }
 
-    fn z(&self) -> i32 { 11 }
+    fn z(&self) -> i32 {
+        11
+    }
 
-    fn y(&self) -> i32 { 12 }
+    fn y(&self) -> i32 {
+        12
+    }
 }
 
 trait Bar: Foo {
-    fn b(&self) -> i32 { 20 }
+    fn b(&self) -> i32 {
+        20
+    }
 
-    fn w(&self) -> i32 { 21 }
+    fn w(&self) -> i32 {
+        21
+    }
 }
 
 trait Baz: Bar {
-    fn c(&self) -> i32 { 30 }
+    fn c(&self) -> i32 {
+        30
+    }
 }
 
 impl Foo for i32 {
-    fn a(&self) -> i32 { 100 }
+    fn a(&self) -> i32 {
+        100
+    }
 }
 
 impl Bar for i32 {
-    fn b(&self) -> i32 { 200 }
+    fn b(&self) -> i32 {
+        200
+    }
 }
 
 impl Baz for i32 {
-    fn c(&self) -> i32 { 300 }
+    fn c(&self) -> i32 {
+        300
+    }
 }
 
 // Note: upcast lifetime means a shorter lifetime.
-fn upcast_baz<'a: 'b, 'b, T>(v: Box<dyn Baz + 'a>, _l: &'b T) -> Box<dyn Baz + 'b> { v }
-fn upcast_bar<'a: 'b, 'b, T>(v: Box<dyn Bar + 'a>, _l: &'b T) -> Box<dyn Bar + 'b> { v }
-fn upcast_foo<'a: 'b, 'b, T>(v: Box<dyn Foo + 'a>, _l: &'b T) -> Box<dyn Foo + 'b> { v }
+fn upcast_baz<'a: 'b, 'b, T>(v: Box<dyn Baz + 'a>, _l: &'b T) -> Box<dyn Baz + 'b> {
+    v
+}
+fn upcast_bar<'a: 'b, 'b, T>(v: Box<dyn Bar + 'a>, _l: &'b T) -> Box<dyn Bar + 'b> {
+    v
+}
+fn upcast_foo<'a: 'b, 'b, T>(v: Box<dyn Foo + 'a>, _l: &'b T) -> Box<dyn Foo + 'b> {
+    v
+}
 
 fn main() {
     let v = Box::new(1);
diff --git a/src/test/ui/traits/trait-upcasting/struct.rs b/src/test/ui/traits/trait-upcasting/struct.rs
index cf71ed49551..0f3cb285bf4 100644
--- a/src/test/ui/traits/trait-upcasting/struct.rs
+++ b/src/test/ui/traits/trait-upcasting/struct.rs
@@ -1,38 +1,57 @@
 // run-pass
 
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 use std::rc::Rc;
 use std::sync::Arc;
 
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
-    fn a(&self) -> i32 { 10 }
+    fn a(&self) -> i32 {
+        10
+    }
 
-    fn z(&self) -> i32 { 11 }
+    fn z(&self) -> i32 {
+        11
+    }
 
-    fn y(&self) -> i32 { 12 }
+    fn y(&self) -> i32 {
+        12
+    }
 }
 
 trait Bar: Foo {
-    fn b(&self) -> i32 { 20 }
+    fn b(&self) -> i32 {
+        20
+    }
 
-    fn w(&self) -> i32 { 21 }
+    fn w(&self) -> i32 {
+        21
+    }
 }
 
 trait Baz: Bar {
-    fn c(&self) -> i32 { 30 }
+    fn c(&self) -> i32 {
+        30
+    }
 }
 
 impl Foo for i32 {
-    fn a(&self) -> i32 { 100 }
+    fn a(&self) -> i32 {
+        100
+    }
 }
 
 impl Bar for i32 {
-    fn b(&self) -> i32 { 200 }
+    fn b(&self) -> i32 {
+        200
+    }
 }
 
 impl Baz for i32 {
-    fn c(&self) -> i32 { 300 }
+    fn c(&self) -> i32 {
+        300
+    }
 }
 
 fn test_box() {
diff --git a/src/test/ui/traits/trait-upcasting/subtrait-method.rs b/src/test/ui/traits/trait-upcasting/subtrait-method.rs
index 0c3af54fe2b..3508e15284b 100644
--- a/src/test/ui/traits/trait-upcasting/subtrait-method.rs
+++ b/src/test/ui/traits/trait-upcasting/subtrait-method.rs
@@ -1,33 +1,52 @@
 #![feature(trait_upcasting)]
+#![allow(incomplete_features)]
 
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
-    fn a(&self) -> i32 { 10 }
+    fn a(&self) -> i32 {
+        10
+    }
 
-    fn z(&self) -> i32 { 11 }
+    fn z(&self) -> i32 {
+        11
+    }
 
-    fn y(&self) -> i32 { 12 }
+    fn y(&self) -> i32 {
+        12
+    }
 }
 
 trait Bar: Foo {
-    fn b(&self) -> i32 { 20 }
+    fn b(&self) -> i32 {
+        20
+    }
 
-    fn w(&self) -> i32 { 21 }
+    fn w(&self) -> i32 {
+        21
+    }
 }
 
 trait Baz: Bar {
-    fn c(&self) -> i32 { 30 }
+    fn c(&self) -> i32 {
+        30
+    }
 }
 
 impl Foo for i32 {
-    fn a(&self) -> i32 { 100 }
+    fn a(&self) -> i32 {
+        100
+    }
 }
 
 impl Bar for i32 {
-    fn b(&self) -> i32 { 200 }
+    fn b(&self) -> i32 {
+        200
+    }
 }
 
 impl Baz for i32 {
-    fn c(&self) -> i32 { 300 }
+    fn c(&self) -> i32 {
+        300
+    }
 }
 
 fn main() {
diff --git a/src/test/ui/traits/trait-upcasting/subtrait-method.stderr b/src/test/ui/traits/trait-upcasting/subtrait-method.stderr
index 4b0765cdb82..8c69011800b 100644
--- a/src/test/ui/traits/trait-upcasting/subtrait-method.stderr
+++ b/src/test/ui/traits/trait-upcasting/subtrait-method.stderr
@@ -1,64 +1,64 @@
 error[E0599]: no method named `c` found for reference `&dyn Bar` in the current scope
-  --> $DIR/subtrait-method.rs:37:9
+  --> $DIR/subtrait-method.rs:56:9
    |
 LL |     bar.c();
    |         ^ help: there is an associated function with a similar name: `a`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `Baz` defines an item `c`, perhaps you need to implement it
-  --> $DIR/subtrait-method.rs:17:1
+  --> $DIR/subtrait-method.rs:28:1
    |
 LL | trait Baz: Bar {
    | ^^^^^^^^^^^^^^
 
 error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope
-  --> $DIR/subtrait-method.rs:41:9
+  --> $DIR/subtrait-method.rs:60:9
    |
 LL |     foo.b();
    |         ^ help: there is an associated function with a similar name: `a`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `Bar` defines an item `b`, perhaps you need to implement it
-  --> $DIR/subtrait-method.rs:11:1
+  --> $DIR/subtrait-method.rs:18:1
    |
 LL | trait Bar: Foo {
    | ^^^^^^^^^^^^^^
 
 error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope
-  --> $DIR/subtrait-method.rs:43:9
+  --> $DIR/subtrait-method.rs:62:9
    |
 LL |     foo.c();
    |         ^ help: there is an associated function with a similar name: `a`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `Baz` defines an item `c`, perhaps you need to implement it
-  --> $DIR/subtrait-method.rs:17:1
+  --> $DIR/subtrait-method.rs:28:1
    |
 LL | trait Baz: Bar {
    | ^^^^^^^^^^^^^^
 
 error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope
-  --> $DIR/subtrait-method.rs:47:9
+  --> $DIR/subtrait-method.rs:66:9
    |
 LL |     foo.b();
    |         ^ help: there is an associated function with a similar name: `a`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `Bar` defines an item `b`, perhaps you need to implement it
-  --> $DIR/subtrait-method.rs:11:1
+  --> $DIR/subtrait-method.rs:18:1
    |
 LL | trait Bar: Foo {
    | ^^^^^^^^^^^^^^
 
 error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope
-  --> $DIR/subtrait-method.rs:49:9
+  --> $DIR/subtrait-method.rs:68:9
    |
 LL |     foo.c();
    |         ^ help: there is an associated function with a similar name: `a`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `Baz` defines an item `c`, perhaps you need to implement it
-  --> $DIR/subtrait-method.rs:17:1
+  --> $DIR/subtrait-method.rs:28:1
    |
 LL | trait Baz: Bar {
    | ^^^^^^^^^^^^^^