about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2019-06-13 21:36:15 +0200
committerJonas Schievink <jonasschievink@gmail.com>2020-02-21 19:41:21 +0100
commita323ff2c864801fdc8e044e88f11efb49a565ed1 (patch)
treeb9de022262d7a61c7c233f80595a1e978dc3d658 /src/test
parent187f3d73abf35404b12782993d6e8880e866d6d1 (diff)
downloadrust-a323ff2c864801fdc8e044e88f11efb49a565ed1.tar.gz
rust-a323ff2c864801fdc8e044e88f11efb49a565ed1.zip
Implement RFC 2532 – Associated Type Defaults
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/associated-types/associated-types-overridden-default.rs6
-rw-r--r--src/test/ui/associated-types/associated-types-overridden-default.stderr9
-rw-r--r--src/test/ui/associated-types/defaults-cyclic-fail.rs35
-rw-r--r--src/test/ui/associated-types/defaults-cyclic-fail.stderr21
-rw-r--r--src/test/ui/associated-types/defaults-cyclic-pass.rs22
-rw-r--r--src/test/ui/associated-types/defaults-in-other-trait-items.rs50
-rw-r--r--src/test/ui/associated-types/defaults-in-other-trait-items.stderr25
-rw-r--r--src/test/ui/privacy/associated-item-privacy-trait.rs9
-rw-r--r--src/test/ui/privacy/associated-item-privacy-trait.stderr113
-rw-r--r--src/test/ui/privacy/private-in-public-assoc-ty.rs5
-rw-r--r--src/test/ui/privacy/private-in-public-assoc-ty.stderr25
-rw-r--r--src/test/ui/ufcs/ufcs-partially-resolved.rs4
-rw-r--r--src/test/ui/ufcs/ufcs-partially-resolved.stderr10
13 files changed, 218 insertions, 116 deletions
diff --git a/src/test/ui/associated-types/associated-types-overridden-default.rs b/src/test/ui/associated-types/associated-types-overridden-default.rs
index 629fc7a7668..72c30df0b3d 100644
--- a/src/test/ui/associated-types/associated-types-overridden-default.rs
+++ b/src/test/ui/associated-types/associated-types-overridden-default.rs
@@ -1,3 +1,8 @@
+// check-pass
+
+// Before RFC 2532, overriding one assoc. type default required overriding all
+// provided defaults.
+
 #![feature(associated_type_defaults)]
 
 pub trait Tr {
@@ -9,7 +14,6 @@ pub trait Tr {
 
 impl Tr for () {
     type Assoc = ();
-    //~^ ERROR need to be reimplemented as `Assoc` was overridden: `Assoc2`, `C`, `foo`
 }
 
 fn main() {}
diff --git a/src/test/ui/associated-types/associated-types-overridden-default.stderr b/src/test/ui/associated-types/associated-types-overridden-default.stderr
deleted file mode 100644
index 79fb9a613c2..00000000000
--- a/src/test/ui/associated-types/associated-types-overridden-default.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0399]: the following trait items need to be reimplemented as `Assoc` was overridden: `Assoc2`, `C`, `foo`
-  --> $DIR/associated-types-overridden-default.rs:11:5
-   |
-LL |     type Assoc = ();
-   |     ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0399`.
diff --git a/src/test/ui/associated-types/defaults-cyclic-fail.rs b/src/test/ui/associated-types/defaults-cyclic-fail.rs
new file mode 100644
index 00000000000..ab66fe0b52e
--- /dev/null
+++ b/src/test/ui/associated-types/defaults-cyclic-fail.rs
@@ -0,0 +1,35 @@
+#![feature(associated_type_defaults)]
+
+// Having a cycle in assoc. type defaults is okay...
+trait Tr {
+    type A = Self::B;
+    type B = Self::A;
+}
+
+// ...but is an error in any impl that doesn't override at least one of the defaults
+impl Tr for () {}
+//~^ ERROR overflow evaluating the requirement
+
+// As soon as at least one is redefined, it works:
+impl Tr for u8 {
+    type A = u8;
+}
+
+impl Tr for u32 {
+    type A = ();
+    type B = u8;
+}
+
+// ...but only if this actually breaks the cycle
+impl Tr for bool {
+//~^ ERROR overflow evaluating the requirement
+    type A = Box<Self::B>;
+    //~^ ERROR overflow evaluating the requirement
+}
+// (the error is shown twice for some reason)
+
+fn main() {
+    // Check that the overridden type propagates to the other
+    let _a: <u8 as Tr>::A = 0u8;
+    let _b: <u8 as Tr>::B = 0u8;
+}
diff --git a/src/test/ui/associated-types/defaults-cyclic-fail.stderr b/src/test/ui/associated-types/defaults-cyclic-fail.stderr
new file mode 100644
index 00000000000..dd0e5c2ef42
--- /dev/null
+++ b/src/test/ui/associated-types/defaults-cyclic-fail.stderr
@@ -0,0 +1,21 @@
+error[E0275]: overflow evaluating the requirement `<() as Tr>::B`
+  --> $DIR/defaults-cyclic-fail.rs:10:6
+   |
+LL | impl Tr for () {}
+   |      ^^
+
+error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
+  --> $DIR/defaults-cyclic-fail.rs:24:6
+   |
+LL | impl Tr for bool {
+   |      ^^
+
+error[E0275]: overflow evaluating the requirement `<bool as Tr>::B`
+  --> $DIR/defaults-cyclic-fail.rs:26:5
+   |
+LL |     type A = Box<Self::B>;
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/associated-types/defaults-cyclic-pass.rs b/src/test/ui/associated-types/defaults-cyclic-pass.rs
new file mode 100644
index 00000000000..618a2038507
--- /dev/null
+++ b/src/test/ui/associated-types/defaults-cyclic-pass.rs
@@ -0,0 +1,22 @@
+// check-pass
+
+#![feature(associated_type_defaults)]
+
+trait Tr {
+    type Item = u8;
+    type Container = Vec<Self::Item>;
+}
+
+impl Tr for () {}
+
+impl Tr for u16 {
+    type Item = u16;
+}
+
+fn main() {
+    let _container: <() as Tr>::Container = Vec::<u8>::new();
+    let _item: <() as Tr>::Item = 0u8;
+
+    let _container: <u16 as Tr>::Container = Vec::<u16>::new();
+    let _item: <u16 as Tr>::Item = 0u16;
+}
diff --git a/src/test/ui/associated-types/defaults-in-other-trait-items.rs b/src/test/ui/associated-types/defaults-in-other-trait-items.rs
new file mode 100644
index 00000000000..0455997b168
--- /dev/null
+++ b/src/test/ui/associated-types/defaults-in-other-trait-items.rs
@@ -0,0 +1,50 @@
+#![feature(associated_type_defaults)]
+
+// Associated type defaults may not be assumed inside the trait defining them.
+// ie. they only resolve to `<Self as Tr>::A`, not the actual type `()`
+trait Tr {
+    type A = ();
+
+    fn f(p: Self::A) {
+        let () = p;
+        //~^ ERROR mismatched types
+        //~| NOTE expected associated type, found `()`
+        //~| NOTE expected associated type `<Self as Tr>::A`
+        //~| NOTE consider constraining
+        //~| NOTE for more information, visit
+    }
+}
+
+// An impl that doesn't override the type *can* assume the default.
+impl Tr for () {
+    fn f(p: Self::A) {
+        let () = p;
+    }
+}
+
+impl Tr for u8 {
+    type A = ();
+
+    fn f(p: Self::A) {
+        let () = p;
+    }
+}
+
+trait AssocConst {
+    type Ty = u8;
+
+    // Assoc. consts also cannot assume that default types hold
+    const C: Self::Ty = 0u8;
+    //~^ ERROR mismatched types
+    //~| NOTE expected associated type, found `u8`
+    //~| NOTE expected associated type `<Self as AssocConst>::Ty`
+    //~| NOTE consider constraining
+    //~| NOTE for more information, visit
+}
+
+// An impl can, however
+impl AssocConst for () {
+    const C: Self::Ty = 0u8;
+}
+
+fn main() {}
diff --git a/src/test/ui/associated-types/defaults-in-other-trait-items.stderr b/src/test/ui/associated-types/defaults-in-other-trait-items.stderr
new file mode 100644
index 00000000000..9ecfe49c2b5
--- /dev/null
+++ b/src/test/ui/associated-types/defaults-in-other-trait-items.stderr
@@ -0,0 +1,25 @@
+error[E0308]: mismatched types
+  --> $DIR/defaults-in-other-trait-items.rs:9:13
+   |
+LL |         let () = p;
+   |             ^^ expected associated type, found `()`
+   |
+   = note: expected associated type `<Self as Tr>::A`
+                    found unit type `()`
+   = note: consider constraining the associated type `<Self as Tr>::A` to `()` or calling a method that returns `<Self as Tr>::A`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+
+error[E0308]: mismatched types
+  --> $DIR/defaults-in-other-trait-items.rs:37:25
+   |
+LL |     const C: Self::Ty = 0u8;
+   |                         ^^^ expected associated type, found `u8`
+   |
+   = note: expected associated type `<Self as AssocConst>::Ty`
+                         found type `u8`
+   = note: consider constraining the associated type `<Self as AssocConst>::Ty` to `u8` or calling a method that returns `<Self as AssocConst>::Ty`
+   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/privacy/associated-item-privacy-trait.rs b/src/test/ui/privacy/associated-item-privacy-trait.rs
index b3d42f09596..03347d5b99a 100644
--- a/src/test/ui/privacy/associated-item-privacy-trait.rs
+++ b/src/test/ui/privacy/associated-item-privacy-trait.rs
@@ -23,8 +23,7 @@ mod priv_trait {
         <Pub as PrivTr>::CONST;
         //~^ ERROR associated constant `PrivTr::CONST` is private
         let _: <Pub as PrivTr>::AssocTy;
-        //~^ ERROR trait `priv_trait::PrivTr` is private
-        //~| ERROR trait `priv_trait::PrivTr` is private
+        //~^ ERROR associated type `PrivTr::AssocTy` is private
         pub type InSignatureTy = <Pub as PrivTr>::AssocTy;
         //~^ ERROR trait `priv_trait::PrivTr` is private
         pub trait InSignatureTr: PrivTr {}
@@ -116,15 +115,11 @@ mod priv_parent_substs {
         <Priv as PubTr<_>>::CONST;
         //~^ ERROR type `priv_parent_substs::Priv` is private
 
-        let _: <Pub as PubTr>::AssocTy;
-        //~^ ERROR type `priv_parent_substs::Priv` is private
-        //~| ERROR type `priv_parent_substs::Priv` is private
+        let _: <Pub as PubTr>::AssocTy;  // FIXME no longer an error?!
         let _: <Pub as PubTr<_>>::AssocTy;
         //~^ ERROR type `priv_parent_substs::Priv` is private
-        //~| ERROR type `priv_parent_substs::Priv` is private
         let _: <Priv as PubTr<_>>::AssocTy;
         //~^ ERROR type `priv_parent_substs::Priv` is private
-        //~| ERROR type `priv_parent_substs::Priv` is private
 
         pub type InSignatureTy1 = <Pub as PubTr>::AssocTy;
         //~^ ERROR type `priv_parent_substs::Priv` is private
diff --git a/src/test/ui/privacy/associated-item-privacy-trait.stderr b/src/test/ui/privacy/associated-item-privacy-trait.stderr
index ac422e99855..db24e425a01 100644
--- a/src/test/ui/privacy/associated-item-privacy-trait.stderr
+++ b/src/test/ui/privacy/associated-item-privacy-trait.stderr
@@ -42,18 +42,7 @@ LL |     priv_trait::mac!();
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: trait `priv_trait::PrivTr` is private
-  --> $DIR/associated-item-privacy-trait.rs:25:13
-   |
-LL |         let _: <Pub as PrivTr>::AssocTy;
-   |             ^
-...
-LL |     priv_trait::mac!();
-   |     ------------------- in this macro invocation
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: trait `priv_trait::PrivTr` is private
+error: associated type `PrivTr::AssocTy` is private
   --> $DIR/associated-item-privacy-trait.rs:25:16
    |
 LL |         let _: <Pub as PrivTr>::AssocTy;
@@ -65,7 +54,7 @@ LL |     priv_trait::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `priv_trait::PrivTr` is private
-  --> $DIR/associated-item-privacy-trait.rs:28:34
+  --> $DIR/associated-item-privacy-trait.rs:27:34
    |
 LL |         pub type InSignatureTy = <Pub as PrivTr>::AssocTy;
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -76,7 +65,7 @@ LL |     priv_trait::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `priv_trait::PrivTr` is private
-  --> $DIR/associated-item-privacy-trait.rs:30:34
+  --> $DIR/associated-item-privacy-trait.rs:29:34
    |
 LL |         pub trait InSignatureTr: PrivTr {}
    |                                  ^^^^^^
@@ -87,7 +76,7 @@ LL |     priv_trait::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `priv_trait::PrivTr` is private
-  --> $DIR/associated-item-privacy-trait.rs:32:14
+  --> $DIR/associated-item-privacy-trait.rs:31:14
    |
 LL |         impl PrivTr for u8 {}
    |              ^^^^^^
@@ -98,7 +87,7 @@ LL |     priv_trait::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:49:21
+  --> $DIR/associated-item-privacy-trait.rs:48:21
    |
 LL |         let value = <Pub as PubTr>::method;
    |                     ^^^^^^^^^^^^^^^^^^^^^^
@@ -109,7 +98,7 @@ LL |     priv_signature::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:51:9
+  --> $DIR/associated-item-privacy-trait.rs:50:9
    |
 LL |         value;
    |         ^^^^^
@@ -120,7 +109,7 @@ LL |     priv_signature::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:53:13
+  --> $DIR/associated-item-privacy-trait.rs:52:13
    |
 LL |         Pub.method(loop {});
    |             ^^^^^^
@@ -131,7 +120,7 @@ LL |     priv_signature::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:70:21
+  --> $DIR/associated-item-privacy-trait.rs:69:21
    |
 LL |         let value = <Pub as PubTr>::method::<Priv>;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -142,7 +131,7 @@ LL |     priv_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:72:9
+  --> $DIR/associated-item-privacy-trait.rs:71:9
    |
 LL |         value;
    |         ^^^^^
@@ -153,7 +142,7 @@ LL |     priv_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:74:9
+  --> $DIR/associated-item-privacy-trait.rs:73:9
    |
 LL |         Pub.method::<Priv>();
    |         ^^^^^^^^^^^^^^^^^^^^
@@ -164,7 +153,7 @@ LL |     priv_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:94:21
+  --> $DIR/associated-item-privacy-trait.rs:93:21
    |
 LL |         let value = <Pub as PubTr>::method;
    |                     ^^^^^^^^^^^^^^^^^^^^^^
@@ -175,7 +164,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:96:9
+  --> $DIR/associated-item-privacy-trait.rs:95:9
    |
 LL |         value;
    |         ^^^^^
@@ -186,7 +175,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:98:21
+  --> $DIR/associated-item-privacy-trait.rs:97:21
    |
 LL |         let value = <Pub as PubTr<_>>::method;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -197,7 +186,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:100:9
+  --> $DIR/associated-item-privacy-trait.rs:99:9
    |
 LL |         value;
    |         ^^^^^
@@ -208,7 +197,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:102:9
+  --> $DIR/associated-item-privacy-trait.rs:101:9
    |
 LL |         Pub.method();
    |         ^^^^^^^^^^^^
@@ -219,7 +208,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:105:21
+  --> $DIR/associated-item-privacy-trait.rs:104:21
    |
 LL |         let value = <Priv as PubTr<_>>::method;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -230,7 +219,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:107:9
+  --> $DIR/associated-item-privacy-trait.rs:106:9
    |
 LL |         value;
    |         ^^^^^
@@ -241,7 +230,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:109:9
+  --> $DIR/associated-item-privacy-trait.rs:108:9
    |
 LL |         Priv.method();
    |         ^^^^^^^^^^^^^
@@ -252,7 +241,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:112:9
+  --> $DIR/associated-item-privacy-trait.rs:111:9
    |
 LL |         <Pub as PubTr>::CONST;
    |         ^^^^^^^^^^^^^^^^^^^^^
@@ -263,7 +252,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:114:9
+  --> $DIR/associated-item-privacy-trait.rs:113:9
    |
 LL |         <Pub as PubTr<_>>::CONST;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -274,7 +263,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:116:9
+  --> $DIR/associated-item-privacy-trait.rs:115:9
    |
 LL |         <Priv as PubTr<_>>::CONST;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -285,54 +274,10 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:119:13
-   |
-LL |         let _: <Pub as PubTr>::AssocTy;
-   |             ^
-...
-LL |     priv_parent_substs::mac!();
-   |     --------------------------- in this macro invocation
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:119:16
-   |
-LL |         let _: <Pub as PubTr>::AssocTy;
-   |                ^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL |     priv_parent_substs::mac!();
-   |     --------------------------- in this macro invocation
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:122:13
-   |
-LL |         let _: <Pub as PubTr<_>>::AssocTy;
-   |             ^
-...
-LL |     priv_parent_substs::mac!();
-   |     --------------------------- in this macro invocation
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:122:16
+  --> $DIR/associated-item-privacy-trait.rs:119:30
    |
 LL |         let _: <Pub as PubTr<_>>::AssocTy;
-   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL |     priv_parent_substs::mac!();
-   |     --------------------------- in this macro invocation
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:125:13
-   |
-LL |         let _: <Priv as PubTr<_>>::AssocTy;
-   |             ^
+   |                              ^
 ...
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
@@ -340,10 +285,10 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:125:16
+  --> $DIR/associated-item-privacy-trait.rs:121:17
    |
 LL |         let _: <Priv as PubTr<_>>::AssocTy;
-   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                 ^^^^
 ...
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
@@ -351,7 +296,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:129:35
+  --> $DIR/associated-item-privacy-trait.rs:124:35
    |
 LL |         pub type InSignatureTy1 = <Pub as PubTr>::AssocTy;
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^
@@ -362,7 +307,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:131:35
+  --> $DIR/associated-item-privacy-trait.rs:126:35
    |
 LL |         pub type InSignatureTy2 = <Priv as PubTr<Pub>>::AssocTy;
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -373,7 +318,7 @@ LL |     priv_parent_substs::mac!();
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
-  --> $DIR/associated-item-privacy-trait.rs:133:14
+  --> $DIR/associated-item-privacy-trait.rs:128:14
    |
 LL |         impl PubTr for u8 {}
    |              ^^^^^
@@ -383,5 +328,5 @@ LL |     priv_parent_substs::mac!();
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 35 previous errors
+error: aborting due to 30 previous errors
 
diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.rs b/src/test/ui/privacy/private-in-public-assoc-ty.rs
index ad1052ada60..62faae1f399 100644
--- a/src/test/ui/privacy/private-in-public-assoc-ty.rs
+++ b/src/test/ui/privacy/private-in-public-assoc-ty.rs
@@ -10,6 +10,11 @@ mod m {
     impl PrivTr for Priv {}
     pub trait PubTrAux1<T> {}
     pub trait PubTrAux2 { type A; }
+    impl<T> PubTrAux1<T> for u8 {}
+    impl PubTrAux2 for u8 {
+        type A = Priv;
+        //~^ ERROR private type `m::Priv` in public interface
+    }
 
     // "Private-in-public in associated types is hard error" in RFC 2145
     // applies only to the aliased types, not bounds.
diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.stderr b/src/test/ui/privacy/private-in-public-assoc-ty.stderr
index 3cc551cdede..c57073a004d 100644
--- a/src/test/ui/privacy/private-in-public-assoc-ty.stderr
+++ b/src/test/ui/privacy/private-in-public-assoc-ty.stderr
@@ -1,5 +1,14 @@
+error[E0446]: private type `m::Priv` in public interface
+  --> $DIR/private-in-public-assoc-ty.rs:15:9
+   |
+LL |     struct Priv;
+   |     - `m::Priv` declared as private
+...
+LL |         type A = Priv;
+   |         ^^^^^^^^^^^^^^ can't leak private type
+
 warning: private trait `m::PrivTr` in public interface (error E0445)
-  --> $DIR/private-in-public-assoc-ty.rs:16:5
+  --> $DIR/private-in-public-assoc-ty.rs:21:5
    |
 LL | /     pub trait PubTr {
 LL | |
@@ -15,7 +24,7 @@ LL | |     }
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 warning: private type `m::Priv` in public interface (error E0446)
-  --> $DIR/private-in-public-assoc-ty.rs:16:5
+  --> $DIR/private-in-public-assoc-ty.rs:21:5
    |
 LL | /     pub trait PubTr {
 LL | |
@@ -30,7 +39,7 @@ LL | |     }
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 warning: private type `m::Priv` in public interface (error E0446)
-  --> $DIR/private-in-public-assoc-ty.rs:16:5
+  --> $DIR/private-in-public-assoc-ty.rs:21:5
    |
 LL | /     pub trait PubTr {
 LL | |
@@ -45,7 +54,7 @@ LL | |     }
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
 
 error[E0446]: private type `m::Priv` in public interface
-  --> $DIR/private-in-public-assoc-ty.rs:27:9
+  --> $DIR/private-in-public-assoc-ty.rs:32:9
    |
 LL |     struct Priv;
    |     - `m::Priv` declared as private
@@ -54,7 +63,7 @@ LL |         type Alias4 = Priv;
    |         ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `m::Priv` in public interface
-  --> $DIR/private-in-public-assoc-ty.rs:34:9
+  --> $DIR/private-in-public-assoc-ty.rs:39:9
    |
 LL |     struct Priv;
    |     - `m::Priv` declared as private
@@ -63,7 +72,7 @@ LL |         type Alias1 = Priv;
    |         ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0445]: private trait `m::PrivTr` in public interface
-  --> $DIR/private-in-public-assoc-ty.rs:37:9
+  --> $DIR/private-in-public-assoc-ty.rs:42:9
    |
 LL |     trait PrivTr {}
    |     - `m::PrivTr` declared as private
@@ -72,7 +81,7 @@ LL |         type Exist = impl PrivTr;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0445]: private trait `m::PrivTr` in public interface
-  --> $DIR/private-in-public-assoc-ty.rs:37:9
+  --> $DIR/private-in-public-assoc-ty.rs:42:9
    |
 LL |     trait PrivTr {}
    |     - `m::PrivTr` declared as private
@@ -80,7 +89,7 @@ LL |     trait PrivTr {}
 LL |         type Exist = impl PrivTr;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
-error: aborting due to 4 previous errors
+error: aborting due to 5 previous errors
 
 Some errors have detailed explanations: E0445, E0446.
 For more information about an error, try `rustc --explain E0445`.
diff --git a/src/test/ui/ufcs/ufcs-partially-resolved.rs b/src/test/ui/ufcs/ufcs-partially-resolved.rs
index 66d4db3ebaf..e8c767b13e9 100644
--- a/src/test/ui/ufcs/ufcs-partially-resolved.rs
+++ b/src/test/ui/ufcs/ufcs-partially-resolved.rs
@@ -35,7 +35,7 @@ fn main() {
     <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A`
     let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type
     let _: <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y`
-    <u8 as Tr>::Y::NN; //~ ERROR no associated item named `NN` found
+    <u8 as Tr>::Y::NN; //~ ERROR no associated item named `NN` found for type `u16`
     <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y`
 
     let _: <u8 as Tr::N>::NN; //~ ERROR cannot find associated type `NN` in `Tr::N`
@@ -52,5 +52,5 @@ fn main() {
     let _: <u8 as Dr>::Z; //~ ERROR expected associated type, found method `Dr::Z`
     <u8 as Dr>::X; //~ ERROR expected method or associated constant, found associated type `Dr::X`
     let _: <u8 as Dr>::Z::N; //~ ERROR expected associated type, found method `Dr::Z`
-    <u8 as Dr>::X::N; //~ ERROR no associated item named `N` found
+    <u8 as Dr>::X::N; //~ ERROR no associated item named `N` found for type `u16`
 }
diff --git a/src/test/ui/ufcs/ufcs-partially-resolved.stderr b/src/test/ui/ufcs/ufcs-partially-resolved.stderr
index 60ebe8ee053..e5e6ed9fac9 100644
--- a/src/test/ui/ufcs/ufcs-partially-resolved.stderr
+++ b/src/test/ui/ufcs/ufcs-partially-resolved.stderr
@@ -205,19 +205,19 @@ error[E0223]: ambiguous associated type
   --> $DIR/ufcs-partially-resolved.rs:36:12
    |
 LL |     let _: <u8 as Tr>::Y::NN;
-   |            ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<u8 as Tr>::Y as Trait>::NN`
+   |            ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u16 as Trait>::NN`
 
-error[E0599]: no associated item named `NN` found for associated type `<u8 as Tr>::Y` in the current scope
+error[E0599]: no associated item named `NN` found for type `u16` in the current scope
   --> $DIR/ufcs-partially-resolved.rs:38:20
    |
 LL |     <u8 as Tr>::Y::NN;
-   |                    ^^ associated item not found in `<u8 as Tr>::Y`
+   |                    ^^ associated item not found in `u16`
 
-error[E0599]: no associated item named `N` found for associated type `<u8 as Dr>::X` in the current scope
+error[E0599]: no associated item named `N` found for type `u16` in the current scope
   --> $DIR/ufcs-partially-resolved.rs:55:20
    |
 LL |     <u8 as Dr>::X::N;
-   |                    ^ associated item not found in `<u8 as Dr>::X`
+   |                    ^ associated item not found in `u16`
 
 error: aborting due to 32 previous errors