about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Regueiro <alexreg@me.com>2019-03-30 22:06:09 +0000
committerAlexander Regueiro <alexreg@me.com>2019-05-20 16:12:49 +0100
commitfd7c253accd46ea8340feb79ecaf18d99f518bb8 (patch)
treefeea292bca793ad38ae2204f0a8d7c692d613b34 /src
parentaea954b74de16888f09ff003ebfdf97f9f7ef001 (diff)
downloadrust-fd7c253accd46ea8340feb79ecaf18d99f518bb8.tar.gz
rust-fd7c253accd46ea8340feb79ecaf18d99f518bb8.zip
Update tests.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/associated-types/associated-types-overridden-binding-2.stderr2
-rw-r--r--src/test/ui/bad/bad-sized.stderr4
-rw-r--r--src/test/ui/error-codes/E0225.stderr10
-rw-r--r--src/test/ui/issues/issue-22560.stderr22
-rw-r--r--src/test/ui/issues/issue-32963.stderr4
-rw-r--r--src/test/ui/maybe-bounds.rs4
-rw-r--r--src/test/ui/maybe-bounds.stderr14
-rw-r--r--src/test/ui/parser/trait-object-trait-parens.rs4
-rw-r--r--src/test/ui/parser/trait-object-trait-parens.stderr16
-rw-r--r--src/test/ui/traits/trait-alias-object.rs9
-rw-r--r--src/test/ui/traits/trait-alias/auxiliary/trait_alias.rs (renamed from src/test/ui/traits/auxiliary/trait_alias.rs)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-bounds.rs (renamed from src/test/run-pass/traits/trait-alias-bounds.rs)2
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-cross-crate.rs (renamed from src/test/ui/traits/trait-alias-cross-crate.rs)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr (renamed from src/test/ui/traits/trait-alias-cross-crate.stderr)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-impl.rs (renamed from src/test/ui/traits/trait-alias-impl.rs)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-impl.stderr (renamed from src/test/ui/traits/trait-alias-impl.stderr)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs27
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-maybe-bound.stderr14
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs126
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr358
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs121
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr371
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-object-fail.rs11
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr (renamed from src/test/ui/traits/trait-alias-object.stderr)8
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-object-wf.rs71
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-object.rs (renamed from src/test/run-pass/traits/trait-alias-object.rs)2
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-syntax-fail.rs (renamed from src/test/ui/traits/trait-alias-syntax.rs)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-syntax-fail.stderr (renamed from src/test/ui/traits/trait-alias-syntax.stderr)4
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-syntax.rs (renamed from src/test/run-pass/traits/trait-alias-syntax.rs)2
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-wf.rs (renamed from src/test/ui/traits/trait-alias-wf.rs)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias-wf.stderr (renamed from src/test/ui/traits/trait-alias-wf.stderr)0
-rw-r--r--src/test/ui/traits/trait-alias/trait-alias.rs (renamed from src/test/ui/run-pass/traits/trait-alias.rs)1
-rw-r--r--src/test/ui/traits/traits-static-outlives-a-where-clause.rs (renamed from src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs)0
-rw-r--r--src/test/ui/traits/wf-trait-object-maybe-bound.rs13
-rw-r--r--src/test/ui/traits/wf-trait-object-maybe-bound.stderr8
-rw-r--r--src/test/ui/traits/wf-trait-object-no-duplicates.rs33
-rw-r--r--src/test/ui/traits/wf-trait-object-no-duplicates.stderr43
-rw-r--r--src/test/ui/traits/wf-trait-object-reverse-order.rs15
38 files changed, 1259 insertions, 60 deletions
diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr
index ad0b6515490..85724cb7c6e 100644
--- a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr
+++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr
@@ -6,7 +6,7 @@ LL |     let _: &I32Iterator<Item = u32> = &vec![42].into_iter();
    |
    = note: expected type `u32`
               found type `i32`
-   = note: required for the cast to the object type `dyn I32Iterator<Item = u32, Item = i32>`
+   = note: required for the cast to the object type `dyn std::iter::Iterator<Item = u32, Item = i32>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr
index 321f9754158..671840acdbf 100644
--- a/src/test/ui/bad/bad-sized.stderr
+++ b/src/test/ui/bad/bad-sized.stderr
@@ -2,7 +2,9 @@ error[E0225]: only auto traits can be used as additional traits in a trait objec
   --> $DIR/bad-sized.rs:4:24
    |
 LL |     let x: Vec<Trait + Sized> = Vec::new();
-   |                        ^^^^^ non-auto additional trait
+   |                -----   ^^^^^ additional non-auto trait
+   |                |
+   |                first non-auto trait
 
 error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
   --> $DIR/bad-sized.rs:4:12
diff --git a/src/test/ui/error-codes/E0225.stderr b/src/test/ui/error-codes/E0225.stderr
index c8d8f07db8a..183cf0aad64 100644
--- a/src/test/ui/error-codes/E0225.stderr
+++ b/src/test/ui/error-codes/E0225.stderr
@@ -2,16 +2,20 @@ error[E0225]: only auto traits can be used as additional traits in a trait objec
   --> $DIR/E0225.rs:6:32
    |
 LL |     let _: Box<std::io::Read + std::io::Write>;
-   |                                ^^^^^^^^^^^^^^ non-auto additional trait
+   |                -------------   ^^^^^^^^^^^^^^ additional non-auto trait
+   |                |
+   |                first non-auto trait
 
 error[E0225]: only auto traits can be used as additional traits in a trait object
   --> $DIR/E0225.rs:8:16
    |
 LL | trait Foo = std::io::Read + std::io::Write;
-   |                             -------------- non-auto additional trait
+   |             -------------   -------------- additional non-auto trait
+   |             |
+   |             first non-auto trait
 ...
 LL |     let _: Box<Foo>;
-   |                ^^^ expanded from this alias
+   |                ^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr
index 5a056dff590..2c6f4d9d45f 100644
--- a/src/test/ui/issues/issue-22560.stderr
+++ b/src/test/ui/issues/issue-22560.stderr
@@ -1,15 +1,15 @@
 error[E0393]: the type parameter `Rhs` must be explicitly specified
-  --> $DIR/issue-22560.rs:3:13
+  --> $DIR/issue-22560.rs:6:13
    |
-LL | type Test = Add +
+LL |             Sub;
    |             ^^^ missing reference to `Rhs`
    |
    = note: because of the default `Self` reference, type parameters must be specified on object types
 
 error[E0393]: the type parameter `Rhs` must be explicitly specified
-  --> $DIR/issue-22560.rs:6:13
+  --> $DIR/issue-22560.rs:3:13
    |
-LL |             Sub;
+LL | type Test = Add +
    |             ^^^ missing reference to `Rhs`
    |
    = note: because of the default `Self` reference, type parameters must be specified on object types
@@ -17,18 +17,26 @@ LL |             Sub;
 error[E0225]: only auto traits can be used as additional traits in a trait object
   --> $DIR/issue-22560.rs:6:13
    |
+LL | type Test = Add +
+   |             --- first non-auto trait
+...
 LL |             Sub;
-   |             ^^^ non-auto additional trait
+   |             ^^^ additional non-auto trait
 
-error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified
+error[E0191]: the value of the associated types `Output` (from the trait `std::ops::Add`), `Output` (from the trait `std::ops::Sub`) must be specified
   --> $DIR/issue-22560.rs:3:13
    |
 LL |   type Test = Add +
    |  _____________^
+   | |_____________|
+   | |
 LL | |
 LL | |
 LL | |             Sub;
-   | |_______________^ associated type `Output` must be specified
+   | |               ^
+   | |_______________|
+   | |_______________associated type `Output` must be specified
+   |                 associated type `Output` must be specified
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/issues/issue-32963.stderr b/src/test/ui/issues/issue-32963.stderr
index 70fda313170..381ccdbeb99 100644
--- a/src/test/ui/issues/issue-32963.stderr
+++ b/src/test/ui/issues/issue-32963.stderr
@@ -2,7 +2,9 @@ error[E0225]: only auto traits can be used as additional traits in a trait objec
   --> $DIR/issue-32963.rs:8:25
    |
 LL |     size_of_copy::<Misc+Copy>();
-   |                         ^^^^ non-auto additional trait
+   |                    ---- ^^^^ additional non-auto trait
+   |                    |
+   |                    first non-auto trait
 
 error[E0277]: the trait bound `dyn Misc: std::marker::Copy` is not satisfied
   --> $DIR/issue-32963.rs:8:5
diff --git a/src/test/ui/maybe-bounds.rs b/src/test/ui/maybe-bounds.rs
index 3e07026fb7d..7defd8d3943 100644
--- a/src/test/ui/maybe-bounds.rs
+++ b/src/test/ui/maybe-bounds.rs
@@ -1,6 +1,6 @@
 trait Tr: ?Sized {} //~ ERROR `?Trait` is not permitted in supertraits
 
-type A1 = Tr + (?Sized); //~ ERROR `?Trait` is not permitted in trait object types
-type A2 = for<'a> Tr + (?Sized); //~ ERROR `?Trait` is not permitted in trait object types
+type A1 = Tr + (?Sized);
+type A2 = for<'a> Tr + (?Sized);
 
 fn main() {}
diff --git a/src/test/ui/maybe-bounds.stderr b/src/test/ui/maybe-bounds.stderr
index 20446c257df..d8c2adfc61c 100644
--- a/src/test/ui/maybe-bounds.stderr
+++ b/src/test/ui/maybe-bounds.stderr
@@ -6,17 +6,5 @@ LL | trait Tr: ?Sized {}
    |
    = note: traits are `?Sized` by default
 
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/maybe-bounds.rs:3:16
-   |
-LL | type A1 = Tr + (?Sized);
-   |                ^^^^^^^^
-
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/maybe-bounds.rs:4:24
-   |
-LL | type A2 = for<'a> Tr + (?Sized);
-   |                        ^^^^^^^^
-
-error: aborting due to 3 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/parser/trait-object-trait-parens.rs b/src/test/ui/parser/trait-object-trait-parens.rs
index 2bbc5800015..49373564f67 100644
--- a/src/test/ui/parser/trait-object-trait-parens.rs
+++ b/src/test/ui/parser/trait-object-trait-parens.rs
@@ -4,9 +4,7 @@ fn f<T: (Copy) + (?Sized) + (for<'a> Trait<'a>)>() {}
 
 fn main() {
     let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
-    //~^ ERROR `?Trait` is not permitted in trait object types
     let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>;
     let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
-    //~^ ERROR `?Trait` is not permitted in trait object types
-    //~| ERROR use of undeclared lifetime name `'a`
+    //~^ ERROR use of undeclared lifetime name `'a`
 }
diff --git a/src/test/ui/parser/trait-object-trait-parens.stderr b/src/test/ui/parser/trait-object-trait-parens.stderr
index 36494b76539..1cf40b30406 100644
--- a/src/test/ui/parser/trait-object-trait-parens.stderr
+++ b/src/test/ui/parser/trait-object-trait-parens.stderr
@@ -1,21 +1,9 @@
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/trait-object-trait-parens.rs:6:25
-   |
-LL |     let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
-   |                         ^^^^^^^^
-
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/trait-object-trait-parens.rs:9:47
-   |
-LL |     let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
-   |                                               ^^^^^^^^
-
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/trait-object-trait-parens.rs:9:31
+  --> $DIR/trait-object-trait-parens.rs:8:31
    |
 LL |     let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
    |                               ^^ undeclared lifetime
 
-error: aborting due to 3 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0261`.
diff --git a/src/test/ui/traits/trait-alias-object.rs b/src/test/ui/traits/trait-alias-object.rs
deleted file mode 100644
index 37963740117..00000000000
--- a/src/test/ui/traits/trait-alias-object.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(trait_alias)]
-
-trait EqAlias = Eq;
-trait IteratorAlias = Iterator;
-
-fn main() {
-    let _: &dyn EqAlias = &123; //~ ERROR `EqAlias` cannot be made into an object
-    let _: &dyn IteratorAlias = &vec![123].into_iter(); //~ ERROR must be specified
-}
diff --git a/src/test/ui/traits/auxiliary/trait_alias.rs b/src/test/ui/traits/trait-alias/auxiliary/trait_alias.rs
index 9e56b87e088..9e56b87e088 100644
--- a/src/test/ui/traits/auxiliary/trait_alias.rs
+++ b/src/test/ui/traits/trait-alias/auxiliary/trait_alias.rs
diff --git a/src/test/run-pass/traits/trait-alias-bounds.rs b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs
index d3dd5cee0c3..428ce5102ba 100644
--- a/src/test/run-pass/traits/trait-alias-bounds.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs
@@ -1,3 +1,5 @@
+// run-pass
+
 #![feature(trait_alias)]
 
 use std::marker::PhantomData;
diff --git a/src/test/ui/traits/trait-alias-cross-crate.rs b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.rs
index 259fc4fa5d1..259fc4fa5d1 100644
--- a/src/test/ui/traits/trait-alias-cross-crate.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.rs
diff --git a/src/test/ui/traits/trait-alias-cross-crate.stderr b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr
index 972d213ac8f..972d213ac8f 100644
--- a/src/test/ui/traits/trait-alias-cross-crate.stderr
+++ b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr
diff --git a/src/test/ui/traits/trait-alias-impl.rs b/src/test/ui/traits/trait-alias/trait-alias-impl.rs
index 6e35793a066..6e35793a066 100644
--- a/src/test/ui/traits/trait-alias-impl.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-impl.rs
diff --git a/src/test/ui/traits/trait-alias-impl.stderr b/src/test/ui/traits/trait-alias/trait-alias-impl.stderr
index 301db4fb71c..301db4fb71c 100644
--- a/src/test/ui/traits/trait-alias-impl.stderr
+++ b/src/test/ui/traits/trait-alias/trait-alias-impl.stderr
diff --git a/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs b/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs
new file mode 100644
index 00000000000..f444dba5d28
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs
@@ -0,0 +1,27 @@
+// Test that `dyn ... + ?Sized + ...` resulting from the expansion of trait aliases is okay.
+
+#![feature(trait_alias)]
+
+trait S = ?Sized;
+
+// Nest a couple of levels deep:
+trait _0 = S;
+trait _1 = _0;
+
+// Straight list expansion:
+type _T0 = dyn _1;
+//~^ ERROR at least one non-builtin trait is required for an object type [E0224]
+
+// In second position:
+type _T1 = dyn Copy + _1;
+
+// ... and with an auto trait:
+type _T2 = dyn Copy + Send + _1;
+
+// Twice:
+trait _2 = _1 + _1;
+
+type _T3 = dyn _2;
+//~^ ERROR at least one non-builtin trait is required for an object type [E0224]
+
+fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.stderr b/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.stderr
new file mode 100644
index 00000000000..52e90c00c37
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.stderr
@@ -0,0 +1,14 @@
+error[E0224]: at least one non-builtin trait is required for an object type
+  --> $DIR/trait-alias-maybe-bound.rs:12:12
+   |
+LL | type _T0 = dyn _1;
+   |            ^^^^^^
+
+error[E0224]: at least one non-builtin trait is required for an object type
+  --> $DIR/trait-alias-maybe-bound.rs:24:12
+   |
+LL | type _T3 = dyn _2;
+   |            ^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs
new file mode 100644
index 00000000000..95525883c64
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs
@@ -0,0 +1,126 @@
+// The purpose of this test is to demonstrate that duplicating object safe traits
+// that are not auto traits is rejected with trait aliases even though one could
+// reasonably accept this.
+
+#![feature(trait_alias)]
+
+use std::marker::Unpin;
+
+// Some arbitray object-safe trait:
+trait Obj {}
+
+// Nest a few levels deep:
+trait _0 = Obj;
+trait _1 = _0;
+
+type _T00 = dyn _0 + _0;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T01 = dyn _1 + _0;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T02 = dyn _1 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T03 = dyn Obj + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T04 = dyn _1 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more and in weird ways:
+
+trait _2 = _0 + _1;
+trait _3 = Obj;
+trait _4 = _3;
+
+type _T10 = dyn _2 + _3;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T11 = dyn _3 + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T12 = dyn Obj + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T13 = dyn _2 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T14 = dyn _1 + _3;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T15 = dyn _3 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T16 = dyn _1 + _4;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T17 = dyn _4 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Include auto traits:
+
+trait _5 = Obj + Send;
+
+type _T20 = dyn _5 + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T21 = dyn Obj + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T22 = dyn _5 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T23 = dyn _5 + Send + Sync + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Also nest:
+
+trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+
+type _T30 = dyn _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T31 = dyn _6 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T32 = dyn Send + _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more:
+
+trait _7 = _5 + Sync;
+trait _8 = Unpin + _7;
+
+type _T40 = dyn _8 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T41 = dyn Obj + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T42 = dyn _8 + _4;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T43 = dyn _4 + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T44 = dyn _4 + Send + Sync + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Take higher ranked types into account.
+
+// Note that `'a` and `'b` are intentionally different to make sure we consider
+// them semantically the same.
+trait ObjL<'l> {}
+trait _9 = for<'a> ObjL<'a>;
+trait _10 = for<'b> ObjL<'b>;
+type _T50 = _9 + _10;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+trait ObjT<T> {}
+trait _11 = ObjT<for<'a> fn(&'a u8)>;
+trait _12 = ObjT<for<'b> fn(&'b u8)>;
+type _T60 = _11 + _12;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr
new file mode 100644
index 00000000000..3cdf1582ab9
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr
@@ -0,0 +1,358 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:16:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | type _T00 = dyn _0 + _0;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:19:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | type _T01 = dyn _1 + _0;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:22:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | type _T02 = dyn _1 + _1;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:25:23
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | type _T03 = dyn Obj + _1;
+   |                 ---   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:28:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T04 = dyn _1 + Obj;
+   |                      ^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:37:17
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _2 = _0 + _1;
+   |                 -- referenced here
+...
+LL | type _T10 = dyn _2 + _3;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:40:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+...
+LL | trait _2 = _0 + _1;
+   |            -- referenced here
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T11 = dyn _3 + _2;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:43:23
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+...
+LL | trait _2 = _0 + _1;
+   |            -- referenced here
+...
+LL | type _T12 = dyn Obj + _2;
+   |                 ---   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:46:17
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _2 = _0 + _1;
+   |                 -- referenced here
+...
+LL | type _T13 = dyn _2 + Obj;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:49:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+...
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+...
+LL | type _T14 = dyn _1 + _3;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:52:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T15 = dyn _3 + _1;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:55:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+...
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here
+...
+LL | type _T16 = dyn _1 + _4;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:58:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T17 = dyn _4 + _1;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:65:22
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | 
+LL | type _T20 = dyn _5 + _5;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:68:23
+   |
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | type _T21 = dyn Obj + _5;
+   |                 ---   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:71:22
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T22 = dyn _5 + Obj;
+   |                      ^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:74:36
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T23 = dyn _5 + Send + Sync + Obj;
+   |                                    ^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:81:17
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+   |                 -- referenced here
+LL | 
+LL | type _T30 = dyn _6;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:84:17
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+   |                 -- referenced here
+...
+LL | type _T31 = dyn _6 + Send;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:87:24
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+   |                 -- referenced here
+...
+LL | type _T32 = dyn Send + _6;
+   |                        ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:95:22
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T40 = dyn _8 + Obj;
+   |                      ^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:98:23
+   |
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here
+...
+LL | type _T41 = dyn Obj + _8;
+   |                 ---   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:101:22
+   |
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here
+...
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T42 = dyn _8 + _4;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:104:22
+   |
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here
+...
+LL | type _T43 = dyn _4 + _8;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:107:36
+   |
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here
+...
+LL | type _T44 = dyn _4 + Send + Sync + _8;
+   |                                    ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:117:18
+   |
+LL | trait _9 = for<'a> ObjL<'a>;
+   |            ---------------- first non-auto trait
+LL | trait _10 = for<'b> ObjL<'b>;
+   |             ---------------- additional non-auto trait
+LL | type _T50 = _9 + _10;
+   |                  ^^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-duplicates.rs:123:19
+   |
+LL | trait _11 = ObjT<for<'a> fn(&'a u8)>;
+   |             ------------------------ first non-auto trait
+LL | trait _12 = ObjT<for<'b> fn(&'b u8)>;
+   |             ------------------------ additional non-auto trait
+LL | type _T60 = _11 + _12;
+   |                   ^^^
+
+error: aborting due to 27 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs b/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs
new file mode 100644
index 00000000000..54c177f0db8
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs
@@ -0,0 +1,121 @@
+// The purpose of this test is to demonstrate that trait alias expansion
+// preserves the rule that `dyn Trait` may only reference one non-auto trait.
+
+#![feature(trait_alias)]
+
+use std::marker::Unpin;
+
+// Some arbitray object-safe traits:
+trait ObjA {}
+trait ObjB {}
+
+// Nest a few levels deep:
+trait _0 = ObjA;
+trait _1 = _0;
+
+type _T00 = dyn _0 + ObjB;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T01 = dyn ObjB + _0;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T02 = dyn ObjB + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T03 = dyn _1 + ObjB;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more and in weird ways:
+
+trait _2 = ObjB;
+trait _3 = _2;
+trait _4 = _3;
+
+type _T10 = dyn _2 + _3;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T11 = dyn _3 + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T12 = dyn _2 + _4;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T13 = dyn _4 + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Include auto traits:
+
+trait _5 = Sync + ObjB + Send;
+
+type _T20 = dyn _5 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T21 = dyn _1 + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T22 = dyn _5 + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T23 = dyn ObjA + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T24 = dyn Send + _5 + _1 + Sync;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T25 = dyn _1 + Sync + _5 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T26 = dyn Sync + Send + _5 + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T27 = dyn Send + Sync + ObjA + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Also nest:
+
+trait _6 = _1 + _5;
+trait _7 = _6;
+trait _8 = _7;
+
+type _T30 = dyn _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T31 = dyn _6 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T32 = dyn Send + _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T33 = dyn _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T34 = dyn _8 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T35 = dyn Send + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more:
+
+trait _9 = _5 + Sync;
+trait _10 = Unpin + _9;
+
+type _T40 = dyn _10 + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T41 = dyn ObjA + _10;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T42 = dyn _10 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T43 = dyn Send + _10 + Sync + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T44 = dyn ObjA + _10 + Send + Sync;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T45 = dyn Sync + Send + _10 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr b/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr
new file mode 100644
index 00000000000..d73667a0709
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr
@@ -0,0 +1,371 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:16:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | type _T00 = dyn _0 + ObjB;
+   |                      ^^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:19:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+...
+LL | type _T01 = dyn ObjB + _0;
+   |                 ----   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:22:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | type _T02 = dyn ObjB + _1;
+   |                 ----   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:25:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | type _T03 = dyn _1 + ObjB;
+   |                      ^^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:34:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here
+...
+LL | type _T10 = dyn _2 + _3;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:37:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | type _T11 = dyn _3 + _2;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:40:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here
+LL | trait _4 = _3;
+   |            -- referenced here
+...
+LL | type _T12 = dyn _2 + _4;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:43:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | type _T13 = dyn _4 + _2;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:50:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+LL | 
+LL | type _T20 = dyn _5 + _1;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:53:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T21 = dyn _1 + _5;
+   |                      ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:56:22
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T22 = dyn _5 + ObjA;
+   |                      ^^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:59:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T23 = dyn ObjA + _5;
+   |                 ----   ^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:62:29
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T24 = dyn Send + _5 + _1 + Sync;
+   |                             ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:65:29
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T25 = dyn _1 + Sync + _5 + Send;
+   |                             ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:68:36
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T26 = dyn Sync + Send + _5 + ObjA;
+   |                                    ^^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:71:38
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T27 = dyn Send + Sync + ObjA + _5;
+   |                               ----   ^^
+   |                               |
+   |                               first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:80:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |                 -- referenced here
+...
+LL | type _T30 = dyn _6;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:83:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |                 -- referenced here
+...
+LL | type _T31 = dyn _6 + Send;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:86:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |                 -- referenced here
+...
+LL | type _T32 = dyn Send + _6;
+   |                        ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:89:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |                 -- referenced here
+LL | trait _7 = _6;
+   |            -- referenced here
+LL | trait _8 = _7;
+   |            -- referenced here
+...
+LL | type _T33 = dyn _8;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:92:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |                 -- referenced here
+LL | trait _7 = _6;
+   |            -- referenced here
+LL | trait _8 = _7;
+   |            -- referenced here
+...
+LL | type _T34 = dyn _8 + Send;
+   |                 ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:95:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |                 -- referenced here
+LL | trait _7 = _6;
+   |            -- referenced here
+LL | trait _8 = _7;
+   |            -- referenced here
+...
+LL | type _T35 = dyn Send + _8;
+   |                        ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:103:23
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T40 = dyn _10 + ObjA;
+   |                       ^^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:106:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here
+...
+LL | type _T41 = dyn ObjA + _10;
+   |                 ----   ^^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:109:23
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T42 = dyn _10 + _1;
+   |                       ^^
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:112:37
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T43 = dyn Send + _10 + Sync + ObjA;
+   |                                     ^^^^ additional non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:115:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here
+...
+LL | type _T44 = dyn ObjA + _10 + Send + Sync;
+   |                 ----   ^^^
+   |                 |
+   |                 first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/trait-alias-no-extra-traits.rs:118:37
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T45 = dyn Sync + Send + _10 + _1;
+   |                                     ^^
+
+error: aborting due to 28 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-fail.rs b/src/test/ui/traits/trait-alias/trait-alias-object-fail.rs
new file mode 100644
index 00000000000..d62fd7e59c9
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-object-fail.rs
@@ -0,0 +1,11 @@
+#![feature(trait_alias)]
+
+trait EqAlias = Eq;
+trait IteratorAlias = Iterator;
+
+fn main() {
+    let _: &dyn EqAlias = &123;
+    //~^ ERROR the trait `std::cmp::Eq` cannot be made into an object [E0038]
+    let _: &dyn IteratorAlias = &vec![123].into_iter();
+    //~^ ERROR must be specified
+}
diff --git a/src/test/ui/traits/trait-alias-object.stderr b/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr
index 353aea311e9..9a9b9177030 100644
--- a/src/test/ui/traits/trait-alias-object.stderr
+++ b/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr
@@ -1,13 +1,13 @@
-error[E0038]: the trait `EqAlias` cannot be made into an object
-  --> $DIR/trait-alias-object.rs:7:13
+error[E0038]: the trait `std::cmp::Eq` cannot be made into an object
+  --> $DIR/trait-alias-object-fail.rs:7:13
    |
 LL |     let _: &dyn EqAlias = &123;
-   |             ^^^^^^^^^^^ the trait `EqAlias` cannot be made into an object
+   |             ^^^^^^^^^^^ the trait `std::cmp::Eq` cannot be made into an object
    |
    = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses
 
 error[E0191]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) must be specified
-  --> $DIR/trait-alias-object.rs:8:13
+  --> $DIR/trait-alias-object-fail.rs:9:13
    |
 LL |     let _: &dyn IteratorAlias = &vec![123].into_iter();
    |             ^^^^^^^^^^^^^^^^^ associated type `Item` must be specified
diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs b/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs
new file mode 100644
index 00000000000..6383e8b6e10
--- /dev/null
+++ b/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs
@@ -0,0 +1,71 @@
+// run-pass
+
+// This test checks that trait objects involving trait aliases are well-formed.
+
+#![feature(trait_alias)]
+
+trait Obj {}
+
+trait _0 = Send + Sync;
+
+// Just auto traits:
+
+trait _1 = _0 + Send + Sync;
+
+use std::marker::Unpin;
+
+type _T01 = dyn _0;
+type _T02 = dyn _1;
+type _T03 = dyn Unpin + _1 + Send + Sync;
+
+// Include object safe traits:
+
+type _T10 = dyn Obj + _0;
+type _T11 = dyn Obj + _1;
+type _T12 = dyn Obj + _1 + _0;
+
+// And when the object safe trait is in a trait alias:
+
+trait _2 = Obj;
+
+type _T20 = dyn _2 + _0;
+type _T21 = dyn _2 + _1;
+type _T22 = dyn _2 + _1 + _0;
+
+// And it should also work when that trait is has auto traits to the right of it.
+
+trait _3 = Obj + Unpin;
+
+type _T30 = dyn _3 + _0;
+type _T31 = dyn _3 + _1;
+type _T32 = dyn _3 + _1 + _0;
+
+// Nest the trait deeply:
+
+trait _4 = _3;
+trait _5 = _4 + Sync + _0 + Send;
+trait _6 = _5 + Send + _1 + Sync;
+
+type _T60 = dyn _6 + _0;
+type _T61 = dyn _6 + _1;
+type _T62 = dyn _6 + _1 + _0;
+
+// Just nest the trait alone:
+
+trait _7 = _2;
+trait _8 = _7;
+trait _9 = _8;
+
+type _T9 = dyn _9;
+
+// First bound is auto trait:
+
+trait _10 = Send + Obj;
+trait _11 = Obj + Send;
+trait _12 = Sync + _11;
+trait _13 = Send + _12;
+
+type _T70 = dyn _0;
+type _T71 = dyn _3;
+
+fn main() {}
diff --git a/src/test/run-pass/traits/trait-alias-object.rs b/src/test/ui/traits/trait-alias/trait-alias-object.rs
index 1cf9e34edf3..12177cd827f 100644
--- a/src/test/run-pass/traits/trait-alias-object.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-object.rs
@@ -1,3 +1,5 @@
+// run-pass
+
 #![feature(trait_alias)]
 
 trait Foo = PartialEq<i32> + Send;
diff --git a/src/test/ui/traits/trait-alias-syntax.rs b/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.rs
index 5948d45b698..5948d45b698 100644
--- a/src/test/ui/traits/trait-alias-syntax.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.rs
diff --git a/src/test/ui/traits/trait-alias-syntax.stderr b/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.stderr
index f99cc45d8ae..f456a2d778c 100644
--- a/src/test/ui/traits/trait-alias-syntax.stderr
+++ b/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.stderr
@@ -1,11 +1,11 @@
 error: trait aliases cannot be `auto`
-  --> $DIR/trait-alias-syntax.rs:4:19
+  --> $DIR/trait-alias-syntax-fail.rs:4:19
    |
 LL | auto trait A = Foo;
    |                   ^ trait aliases cannot be `auto`
 
 error: trait aliases cannot be `unsafe`
-  --> $DIR/trait-alias-syntax.rs:5:21
+  --> $DIR/trait-alias-syntax-fail.rs:5:21
    |
 LL | unsafe trait B = Foo;
    |                     ^ trait aliases cannot be `unsafe`
diff --git a/src/test/run-pass/traits/trait-alias-syntax.rs b/src/test/ui/traits/trait-alias/trait-alias-syntax.rs
index 7cdd9184d3f..17557a51aa7 100644
--- a/src/test/run-pass/traits/trait-alias-syntax.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-syntax.rs
@@ -1,3 +1,5 @@
+// run-pass
+
 #![feature(trait_alias)]
 
 trait SimpleAlias = Default;
diff --git a/src/test/ui/traits/trait-alias-wf.rs b/src/test/ui/traits/trait-alias/trait-alias-wf.rs
index d10e2abb0e1..d10e2abb0e1 100644
--- a/src/test/ui/traits/trait-alias-wf.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias-wf.rs
diff --git a/src/test/ui/traits/trait-alias-wf.stderr b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr
index ee2dd5b24af..ee2dd5b24af 100644
--- a/src/test/ui/traits/trait-alias-wf.stderr
+++ b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr
diff --git a/src/test/ui/run-pass/traits/trait-alias.rs b/src/test/ui/traits/trait-alias/trait-alias.rs
index 9be5664869e..d8168f2990c 100644
--- a/src/test/ui/run-pass/traits/trait-alias.rs
+++ b/src/test/ui/traits/trait-alias/trait-alias.rs
@@ -1,4 +1,5 @@
 // run-pass
+
 #![feature(trait_alias)]
 
 pub trait Foo {}
diff --git a/src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs b/src/test/ui/traits/traits-static-outlives-a-where-clause.rs
index f0c2c1082b0..f0c2c1082b0 100644
--- a/src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs
+++ b/src/test/ui/traits/traits-static-outlives-a-where-clause.rs
diff --git a/src/test/ui/traits/wf-trait-object-maybe-bound.rs b/src/test/ui/traits/wf-trait-object-maybe-bound.rs
new file mode 100644
index 00000000000..68f0155faf9
--- /dev/null
+++ b/src/test/ui/traits/wf-trait-object-maybe-bound.rs
@@ -0,0 +1,13 @@
+// The purpose of this test is to demonstrate that `?Sized` is allowed in trait objects
+// (thought it has no effect).
+
+type _0 = dyn ?Sized;
+//~^ ERROR at least one non-builtin trait is required for an object type [E0224]
+
+type _1 = dyn Clone + ?Sized;
+
+type _2 = dyn Clone + ?Sized + ?Sized;
+
+type _3 = dyn ?Sized + Clone;
+
+fn main() {}
diff --git a/src/test/ui/traits/wf-trait-object-maybe-bound.stderr b/src/test/ui/traits/wf-trait-object-maybe-bound.stderr
new file mode 100644
index 00000000000..ba24b834211
--- /dev/null
+++ b/src/test/ui/traits/wf-trait-object-maybe-bound.stderr
@@ -0,0 +1,8 @@
+error[E0224]: at least one non-builtin trait is required for an object type
+  --> $DIR/wf-trait-object-maybe-bound.rs:4:11
+   |
+LL | type _0 = dyn ?Sized;
+   |           ^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/traits/wf-trait-object-no-duplicates.rs b/src/test/ui/traits/wf-trait-object-no-duplicates.rs
new file mode 100644
index 00000000000..dd6d73619bc
--- /dev/null
+++ b/src/test/ui/traits/wf-trait-object-no-duplicates.rs
@@ -0,0 +1,33 @@
+// The purpose of this test is to demonstrate that duplicating object safe traits
+// that are not auto-traits is rejected even though one could reasonably accept this.
+
+// Some arbitray object-safe trait:
+trait Obj {}
+
+// Demonstrate that recursive expansion of trait aliases doesn't affect stable behavior:
+type _0 = dyn Obj + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Some variations:
+
+type _1 = dyn Send + Obj + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _2 = dyn Obj + Send + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _3 = dyn Obj + Send + Send; // But it is OK to duplicate auto traits.
+
+// Take higher ranked types into account.
+
+// Note that `'a` and `'b` are intentionally different to make sure we consider
+// them semantically the same.
+trait ObjL<'l> {}
+type _4 = dyn for<'a> ObjL<'a> + for<'b> ObjL<'b>;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+trait ObjT<T> {}
+type _5 = dyn ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)>;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/src/test/ui/traits/wf-trait-object-no-duplicates.stderr b/src/test/ui/traits/wf-trait-object-no-duplicates.stderr
new file mode 100644
index 00000000000..75dacb2e156
--- /dev/null
+++ b/src/test/ui/traits/wf-trait-object-no-duplicates.stderr
@@ -0,0 +1,43 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/wf-trait-object-no-duplicates.rs:8:21
+   |
+LL | type _0 = dyn Obj + Obj;
+   |               ---   ^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/wf-trait-object-no-duplicates.rs:13:28
+   |
+LL | type _1 = dyn Send + Obj + Obj;
+   |                      ---   ^^^ additional non-auto trait
+   |                      |
+   |                      first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/wf-trait-object-no-duplicates.rs:16:28
+   |
+LL | type _2 = dyn Obj + Send + Obj;
+   |               ---          ^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/wf-trait-object-no-duplicates.rs:26:34
+   |
+LL | type _4 = dyn for<'a> ObjL<'a> + for<'b> ObjL<'b>;
+   |               ----------------   ^^^^^^^^^^^^^^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/wf-trait-object-no-duplicates.rs:30:42
+   |
+LL | type _5 = dyn ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)>;
+   |               ------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/wf-trait-object-reverse-order.rs b/src/test/ui/traits/wf-trait-object-reverse-order.rs
new file mode 100644
index 00000000000..f9c584ace5b
--- /dev/null
+++ b/src/test/ui/traits/wf-trait-object-reverse-order.rs
@@ -0,0 +1,15 @@
+// run-pass
+
+// Ensure that `dyn $($AutoTrait) + ObjSafe` is well-formed.
+
+use std::marker::Unpin;
+
+// Some arbitray object-safe trait:
+trait Obj {}
+
+type _0 = Unpin;
+type _1 = Send + Obj;
+type _2 = Send + Unpin + Obj;
+type _3 = Send + Unpin + Sync + Obj;
+
+fn main() {}