about summary refs log tree commit diff
path: root/tests/ui/traits/alias
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/alias')
-rw-r--r--tests/ui/traits/alias/ambiguous.rs24
-rw-r--r--tests/ui/traits/alias/ambiguous.stderr28
-rw-r--r--tests/ui/traits/alias/auxiliary/greeter.rs13
-rw-r--r--tests/ui/traits/alias/auxiliary/send_sync.rs3
-rw-r--r--tests/ui/traits/alias/basic.rs8
-rw-r--r--tests/ui/traits/alias/bounds.rs57
-rw-r--r--tests/ui/traits/alias/cross-crate.rs17
-rw-r--r--tests/ui/traits/alias/cross-crate.stderr31
-rw-r--r--tests/ui/traits/alias/generic-default-in-dyn.rs10
-rw-r--r--tests/ui/traits/alias/generic-default-in-dyn.stderr35
-rw-r--r--tests/ui/traits/alias/impl.rs7
-rw-r--r--tests/ui/traits/alias/impl.stderr9
-rw-r--r--tests/ui/traits/alias/import-cross-crate.rs14
-rw-r--r--tests/ui/traits/alias/import.rs40
-rw-r--r--tests/ui/traits/alias/issue-60021-assoc-method-resolve.rs19
-rw-r--r--tests/ui/traits/alias/issue-72415-assoc-const-resolve.rs14
-rw-r--r--tests/ui/traits/alias/issue-75983.rs17
-rw-r--r--tests/ui/traits/alias/issue-83613.rs12
-rw-r--r--tests/ui/traits/alias/issue-83613.stderr11
-rw-r--r--tests/ui/traits/alias/maybe-bound.rs29
-rw-r--r--tests/ui/traits/alias/no-duplicates.rs126
-rw-r--r--tests/ui/traits/alias/no-duplicates.stderr527
-rw-r--r--tests/ui/traits/alias/no-extra-traits.rs121
-rw-r--r--tests/ui/traits/alias/no-extra-traits.stderr579
-rw-r--r--tests/ui/traits/alias/object-fail.rs11
-rw-r--r--tests/ui/traits/alias/object-fail.stderr21
-rw-r--r--tests/ui/traits/alias/object-wf.rs85
-rw-r--r--tests/ui/traits/alias/object.rs18
-rw-r--r--tests/ui/traits/alias/only-maybe-bound.rs22
-rw-r--r--tests/ui/traits/alias/only-maybe-bound.stderr21
-rw-r--r--tests/ui/traits/alias/self-in-const-generics.rs12
-rw-r--r--tests/ui/traits/alias/self-in-const-generics.stderr11
-rw-r--r--tests/ui/traits/alias/self-in-generics.rs15
-rw-r--r--tests/ui/traits/alias/self-in-generics.stderr11
-rw-r--r--tests/ui/traits/alias/style_lint.rs8
-rw-r--r--tests/ui/traits/alias/style_lint.stderr10
-rw-r--r--tests/ui/traits/alias/suggest-trait-alias-instead-of-type.fixed13
-rw-r--r--tests/ui/traits/alias/suggest-trait-alias-instead-of-type.rs13
-rw-r--r--tests/ui/traits/alias/suggest-trait-alias-instead-of-type.stderr14
-rw-r--r--tests/ui/traits/alias/syntax-fail.rs10
-rw-r--r--tests/ui/traits/alias/syntax-fail.stderr26
-rw-r--r--tests/ui/traits/alias/syntax.rs24
-rw-r--r--tests/ui/traits/alias/wf.rs7
-rw-r--r--tests/ui/traits/alias/wf.stderr19
44 files changed, 2122 insertions, 0 deletions
diff --git a/tests/ui/traits/alias/ambiguous.rs b/tests/ui/traits/alias/ambiguous.rs
new file mode 100644
index 00000000000..28409e0c662
--- /dev/null
+++ b/tests/ui/traits/alias/ambiguous.rs
@@ -0,0 +1,24 @@
+#![feature(trait_alias)]
+
+mod inner {
+    pub trait A { fn foo(&self); }
+    pub trait B { fn foo(&self); }
+
+    impl A for u8 {
+        fn foo(&self) {}
+    }
+    impl B for u8 {
+        fn foo(&self) {}
+    }
+
+    pub trait C = A + B;
+}
+
+use inner::C;
+
+fn main() {
+    let t = 1u8;
+    t.foo(); //~ ERROR E0034
+
+    inner::A::foo(&t); // ok
+}
diff --git a/tests/ui/traits/alias/ambiguous.stderr b/tests/ui/traits/alias/ambiguous.stderr
new file mode 100644
index 00000000000..0fe1a79678d
--- /dev/null
+++ b/tests/ui/traits/alias/ambiguous.stderr
@@ -0,0 +1,28 @@
+error[E0034]: multiple applicable items in scope
+  --> $DIR/ambiguous.rs:21:7
+   |
+LL |     t.foo();
+   |       ^^^ multiple `foo` found
+   |
+note: candidate #1 is defined in an impl of the trait `A` for the type `u8`
+  --> $DIR/ambiguous.rs:8:9
+   |
+LL |         fn foo(&self) {}
+   |         ^^^^^^^^^^^^^
+note: candidate #2 is defined in an impl of the trait `B` for the type `u8`
+  --> $DIR/ambiguous.rs:11:9
+   |
+LL |         fn foo(&self) {}
+   |         ^^^^^^^^^^^^^
+help: disambiguate the associated function for candidate #1
+   |
+LL |     A::foo(&t);
+   |     ~~~~~~~~~~
+help: disambiguate the associated function for candidate #2
+   |
+LL |     B::foo(&t);
+   |     ~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0034`.
diff --git a/tests/ui/traits/alias/auxiliary/greeter.rs b/tests/ui/traits/alias/auxiliary/greeter.rs
new file mode 100644
index 00000000000..9e412215512
--- /dev/null
+++ b/tests/ui/traits/alias/auxiliary/greeter.rs
@@ -0,0 +1,13 @@
+#![feature(trait_alias)]
+
+pub trait Hello {
+    fn hello(&self);
+}
+
+pub struct Hi;
+
+impl Hello for Hi {
+    fn hello(&self) {}
+}
+
+pub trait Greet = Hello;
diff --git a/tests/ui/traits/alias/auxiliary/send_sync.rs b/tests/ui/traits/alias/auxiliary/send_sync.rs
new file mode 100644
index 00000000000..9e56b87e088
--- /dev/null
+++ b/tests/ui/traits/alias/auxiliary/send_sync.rs
@@ -0,0 +1,3 @@
+#![feature(trait_alias)]
+
+pub trait SendSync = Send + Sync;
diff --git a/tests/ui/traits/alias/basic.rs b/tests/ui/traits/alias/basic.rs
new file mode 100644
index 00000000000..d8168f2990c
--- /dev/null
+++ b/tests/ui/traits/alias/basic.rs
@@ -0,0 +1,8 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+pub trait Foo {}
+pub trait FooAlias = Foo;
+
+fn main() {}
diff --git a/tests/ui/traits/alias/bounds.rs b/tests/ui/traits/alias/bounds.rs
new file mode 100644
index 00000000000..b97eb38c5af
--- /dev/null
+++ b/tests/ui/traits/alias/bounds.rs
@@ -0,0 +1,57 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+use std::marker::PhantomData;
+
+trait Empty {}
+trait EmptyAlias = Empty;
+trait CloneDefault = Clone + Default;
+trait SendSyncAlias = Send + Sync;
+trait WhereSendAlias = where Self: Send;
+trait SendEqAlias<T> = Send where T: PartialEq<Self>;
+trait I32Iterator = Iterator<Item = i32>;
+
+#[allow(dead_code)]
+struct Foo<T: SendSyncAlias>(PhantomData<T>);
+#[allow(dead_code)]
+struct Bar<T>(PhantomData<T>) where T: SendSyncAlias;
+
+impl dyn EmptyAlias {}
+
+impl<T: SendSyncAlias> Empty for T {}
+
+fn a<T: CloneDefault>() -> (T, T) {
+    let one = T::default();
+    let two = one.clone();
+    (one, two)
+}
+
+fn b(x: &impl SendEqAlias<i32>) -> bool {
+    22_i32 == *x
+}
+
+fn c<T: I32Iterator>(x: &mut T) -> Option<i32> {
+    x.next()
+}
+
+fn d<T: SendSyncAlias>() {
+    is_send_and_sync::<T>();
+}
+
+fn is_send_and_sync<T: Send + Sync>() {}
+
+fn main() {
+    let both = a::<i32>();
+    assert_eq!(both.0, 0);
+    assert_eq!(both.1, 0);
+    let both: (i32, i32) = a();
+    assert_eq!(both.0, 0);
+    assert_eq!(both.1, 0);
+
+    assert!(b(&22));
+
+    assert_eq!(c(&mut vec![22].into_iter()), Some(22));
+
+    d::<i32>();
+}
diff --git a/tests/ui/traits/alias/cross-crate.rs b/tests/ui/traits/alias/cross-crate.rs
new file mode 100644
index 00000000000..8919c643400
--- /dev/null
+++ b/tests/ui/traits/alias/cross-crate.rs
@@ -0,0 +1,17 @@
+// aux-build:send_sync.rs
+
+#![feature(trait_alias)]
+
+extern crate send_sync;
+
+use std::rc::Rc;
+use send_sync::SendSync;
+
+fn use_alias<T: SendSync>() {}
+
+fn main() {
+    use_alias::<u32>();
+    use_alias::<Rc<u32>>();
+    //~^ ERROR `Rc<u32>` cannot be sent between threads safely [E0277]
+    //~^^ ERROR `Rc<u32>` cannot be shared between threads safely [E0277]
+}
diff --git a/tests/ui/traits/alias/cross-crate.stderr b/tests/ui/traits/alias/cross-crate.stderr
new file mode 100644
index 00000000000..ae9d7d0a9b4
--- /dev/null
+++ b/tests/ui/traits/alias/cross-crate.stderr
@@ -0,0 +1,31 @@
+error[E0277]: `Rc<u32>` cannot be sent between threads safely
+  --> $DIR/cross-crate.rs:14:17
+   |
+LL |     use_alias::<Rc<u32>>();
+   |                 ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
+   |
+   = help: the trait `Send` is not implemented for `Rc<u32>`
+   = note: required for `Rc<u32>` to implement `SendSync`
+note: required by a bound in `use_alias`
+  --> $DIR/cross-crate.rs:10:17
+   |
+LL | fn use_alias<T: SendSync>() {}
+   |                 ^^^^^^^^ required by this bound in `use_alias`
+
+error[E0277]: `Rc<u32>` cannot be shared between threads safely
+  --> $DIR/cross-crate.rs:14:17
+   |
+LL |     use_alias::<Rc<u32>>();
+   |                 ^^^^^^^ `Rc<u32>` cannot be shared between threads safely
+   |
+   = help: the trait `Sync` is not implemented for `Rc<u32>`
+   = note: required for `Rc<u32>` to implement `SendSync`
+note: required by a bound in `use_alias`
+  --> $DIR/cross-crate.rs:10:17
+   |
+LL | fn use_alias<T: SendSync>() {}
+   |                 ^^^^^^^^ required by this bound in `use_alias`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/alias/generic-default-in-dyn.rs b/tests/ui/traits/alias/generic-default-in-dyn.rs
new file mode 100644
index 00000000000..d44e1c2a975
--- /dev/null
+++ b/tests/ui/traits/alias/generic-default-in-dyn.rs
@@ -0,0 +1,10 @@
+trait SendEqAlias<T> = PartialEq;
+//~^ ERROR trait aliases are experimental
+
+struct Foo<T>(dyn SendEqAlias<T>);
+//~^ ERROR the type parameter `Rhs` must be explicitly specified [E0393]
+
+struct Bar<T>(dyn SendEqAlias<T>, T);
+//~^ ERROR the type parameter `Rhs` must be explicitly specified [E0393]
+
+fn main() {}
diff --git a/tests/ui/traits/alias/generic-default-in-dyn.stderr b/tests/ui/traits/alias/generic-default-in-dyn.stderr
new file mode 100644
index 00000000000..0d3f794aa0f
--- /dev/null
+++ b/tests/ui/traits/alias/generic-default-in-dyn.stderr
@@ -0,0 +1,35 @@
+error[E0658]: trait aliases are experimental
+  --> $DIR/generic-default-in-dyn.rs:1:1
+   |
+LL | trait SendEqAlias<T> = PartialEq;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
+   = help: add `#![feature(trait_alias)]` to the crate attributes to enable
+
+error[E0393]: the type parameter `Rhs` must be explicitly specified
+  --> $DIR/generic-default-in-dyn.rs:4:19
+   |
+LL | struct Foo<T>(dyn SendEqAlias<T>);
+   |                   ^^^^^^^^^^^^^^ missing reference to `Rhs`
+  --> $SRC_DIR/core/src/cmp.rs:LL:COL
+   |
+   = note: type parameter `Rhs` must be specified for this
+   |
+   = 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/generic-default-in-dyn.rs:7:19
+   |
+LL | struct Bar<T>(dyn SendEqAlias<T>, T);
+   |                   ^^^^^^^^^^^^^^ missing reference to `Rhs`
+  --> $SRC_DIR/core/src/cmp.rs:LL:COL
+   |
+   = note: type parameter `Rhs` must be specified for this
+   |
+   = note: because of the default `Self` reference, type parameters must be specified on object types
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0393, E0658.
+For more information about an error, try `rustc --explain E0393`.
diff --git a/tests/ui/traits/alias/impl.rs b/tests/ui/traits/alias/impl.rs
new file mode 100644
index 00000000000..6e35793a066
--- /dev/null
+++ b/tests/ui/traits/alias/impl.rs
@@ -0,0 +1,7 @@
+#![feature(trait_alias)]
+
+trait DefaultAlias = Default;
+
+impl DefaultAlias for () {} //~ ERROR expected trait, found trait alias
+
+fn main() {}
diff --git a/tests/ui/traits/alias/impl.stderr b/tests/ui/traits/alias/impl.stderr
new file mode 100644
index 00000000000..cedcd10213d
--- /dev/null
+++ b/tests/ui/traits/alias/impl.stderr
@@ -0,0 +1,9 @@
+error[E0404]: expected trait, found trait alias `DefaultAlias`
+  --> $DIR/impl.rs:5:6
+   |
+LL | impl DefaultAlias for () {}
+   |      ^^^^^^^^^^^^ not a trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/tests/ui/traits/alias/import-cross-crate.rs b/tests/ui/traits/alias/import-cross-crate.rs
new file mode 100644
index 00000000000..868585cd097
--- /dev/null
+++ b/tests/ui/traits/alias/import-cross-crate.rs
@@ -0,0 +1,14 @@
+// run-pass
+// aux-build:greeter.rs
+
+#![feature(trait_alias)]
+
+extern crate greeter;
+
+// Import only the alias, not the real trait.
+use greeter::{Greet, Hi};
+
+fn main() {
+    let hi = Hi;
+    hi.hello(); // From `Hello`, via `Greet` alias.
+}
diff --git a/tests/ui/traits/alias/import.rs b/tests/ui/traits/alias/import.rs
new file mode 100644
index 00000000000..802a8f15698
--- /dev/null
+++ b/tests/ui/traits/alias/import.rs
@@ -0,0 +1,40 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+mod inner {
+    pub trait Foo {
+        fn foo(&self);
+    }
+
+    pub struct Qux;
+
+    impl Foo for Qux {
+        fn foo(&self) {}
+    }
+
+    pub trait Bar = Foo;
+}
+
+mod two {
+    pub trait A {
+        fn foo();
+    }
+
+    impl A for u8 {
+        fn foo() {}
+    }
+}
+
+// Import only the alias, not the `Foo` trait.
+use inner::{Bar, Qux};
+
+// Declaring an alias also brings in aliased methods.
+trait Two = two::A;
+
+fn main() {
+    let q = Qux;
+    q.foo(); // From Bar.
+
+    u8::foo(); // From A.
+}
diff --git a/tests/ui/traits/alias/issue-60021-assoc-method-resolve.rs b/tests/ui/traits/alias/issue-60021-assoc-method-resolve.rs
new file mode 100644
index 00000000000..5e27ed3c646
--- /dev/null
+++ b/tests/ui/traits/alias/issue-60021-assoc-method-resolve.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+trait SomeTrait {
+    fn map(&self) {}
+}
+
+impl<T> SomeTrait for Option<T> {}
+
+trait SomeAlias = SomeTrait;
+
+fn main() {
+    let x = Some(123);
+    // This should resolve to the trait impl for Option
+    Option::map(x, |z| z);
+    // This should resolve to the trait impl for SomeTrait
+    SomeTrait::map(&x);
+}
diff --git a/tests/ui/traits/alias/issue-72415-assoc-const-resolve.rs b/tests/ui/traits/alias/issue-72415-assoc-const-resolve.rs
new file mode 100644
index 00000000000..e49125d1024
--- /dev/null
+++ b/tests/ui/traits/alias/issue-72415-assoc-const-resolve.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+trait Bounded { const MAX: Self; }
+
+impl Bounded for u32 {
+    // This should correctly resolve to the associated const in the inherent impl of u32.
+    const MAX: Self = u32::MAX;
+}
+
+trait Num = Bounded + Copy;
+
+fn main() {}
diff --git a/tests/ui/traits/alias/issue-75983.rs b/tests/ui/traits/alias/issue-75983.rs
new file mode 100644
index 00000000000..f9a7f36de43
--- /dev/null
+++ b/tests/ui/traits/alias/issue-75983.rs
@@ -0,0 +1,17 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+struct Bar;
+trait Foo {}
+impl Foo for Bar {}
+
+trait Baz = Foo where Bar: Foo;
+
+fn new() -> impl Baz {
+    Bar
+}
+
+fn main() {
+    let _ = new();
+}
diff --git a/tests/ui/traits/alias/issue-83613.rs b/tests/ui/traits/alias/issue-83613.rs
new file mode 100644
index 00000000000..2462e703a71
--- /dev/null
+++ b/tests/ui/traits/alias/issue-83613.rs
@@ -0,0 +1,12 @@
+#![feature(type_alias_impl_trait)]
+trait OpaqueTrait {}
+impl<T> OpaqueTrait for T {}
+type OpaqueType = impl OpaqueTrait;
+fn mk_opaque() -> OpaqueType {
+    || 0
+}
+trait AnotherTrait {}
+impl<T: Send> AnotherTrait for T {}
+impl AnotherTrait for OpaqueType {}
+//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
+fn main() {}
diff --git a/tests/ui/traits/alias/issue-83613.stderr b/tests/ui/traits/alias/issue-83613.stderr
new file mode 100644
index 00000000000..a78294da6c1
--- /dev/null
+++ b/tests/ui/traits/alias/issue-83613.stderr
@@ -0,0 +1,11 @@
+error[E0119]: conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
+  --> $DIR/issue-83613.rs:10:1
+   |
+LL | impl<T: Send> AnotherTrait for T {}
+   | -------------------------------- first implementation here
+LL | impl AnotherTrait for OpaqueType {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/traits/alias/maybe-bound.rs b/tests/ui/traits/alias/maybe-bound.rs
new file mode 100644
index 00000000000..284baa48149
--- /dev/null
+++ b/tests/ui/traits/alias/maybe-bound.rs
@@ -0,0 +1,29 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+// Test that `dyn ... + ?Sized + ...` resulting from the expansion of trait aliases is okay.
+
+#![feature(trait_alias)]
+
+trait Foo {}
+
+trait S = ?Sized;
+
+// Nest a couple of levels deep:
+trait _0 = S;
+trait _1 = _0;
+
+// Straight list expansion:
+type _T0 = dyn _1 + Foo;
+
+// In second position:
+type _T1 = dyn Foo + _1;
+
+// ... and with an auto trait:
+type _T2 = dyn Foo + Send + _1;
+
+// Twice:
+trait _2 = _1 + _1;
+
+type _T3 = dyn _2 + Foo;
+
+fn main() {}
diff --git a/tests/ui/traits/alias/no-duplicates.rs b/tests/ui/traits/alias/no-duplicates.rs
new file mode 100644
index 00000000000..88feb89170d
--- /dev/null
+++ b/tests/ui/traits/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 arbitrary 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 = dyn _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 = dyn _11 + _12;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/tests/ui/traits/alias/no-duplicates.stderr b/tests/ui/traits/alias/no-duplicates.stderr
new file mode 100644
index 00000000000..bf244b97e9b
--- /dev/null
+++ b/tests/ui/traits/alias/no-duplicates.stderr
@@ -0,0 +1,527 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:16:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | type _T00 = dyn _0 + _0;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:19:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | type _T01 = dyn _1 + _0;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:22:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T02 = dyn _1 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:25:23
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | type _T03 = dyn Obj + _1;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:28:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | type _T04 = dyn _1 + Obj;
+   |                 --   ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:37:17
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _2 = _0 + _1;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T10 = dyn _2 + _3;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:40:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+...
+LL | trait _2 = _0 + _1;
+   |            -- referenced here (additional use)
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T11 = dyn _3 + _2;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:43:23
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+...
+LL | trait _2 = _0 + _1;
+   |            -- referenced here (additional use)
+...
+LL | type _T12 = dyn Obj + _2;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:46:17
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _2 = _0 + _1;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T13 = dyn _2 + Obj;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:49:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+...
+LL | type _T14 = dyn _1 + _3;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:52:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T15 = dyn _3 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:55:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (additional use)
+...
+LL | type _T16 = dyn _1 + _4;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:58:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | type _T17 = dyn _4 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:68:23
+   |
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | type _T21 = dyn Obj + _5;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:71:22
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T22 = dyn _5 + Obj;
+   |                 --   ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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 (additional use)
+   |            |
+   |            referenced here (first use)
+LL |
+LL | type _T30 = dyn _6;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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 (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T31 = dyn _6 + Send;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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 (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T32 = dyn Send + _6;
+   |                        ^^
+   |                        |
+   |                        trait alias used in trait object type (additional use)
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:95:22
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (first use)
+LL |
+LL | type _T40 = dyn _8 + Obj;
+   |                 --   ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:98:23
+   |
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (additional use)
+...
+LL | type _T41 = dyn Obj + _8;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:101:22
+   |
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (first use)
+...
+LL | type _T42 = dyn _8 + _4;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:104:22
+   |
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (additional use)
+...
+LL | type _T43 = dyn _4 + _8;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:107:36
+   |
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (additional use)
+...
+LL | type _T44 = dyn _4 + Send + Sync + _8;
+   |                 --                 ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:117:22
+   |
+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 = dyn _9 + _10;
+   |                 --   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: for<'a> ObjL<'a> + for<'b> ObjL<'b> {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:123:23
+   |
+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 = dyn _11 + _12;
+   |                 ---   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)> {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error: aborting due to 27 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/tests/ui/traits/alias/no-extra-traits.rs b/tests/ui/traits/alias/no-extra-traits.rs
new file mode 100644
index 00000000000..4dad8c0f873
--- /dev/null
+++ b/tests/ui/traits/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 arbitrary 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/tests/ui/traits/alias/no-extra-traits.stderr b/tests/ui/traits/alias/no-extra-traits.stderr
new file mode 100644
index 00000000000..4b1ddf6843c
--- /dev/null
+++ b/tests/ui/traits/alias/no-extra-traits.stderr
@@ -0,0 +1,579 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:16:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | type _T00 = dyn _0 + ObjB;
+   |                 --   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:19:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+...
+LL | type _T01 = dyn ObjB + _0;
+   |                 ----   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:22:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | type _T02 = dyn ObjB + _1;
+   |                 ----   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:25:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | type _T03 = dyn _1 + ObjB;
+   |                 --   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:34:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (additional use)
+...
+LL | type _T10 = dyn _2 + _3;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:37:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (first use)
+...
+LL | type _T11 = dyn _3 + _2;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:40:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (additional use)
+LL | trait _4 = _3;
+   |            -- referenced here (additional use)
+...
+LL | type _T12 = dyn _2 + _4;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:43:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (first use)
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | type _T13 = dyn _4 + _2;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:50:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+LL |
+LL | type _T20 = dyn _5 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:53:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T21 = dyn _1 + _5;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:59:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T23 = dyn ObjA + _5;
+   |                 ----   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:62:29
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T24 = dyn Send + _5 + _1 + Sync;
+   |                        --   ^^ trait alias used in trait object type (additional use)
+   |                        |
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:65:29
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T25 = dyn _1 + Sync + _5 + Send;
+   |                 --          ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/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
+   |                               |
+   |                               trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:71:38
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T27 = dyn Send + Sync + ObjA + _5;
+   |                               ----   ^^ trait alias used in trait object type (additional use)
+   |                               |
+   |                               first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:80:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T30 = dyn _6;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:83:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T31 = dyn _6 + Send;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:86:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T32 = dyn Send + _6;
+   |                        ^^
+   |                        |
+   |                        trait alias used in trait object type (additional use)
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:89:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | trait _7 = _6;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+LL | trait _8 = _7;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T33 = dyn _8;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:92:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | trait _7 = _6;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+LL | trait _8 = _7;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T34 = dyn _8 + Send;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:95:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | trait _7 = _6;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+LL | trait _8 = _7;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T35 = dyn Send + _8;
+   |                        ^^
+   |                        |
+   |                        trait alias used in trait object type (additional use)
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:103:23
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+LL |
+LL | type _T40 = dyn _10 + ObjA;
+   |                 ---   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:106:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (additional use)
+...
+LL | type _T41 = dyn ObjA + _10;
+   |                 ----   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:109:23
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+...
+LL | type _T42 = dyn _10 + _1;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:112:37
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+...
+LL | type _T43 = dyn Send + _10 + Sync + ObjA;
+   |                        ---          ^^^^ additional non-auto trait
+   |                        |
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:115:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (additional use)
+...
+LL | type _T44 = dyn ObjA + _10 + Send + Sync;
+   |                 ----   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:118:37
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+...
+LL | type _T45 = dyn Sync + Send + _10 + _1;
+   |                               ---   ^^ trait alias used in trait object type (additional use)
+   |                               |
+   |                               trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error: aborting due to 28 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/tests/ui/traits/alias/object-fail.rs b/tests/ui/traits/alias/object-fail.rs
new file mode 100644
index 00000000000..5c753ff207c
--- /dev/null
+++ b/tests/ui/traits/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 `Eq` cannot be made into an object [E0038]
+    let _: &dyn IteratorAlias = &vec![123].into_iter();
+    //~^ ERROR must be specified
+}
diff --git a/tests/ui/traits/alias/object-fail.stderr b/tests/ui/traits/alias/object-fail.stderr
new file mode 100644
index 00000000000..048a150df8c
--- /dev/null
+++ b/tests/ui/traits/alias/object-fail.stderr
@@ -0,0 +1,21 @@
+error[E0038]: the trait `Eq` cannot be made into an object
+  --> $DIR/object-fail.rs:7:13
+   |
+LL |     let _: &dyn EqAlias = &123;
+   |             ^^^^^^^^^^^ `Eq` cannot be made into an object
+   |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $SRC_DIR/core/src/cmp.rs:LL:COL
+   |
+   = note: the trait cannot be made into an object because it uses `Self` as a type parameter
+
+error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified
+  --> $DIR/object-fail.rs:9:17
+   |
+LL |     let _: &dyn IteratorAlias = &vec![123].into_iter();
+   |                 ^^^^^^^^^^^^^ help: specify the associated type: `IteratorAlias<Item = Type>`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0038, E0191.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/tests/ui/traits/alias/object-wf.rs b/tests/ui/traits/alias/object-wf.rs
new file mode 100644
index 00000000000..1440f02df1d
--- /dev/null
+++ b/tests/ui/traits/alias/object-wf.rs
@@ -0,0 +1,85 @@
+// check-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;
+
+fn _f0() {
+    let _: Box<dyn _0>;
+    let _: Box<dyn _1>;
+    let _: Box<dyn Unpin + _1 + Send + Sync>;
+}
+
+// Include object safe traits:
+
+fn _f1() {
+    let _: Box<dyn Obj + _0>;
+    let _: Box<dyn Obj + _1>;
+    let _: Box<dyn Obj + _1 + _0>;
+}
+
+// And when the object safe trait is in a trait alias:
+
+trait _2 = Obj;
+
+fn _f2() {
+    let _: Box<dyn _2 + _0>;
+    let _: Box<dyn _2 + _1>;
+    let _: Box<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;
+
+fn _f3() {
+    let _: Box<dyn _3 + _0>;
+    let _: Box<dyn _3 + _1>;
+    let _: Box<dyn _3 + _1 + _0>;
+}
+
+// Nest the trait deeply:
+
+trait _4 = _3;
+trait _5 = _4 + Sync + _0 + Send;
+trait _6 = _5 + Send + _1 + Sync;
+
+fn _f4() {
+    let _: Box<dyn _6 + _0>;
+    let _: Box<dyn _6 + _1>;
+    let _: Box<dyn _6 + _1 + _0>;
+}
+
+// Just nest the trait alone:
+
+trait _7 = _2;
+trait _8 = _7;
+trait _9 = _8;
+
+fn _f5() {
+    let _: Box<dyn _9>;
+}
+
+// First bound is auto trait:
+
+trait _10 = Send + Obj;
+trait _11 = Obj + Send;
+trait _12 = Sync + _11;
+trait _13 = Send + _12;
+
+fn f6() {
+    let _: Box<dyn _10>;
+    let _: Box<dyn _13>;
+}
+
+fn main() {}
diff --git a/tests/ui/traits/alias/object.rs b/tests/ui/traits/alias/object.rs
new file mode 100644
index 00000000000..12177cd827f
--- /dev/null
+++ b/tests/ui/traits/alias/object.rs
@@ -0,0 +1,18 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+trait Foo = PartialEq<i32> + Send;
+trait Bar = Foo + Sync;
+
+trait I32Iterator = Iterator<Item = i32>;
+
+pub fn main() {
+    let a: &dyn Bar = &123;
+    assert!(*a == 123);
+    let b = Box::new(456) as Box<dyn Foo>;
+    assert!(*b == 456);
+
+    let c: &mut dyn I32Iterator = &mut vec![123].into_iter();
+    assert_eq!(c.next(), Some(123));
+}
diff --git a/tests/ui/traits/alias/only-maybe-bound.rs b/tests/ui/traits/alias/only-maybe-bound.rs
new file mode 100644
index 00000000000..e4abf314e0a
--- /dev/null
+++ b/tests/ui/traits/alias/only-maybe-bound.rs
@@ -0,0 +1,22 @@
+// Test that `dyn ?Sized` (i.e., a trait object with only a maybe buond) is not allowed, when just
+// `?Sized` results from trait alias expansion.
+
+#![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 trait is required for an object type [E0224]
+
+// Twice:
+trait _2 = _1 + _1;
+
+type _T1 = dyn _2;
+//~^ ERROR at least one trait is required for an object type [E0224]
+
+fn main() {}
diff --git a/tests/ui/traits/alias/only-maybe-bound.stderr b/tests/ui/traits/alias/only-maybe-bound.stderr
new file mode 100644
index 00000000000..175ec8120ec
--- /dev/null
+++ b/tests/ui/traits/alias/only-maybe-bound.stderr
@@ -0,0 +1,21 @@
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/only-maybe-bound.rs:13:12
+   |
+LL | trait _1 = _0;
+   | -------- this alias does not contain a trait
+...
+LL | type _T0 = dyn _1;
+   |            ^^^^^^
+
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/only-maybe-bound.rs:19:12
+   |
+LL | trait _2 = _1 + _1;
+   | -------- this alias does not contain a trait
+LL |
+LL | type _T1 = dyn _2;
+   |            ^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0224`.
diff --git a/tests/ui/traits/alias/self-in-const-generics.rs b/tests/ui/traits/alias/self-in-const-generics.rs
new file mode 100644
index 00000000000..b0de8ccd678
--- /dev/null
+++ b/tests/ui/traits/alias/self-in-const-generics.rs
@@ -0,0 +1,12 @@
+#![allow(incomplete_features)]
+#![feature(generic_const_exprs)]
+#![feature(trait_alias)]
+
+trait Bar<const N: usize> {}
+
+trait BB = Bar<{ 2 + 1 }>;
+
+fn foo(x: &dyn BB) {}
+//~^ ERROR the trait alias `BB` cannot be made into an object [E0038]
+
+fn main() {}
diff --git a/tests/ui/traits/alias/self-in-const-generics.stderr b/tests/ui/traits/alias/self-in-const-generics.stderr
new file mode 100644
index 00000000000..61cc217cfbc
--- /dev/null
+++ b/tests/ui/traits/alias/self-in-const-generics.stderr
@@ -0,0 +1,11 @@
+error[E0038]: the trait alias `BB` cannot be made into an object
+  --> $DIR/self-in-const-generics.rs:9:16
+   |
+LL | fn foo(x: &dyn BB) {}
+   |                ^^
+   |
+   = note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/traits/alias/self-in-generics.rs b/tests/ui/traits/alias/self-in-generics.rs
new file mode 100644
index 00000000000..0bb6335f91e
--- /dev/null
+++ b/tests/ui/traits/alias/self-in-generics.rs
@@ -0,0 +1,15 @@
+// astconv uses `FreshTy(0)` as a dummy `Self` type when instanciating trait objects.
+// This `FreshTy(0)` can leak into substs, causing ICEs in several places.
+// Using `save-analysis` triggers type-checking `f` that would be normally skipped
+// as `type_of` emitted an error.
+//
+// compile-flags: -Zsave-analysis
+
+#![feature(trait_alias)]
+
+pub trait SelfInput = Fn(&mut Self);
+
+pub fn f(_f: &dyn SelfInput) {}
+//~^ ERROR the trait alias `SelfInput` cannot be made into an object [E0038]
+
+fn main() {}
diff --git a/tests/ui/traits/alias/self-in-generics.stderr b/tests/ui/traits/alias/self-in-generics.stderr
new file mode 100644
index 00000000000..110d60e6e91
--- /dev/null
+++ b/tests/ui/traits/alias/self-in-generics.stderr
@@ -0,0 +1,11 @@
+error[E0038]: the trait alias `SelfInput` cannot be made into an object
+  --> $DIR/self-in-generics.rs:12:19
+   |
+LL | pub fn f(_f: &dyn SelfInput) {}
+   |                   ^^^^^^^^^
+   |
+   = note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/traits/alias/style_lint.rs b/tests/ui/traits/alias/style_lint.rs
new file mode 100644
index 00000000000..33be20054b5
--- /dev/null
+++ b/tests/ui/traits/alias/style_lint.rs
@@ -0,0 +1,8 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+trait Foo = std::fmt::Display + std::fmt::Debug;
+trait bar = std::fmt::Display + std::fmt::Debug; //~WARN trait alias `bar` should have an upper camel case name
+
+fn main() {}
diff --git a/tests/ui/traits/alias/style_lint.stderr b/tests/ui/traits/alias/style_lint.stderr
new file mode 100644
index 00000000000..91e2ea90eb9
--- /dev/null
+++ b/tests/ui/traits/alias/style_lint.stderr
@@ -0,0 +1,10 @@
+warning: trait alias `bar` should have an upper camel case name
+  --> $DIR/style_lint.rs:6:7
+   |
+LL | trait bar = std::fmt::Display + std::fmt::Debug;
+   |       ^^^ help: convert the identifier to upper camel case: `Bar`
+   |
+   = note: `#[warn(non_camel_case_types)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.fixed b/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.fixed
new file mode 100644
index 00000000000..8a94abaeb07
--- /dev/null
+++ b/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.fixed
@@ -0,0 +1,13 @@
+// Regression test of #43913.
+
+// run-rustfix
+
+#![feature(trait_alias)]
+#![allow(bare_trait_objects, dead_code)]
+
+trait Strings = Iterator<Item=String>;
+
+struct Struct<S: Strings>(S);
+//~^ ERROR: expected trait, found type alias `Strings`
+
+fn main() {}
diff --git a/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.rs b/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.rs
new file mode 100644
index 00000000000..40c678c281f
--- /dev/null
+++ b/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.rs
@@ -0,0 +1,13 @@
+// Regression test of #43913.
+
+// run-rustfix
+
+#![feature(trait_alias)]
+#![allow(bare_trait_objects, dead_code)]
+
+type Strings = Iterator<Item=String>;
+
+struct Struct<S: Strings>(S);
+//~^ ERROR: expected trait, found type alias `Strings`
+
+fn main() {}
diff --git a/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.stderr b/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.stderr
new file mode 100644
index 00000000000..6e03eeada49
--- /dev/null
+++ b/tests/ui/traits/alias/suggest-trait-alias-instead-of-type.stderr
@@ -0,0 +1,14 @@
+error[E0404]: expected trait, found type alias `Strings`
+  --> $DIR/suggest-trait-alias-instead-of-type.rs:10:18
+   |
+LL | struct Struct<S: Strings>(S);
+   |                  ^^^^^^^ type aliases cannot be used as traits
+   |
+help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias
+   |
+LL | trait Strings = Iterator<Item=String>;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/tests/ui/traits/alias/syntax-fail.rs b/tests/ui/traits/alias/syntax-fail.rs
new file mode 100644
index 00000000000..039bbce8c1e
--- /dev/null
+++ b/tests/ui/traits/alias/syntax-fail.rs
@@ -0,0 +1,10 @@
+#![feature(trait_alias)]
+
+trait Foo {}
+auto trait A = Foo; //~ ERROR trait aliases cannot be `auto`
+unsafe trait B = Foo; //~ ERROR trait aliases cannot be `unsafe`
+
+trait C: Ord = Eq; //~ ERROR bounds are not allowed on trait aliases
+trait D: = Eq; //~ ERROR bounds are not allowed on trait aliases
+
+fn main() {}
diff --git a/tests/ui/traits/alias/syntax-fail.stderr b/tests/ui/traits/alias/syntax-fail.stderr
new file mode 100644
index 00000000000..748b92056d1
--- /dev/null
+++ b/tests/ui/traits/alias/syntax-fail.stderr
@@ -0,0 +1,26 @@
+error: trait aliases cannot be `auto`
+  --> $DIR/syntax-fail.rs:4:1
+   |
+LL | auto trait A = Foo;
+   | ^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto`
+
+error: trait aliases cannot be `unsafe`
+  --> $DIR/syntax-fail.rs:5:1
+   |
+LL | unsafe trait B = Foo;
+   | ^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe`
+
+error: bounds are not allowed on trait aliases
+  --> $DIR/syntax-fail.rs:7:8
+   |
+LL | trait C: Ord = Eq;
+   |        ^^^^^
+
+error: bounds are not allowed on trait aliases
+  --> $DIR/syntax-fail.rs:8:8
+   |
+LL | trait D: = Eq;
+   |        ^
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/traits/alias/syntax.rs b/tests/ui/traits/alias/syntax.rs
new file mode 100644
index 00000000000..17557a51aa7
--- /dev/null
+++ b/tests/ui/traits/alias/syntax.rs
@@ -0,0 +1,24 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+trait SimpleAlias = Default;
+trait GenericAlias<T> = Iterator<Item = T>;
+trait Partial<T> = IntoIterator<Item = T>;
+trait SpecificAlias = GenericAlias<i32>;
+trait PartialEqRef<'a, T: 'a> = PartialEq<&'a T>;
+trait StaticAlias = 'static;
+
+trait Things<T> {}
+trait Romeo {}
+#[allow(dead_code)]
+struct The<T>(T);
+#[allow(dead_code)]
+struct Fore<T>(T);
+impl<T, U> Things<T> for The<U> {}
+impl<T> Romeo for Fore<T> {}
+
+trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo;
+trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>;
+
+fn main() {}
diff --git a/tests/ui/traits/alias/wf.rs b/tests/ui/traits/alias/wf.rs
new file mode 100644
index 00000000000..d10e2abb0e1
--- /dev/null
+++ b/tests/ui/traits/alias/wf.rs
@@ -0,0 +1,7 @@
+#![feature(trait_alias)]
+
+trait Foo {}
+trait A<T: Foo> {}
+trait B<T> = A<T>; //~ ERROR `T: Foo` is not satisfied
+
+fn main() {}
diff --git a/tests/ui/traits/alias/wf.stderr b/tests/ui/traits/alias/wf.stderr
new file mode 100644
index 00000000000..7172008d3ee
--- /dev/null
+++ b/tests/ui/traits/alias/wf.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/wf.rs:5:14
+   |
+LL | trait B<T> = A<T>;
+   |              ^^^^ the trait `Foo` is not implemented for `T`
+   |
+note: required by a bound in `A`
+  --> $DIR/wf.rs:4:12
+   |
+LL | trait A<T: Foo> {}
+   |            ^^^ required by this bound in `A`
+help: consider restricting type parameter `T`
+   |
+LL | trait B<T: Foo> = A<T>;
+   |          +++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.