Skip to content

Conversation

@xonx4l
Copy link
Contributor

@xonx4l xonx4l commented Dec 27, 2025

This PR adds a diagnostics note when param-env shadows global impl as discussed in #149910

It adds a note explaining that the definition is hidden by the generic bound.

r?lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 27, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const/suggest-contraining-assoc-type-because-of-assoc-const.stderr`
diff of stderr:

6    |
7    = note: expected associated type `<C as O>::M`
8                          found type `u8`
+    = note: the associated type `<C as O>::M` is defined as `u8` in the implementation, but the generic bound `C` hides this definition
9 help: consider constraining the associated type `<C as O>::M` to `u8`
10    |
11 LL | impl<C: O<M = u8>> U<C> for u16 {


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs:13:21
   |
LL |     const N: C::M = 4u8; //~ ERROR mismatched types
   |                     ^^^ expected associated type, found `u8`
   |
   = note: expected associated type `<C as O>::M`
                         found type `u8`
   = note: the associated type `<C as O>::M` is defined as `u8` in the implementation, but the generic bound `C` hides this definition
help: consider constraining the associated type `<C as O>::M` to `u8`
   |
LL | impl<C: O<M = u8>> U<C> for u16 {
   |          ++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
---

89    |
90    = note: expected associated type `<B2<T> as Tr>::Ty`
91                          found type `bool`
+    = note: the associated type `<B2<T> as Tr>::Ty` is defined as `bool` in the implementation, but the generic bound `B2<T>` hides this definition
92 
93 error[E0308]: mismatched types
94   --> $DIR/defaults-specialization.rs:87:32

121    |
122 LL |     fn make() -> Self::Ty {
123    |     ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make`
+    = note: the associated type `<B<()> as Tr>::Ty` is defined as `bool` in the implementation, but the generic bound `B<()>` hides this definition
124 
125 error[E0308]: mismatched types
126   --> $DIR/defaults-specialization.rs:89:33

153    |
154 LL |     fn make() -> Self::Ty {
155    |     ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make`
+    = note: the associated type `<B2<()> as Tr>::Ty` is defined as `bool` in the implementation, but the generic bound `B2<()>` hides this definition
156 
157 error: aborting due to 9 previous errors; 1 warning emitted
158 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args associated-types/defaults-specialization.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/associated-types/defaults-specialization.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/associated-types/defaults-specialization" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:3:38
   |
---
  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:9:18
   |
LL |     fn make() -> Self::Ty {
   |                  ^^^^^^^^
   = note: expected signature `fn() -> <A<T> as Tr>::Ty`
              found signature `fn() -> u8`
help: change the output type to match the trait
   |
LL -     fn make() -> u8 { 0 }
LL +     fn make() -> <A<T> as Tr>::Ty { 0 }
   |

error[E0053]: method `make` has an incompatible type for trait
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:35:18
   |
---
  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:9:18
   |
LL |     fn make() -> Self::Ty {
   |                  ^^^^^^^^
   = note: expected signature `fn() -> <B<T> as Tr>::Ty`
              found signature `fn() -> bool`
help: change the output type to match the trait
   |
LL -     fn make() -> bool { true }
LL +     fn make() -> <B<T> as Tr>::Ty { true }
   |

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:10:9
   |
---
   |
LL |     fn make() -> Self::Ty { 0u8 }
   |                  --------   ^^^ expected associated type, found `u8`
   |                  |
   |                  expected `<A2<T> as Tr>::Ty` because of return type
   |
   = note: expected associated type `<A2<T> as Tr>::Ty`
                         found type `u8`
   = help: consider constraining the associated type `<A2<T> as Tr>::Ty` to `u8` or calling a method that returns `<A2<T> as Tr>::Ty`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:44:29
   |
LL |     default type Ty = bool;
   |     --------------- associated type is `default` and may be overridden
LL |
LL |     fn make() -> Self::Ty { true }
   |                  --------   ^^^^ expected associated type, found `bool`
   |                  |
   |                  expected `<B2<T> as Tr>::Ty` because of return type
   |
   = note: expected associated type `<B2<T> as Tr>::Ty`
                         found type `bool`
   = note: the associated type `<B2<T> as Tr>::Ty` is defined as `bool` in the implementation, but the generic bound `B2<T>` hides this definition

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:87:32
   |
LL |     let _: <B<()> as Tr>::Ty = 0u8;   //~ error: mismatched types
   |            -----------------   ^^^ expected associated type, found `u8`
   |            |
   |            expected due to this
   |
   = note: expected associated type `<B<()> as Tr>::Ty`
                         found type `u8`
help: a method is available that returns `<B<()> as Tr>::Ty`
  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:9:5
   |
LL |     fn make() -> Self::Ty {
   |     ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make`

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:88:32
   |
LL |     let _: <B<()> as Tr>::Ty = true;  //~ error: mismatched types
   |            -----------------   ^^^^ expected associated type, found `bool`
   |            |
   |            expected due to this
   |
   = note: expected associated type `<B<()> as Tr>::Ty`
                         found type `bool`
help: a method is available that returns `<B<()> as Tr>::Ty`
  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:9:5
   |
LL |     fn make() -> Self::Ty {
   |     ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make`
   = note: the associated type `<B<()> as Tr>::Ty` is defined as `bool` in the implementation, but the generic bound `B<()>` hides this definition

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:89:33
   |
LL |     let _: <B2<()> as Tr>::Ty = 0u8;  //~ error: mismatched types
   |            ------------------   ^^^ expected associated type, found `u8`
   |            |
   |            expected due to this
   |
   = note: expected associated type `<B2<()> as Tr>::Ty`
                         found type `u8`
help: a method is available that returns `<B2<()> as Tr>::Ty`
  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:9:5
   |
LL |     fn make() -> Self::Ty {
   |     ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make`

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:90:33
   |
LL |     let _: <B2<()> as Tr>::Ty = true; //~ error: mismatched types
   |            ------------------   ^^^^ expected associated type, found `bool`
   |            |
   |            expected due to this
   |
   = note: expected associated type `<B2<()> as Tr>::Ty`
                         found type `bool`
help: a method is available that returns `<B2<()> as Tr>::Ty`
  --> /checkout/tests/ui/associated-types/defaults-specialization.rs:9:5
   |
LL |     fn make() -> Self::Ty {
   |     ^^^^^^^^^^^^^^^^^^^^^ consider calling `Tr::make`
   = note: the associated type `<B2<()> as Tr>::Ty` is defined as `bool` in the implementation, but the generic bound `B2<()>` hides this definition

error: aborting due to 9 previous errors; 1 warning emitted

Some errors have detailed explanations: E0053, E0308.
For more information about an error, try `rustc --explain E0053`.
---
1 error[E0308]: mismatched types
-   --> $DIR/issue-149910.rs:10:5
+   --> $DIR/param-env-shadowing-issue-149910.rs:10:5
3    |
4 LL | fn foo<T: Trait>(x: T) -> T::Assoc {
5    |        -                  -------- expected `<T as Trait>::Assoc` because of return type

6    |        |
7    |        found this type parameter
- LL |     x 
+ LL |     x
---
To only update this specific test, also pass `--test-args associated-types/param-env-shadowing-issue-149910.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/associated-types/param-env-shadowing-issue-149910.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/associated-types/param-env-shadowing-issue-149910" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/associated-types/param-env-shadowing-issue-149910.rs:10:5
   |
LL | fn foo<T: Trait>(x: T) -> T::Assoc {
   |        -                  -------- expected `<T as Trait>::Assoc` because of return type
   |        |
   |        found this type parameter
LL |     x
   |     ^ expected associated type, found type parameter `T`
   |
   = note: expected associated type `<T as Trait>::Assoc`
               found type parameter `T`
   = note: the associated type `<T as Trait>::Assoc` is defined as `T` in the implementation, but the generic bound `T` hides this definition
help: consider further restricting this bound
   |
LL | fn foo<T: Trait<Assoc = T>>(x: T) -> T::Assoc {
   |                +++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
---
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-projection.current/specialization-default-projection.current.stderr`
diff of stderr:

21                     found unit type `()`
22    = help: consider constraining the associated type `<T as Foo>::Assoc` to `()` or calling a method that returns `<T as Foo>::Assoc`
23    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+    = note: the associated type `<T as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `T` hides this definition
24 
25 error[E0308]: mismatched types
26   --> $DIR/specialization-default-projection.rs:32:5

37            found associated type `<() as Foo>::Assoc`
38    = help: consider constraining the associated type `<() as Foo>::Assoc` to `()`
39    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+    = note: the associated type `<() as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `()` hides this definition
40 
41 error: aborting due to 2 previous errors; 1 warning emitted
42 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args specialization/specialization-default-projection.rs`

error in revision `current`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/specialization/specialization-default-projection.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "current" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-projection.current" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/specialization/specialization-default-projection.rs:5:12
   |
LL | #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
   |            ^^^^^^^^^^^^^^
   |
   = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
   = help: consider using `min_specialization` instead, which is more stable and complete
   = note: `#[warn(incomplete_features)]` on by default

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-projection.rs:25:5
   |
LL | fn generic<T>() -> <T as Foo>::Assoc {
   |                    ----------------- expected `<T as Foo>::Assoc` because of return type
...
LL |     () //~ ERROR mismatched types
   |     ^^ expected associated type, found `()`
   |
   = note: expected associated type `<T as Foo>::Assoc`
                    found unit type `()`
   = help: consider constraining the associated type `<T as Foo>::Assoc` to `()` or calling a method that returns `<T as Foo>::Assoc`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
   = note: the associated type `<T as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `T` hides this definition

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-projection.rs:32:5
   |
LL | fn monomorphic() -> () {
   |                     -- expected `()` because of return type
...
LL |     generic::<()>() //~ ERROR mismatched types
   |     ^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
   |     |
   |     expected `()`, found associated type
   |
   = note:    expected unit type `()`
           found associated type `<() as Foo>::Assoc`
   = help: consider constraining the associated type `<() as Foo>::Assoc` to `()`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
   = note: the associated type `<() as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `()` hides this definition

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0308`.
------------------------------------------

---- [ui] tests/ui/specialization/specialization-default-projection.rs#current stdout end ----
---- [ui] tests/ui/specialization/specialization-default-projection.rs#next stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-projection.next/specialization-default-projection.next.stderr`
diff of stderr:

21                     found unit type `()`
22    = help: consider constraining the associated type `<T as Foo>::Assoc` to `()` or calling a method that returns `<T as Foo>::Assoc`
23    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+    = note: the associated type `<T as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `T` hides this definition
24 
25 error[E0308]: mismatched types
26   --> $DIR/specialization-default-projection.rs:32:5

37            found associated type `<() as Foo>::Assoc`
38    = help: consider constraining the associated type `<() as Foo>::Assoc` to `()`
39    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+    = note: the associated type `<() as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `()` hides this definition
40 
41 error: aborting due to 2 previous errors; 1 warning emitted
42 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args specialization/specialization-default-projection.rs`

error in revision `next`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/specialization/specialization-default-projection.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-projection.next" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
stdout: none
--- stderr -------------------------------
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/specialization/specialization-default-projection.rs:5:12
   |
LL | #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
   |            ^^^^^^^^^^^^^^
   |
   = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
   = help: consider using `min_specialization` instead, which is more stable and complete
   = note: `#[warn(incomplete_features)]` on by default

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-projection.rs:25:5
   |
LL | fn generic<T>() -> <T as Foo>::Assoc {
   |                    ----------------- expected `<T as Foo>::Assoc` because of return type
...
LL |     () //~ ERROR mismatched types
   |     ^^ types differ
   |
   = note: expected associated type `<T as Foo>::Assoc`
                    found unit type `()`
   = help: consider constraining the associated type `<T as Foo>::Assoc` to `()` or calling a method that returns `<T as Foo>::Assoc`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
   = note: the associated type `<T as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `T` hides this definition

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-projection.rs:32:5
   |
LL | fn monomorphic() -> () {
   |                     -- expected `()` because of return type
...
LL |     generic::<()>() //~ ERROR mismatched types
   |     ^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
   |     |
   |     types differ
   |
   = note:    expected unit type `()`
           found associated type `<() as Foo>::Assoc`
   = help: consider constraining the associated type `<() as Foo>::Assoc` to `()`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
   = note: the associated type `<() as Foo>::Assoc` is defined as `()` in the implementation, but the generic bound `()` hides this definition

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0308`.
------------------------------------------

---- [ui] tests/ui/specialization/specialization-default-projection.rs#next stdout end ----
---- [ui] tests/ui/specialization/specialization-default-types.rs#current stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-types.current/specialization-default-types.current.stderr`
diff of stderr:

20    |
21    = note: expected associated type `<T as Example>::Output`
22                        found struct `Box<T>`
+    = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition
23 
24 error[E0308]: mismatched types
25   --> $DIR/specialization-default-types.rs:29:5

33            found associated type `<T as Example>::Output`
34    = help: consider constraining the associated type `<T as Example>::Output` to `Box<T>`
35    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+    = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition
36 
37 error: aborting due to 2 previous errors; 1 warning emitted
38 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args specialization/specialization-default-types.rs`

error in revision `current`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/specialization/specialization-default-types.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "current" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-types.current" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/specialization/specialization-default-types.rs:9:12
   |
LL | #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
   |            ^^^^^^^^^^^^^^
   |
   = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
   = help: consider using `min_specialization` instead, which is more stable and complete
   = note: `#[warn(incomplete_features)]` on by default

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-types.rs:19:9
   |
LL |     default type Output = Box<T>;
   |     ------------------- associated type is `default` and may be overridden
LL |     default fn generate(self) -> Self::Output {
   |                                  ------------ expected `<T as Example>::Output` because of return type
LL |         Box::new(self) //~ ERROR mismatched types
   |         ^^^^^^^^^^^^^^ expected associated type, found `Box<T>`
   |
   = note: expected associated type `<T as Example>::Output`
                       found struct `Box<T>`
   = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-types.rs:29:5
   |
LL | fn trouble<T>(t: T) -> Box<T> {
   |                        ------ expected `Box<T>` because of return type
LL |     Example::generate(t) //~ ERROR mismatched types
   |     ^^^^^^^^^^^^^^^^^^^^ expected `Box<T>`, found associated type
   |
   = note:       expected struct `Box<T>`
           found associated type `<T as Example>::Output`
   = help: consider constraining the associated type `<T as Example>::Output` to `Box<T>`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
   = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0308`.
------------------------------------------

---- [ui] tests/ui/specialization/specialization-default-types.rs#current stdout end ----
---- [ui] tests/ui/specialization/specialization-default-types.rs#next stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-types.next/specialization-default-types.next.stderr`
diff of stderr:

20    |
21    = note: expected associated type `<T as Example>::Output`
22                        found struct `Box<T>`
+    = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition
23 
24 error[E0308]: mismatched types
25   --> $DIR/specialization-default-types.rs:29:5

33            found associated type `<T as Example>::Output`
34    = help: consider constraining the associated type `<T as Example>::Output` to `Box<T>`
35    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+    = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition
36 
37 error: aborting due to 2 previous errors; 1 warning emitted
38 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args specialization/specialization-default-types.rs`

error in revision `next`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/specialization/specialization-default-types.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/specialization/specialization-default-types.next" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
stdout: none
--- stderr -------------------------------
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/specialization/specialization-default-types.rs:9:12
   |
LL | #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
   |            ^^^^^^^^^^^^^^
   |
   = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
   = help: consider using `min_specialization` instead, which is more stable and complete
   = note: `#[warn(incomplete_features)]` on by default

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-types.rs:19:9
   |
LL |     default type Output = Box<T>;
   |     ------------------- associated type is `default` and may be overridden
LL |     default fn generate(self) -> Self::Output {
   |                                  ------------ expected `<T as Example>::Output` because of return type
LL |         Box::new(self) //~ ERROR mismatched types
   |         ^^^^^^^^^^^^^^ types differ
   |
   = note: expected associated type `<T as Example>::Output`
                       found struct `Box<T>`
   = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/specialization/specialization-default-types.rs:29:5
   |
LL | fn trouble<T>(t: T) -> Box<T> {
   |                        ------ expected `Box<T>` because of return type
LL |     Example::generate(t) //~ ERROR mismatched types
   |     ^^^^^^^^^^^^^^^^^^^^ types differ
   |
   = note:       expected struct `Box<T>`
           found associated type `<T as Example>::Output`
   = help: consider constraining the associated type `<T as Example>::Output` to `Box<T>`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
   = note: the associated type `<T as Example>::Output` is defined as `Box<T>` in the implementation, but the generic bound `T` hides this definition

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0308`.
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants