Skip to content

Conversation

@Jamesbarford
Copy link
Contributor

@Jamesbarford Jamesbarford commented Dec 2, 2025

r? ghost

Couple of issues I've encountered;

  • compiler/rustc_infer/src/infer/region_constraints/mod.rs GenericKind I can't call write!(f, "{p}") due to error 1. Which looks like I may need to implement Lift for Placeholder?
  • Using the define_print_and_forward_display! for ty::PlaceholderType caused error 2, as I've moved the struct it no longer exists in the crate. I suspect because I'm not using that macro it causes the error for GenericKind
Error 1
error: lifetime may not live long enough
   --> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:38
    |
668 | impl<'tcx> fmt::Display for GenericKind<'tcx> {
    |      ---- lifetime `'tcx` defined here
...
672 |             GenericKind::Placeholder(ref p) => write!(f, "{p}"),
    |                                      ^^^^^ assignment requires that `'tcx` must outlive `'static`
    |
    = note: requirement occurs because of the type `rustc_middle::ty::TyCtxt<'_>`, which makes the generic argument `'_` invariant
    = note: the struct `rustc_middle::ty::TyCtxt<'tcx>` is invariant over the parameter `'tcx`
    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error: implementation of `Lift` is not general enough
   --> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:38
    |
672 |             GenericKind::Placeholder(ref p) => write!(f, "{p}"),
    |                                      ^^^^^ implementation of `Lift` is not general enough
    |
    = note: `Lift<rustc_middle::ty::TyCtxt<'0>>` would have to be implemented for the type `rustc_type_ir::Placeholder<rustc_middle::ty::TyCtxt<'_>, BoundTy>`, for any lifetime `'0`...
    = note: ...but `Lift<rustc_middle::ty::TyCtxt<'1>>` is actually implemented for the type `rustc_type_ir::Placeholder<rustc_middle::ty::TyCtxt<'1>, BoundTy>`, for some specific lifetime `'1`

error: implementation of `Print` is not general enough
   --> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:38
    |
672 |             GenericKind::Placeholder(ref p) => write!(f, "{p}"),
    |                                      ^^^^^ implementation of `Print` is not general enough
Error 2
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
    --> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
     |
3057 | / macro_rules! forward_display_to_print {
3058 | |     ($($ty:ty),+) => {
3059 | |         // Some of the $ty arguments may not actually use 'tcx
3060 | |         $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
     | |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...    |
3072 | |     };
3073 | | }
     | |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | |     ty::Region<'tcx>,
3095 | |     Ty<'tcx>,
3096 | |     &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | |     ty::Const<'tcx>,
3098 | |     &'tcx ty::PlaceholderType<'tcx>
     | |     ------------------------------- `rustc_type_ir::Placeholder` is not defined in the current crate
3099 | | }
     | |_- in this macro invocation
     |
     = note: impl doesn't have any local type before any uncovered type parameters
     = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
     = note: define and implement a trait or new type instead

error: implementation of `Lift` is not general enough
    --> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
     |
3057 | / macro_rules! forward_display_to_print {
3058 | |     ($($ty:ty),+) => {
3059 | |         // Some of the $ty arguments may not actually use 'tcx
3060 | |         $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
     | |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Lift` is not general enough
...    |
3072 | |     };
3073 | | }
     | |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | |     ty::Region<'tcx>,
3095 | |     Ty<'tcx>,
3096 | |     &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | |     ty::Const<'tcx>,
3098 | |     &'tcx ty::PlaceholderType<'tcx>
3099 | | }
     | |_- in this macro invocation
     |
     = note: `Lift<context::TyCtxt<'0>>` would have to be implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'tcx>, BoundTy>`, for any lifetime `'0`...
     = note: ...but `Lift<context::TyCtxt<'1>>` is actually implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'1>, BoundTy>`, for some specific lifetime `'1`

error: implementation of `print::Print` is not general enough
    --> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
     |
3057 | / macro_rules! forward_display_to_print {
3058 | |     ($($ty:ty),+) => {
3059 | |         // Some of the $ty arguments may not actually use 'tcx
3060 | |         $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
     | |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `print::Print` is not general enough
...    |
3072 | |     };
3073 | | }
     | |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | |     ty::Region<'tcx>,
3095 | |     Ty<'tcx>,
3096 | |     &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | |     ty::Const<'tcx>,
3098 | |     &'tcx ty::PlaceholderType<'tcx>
3099 | | }
     | |_- in this macro invocation
     |
     = note: `print::Print<'0, print::pretty::FmtPrinter<'a, '0>>` would have to be implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'tcx>, BoundTy>`, for any lifetime `'0`...
     = note: ...but `print::Print<'1, print::pretty::FmtPrinter<'a, 'tcx>>` is actually implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'1>, BoundTy>`, for some specific lifetime `'1`

error: specializing impl repeats parameter `'tcx`
    --> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
     |
3057 | / macro_rules! forward_display_to_print {
3058 | |     ($($ty:ty),+) => {
3059 | |         // Some of the $ty arguments may not actually use 'tcx
3060 | |         $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
     | |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...    |
3072 | |     };
3073 | | }
     | |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | |     ty::Region<'tcx>,
3095 | |     Ty<'tcx>,
3096 | |     &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | |     ty::Const<'tcx>,
3098 | |     &'tcx ty::PlaceholderType<'tcx>
3099 | | }
     | |_- in this macro invocation

error[E0277]: the trait bound `&Placeholder<TyCtxt<'tcx>, BoundTy>: Lift<...>` is not satisfied
    --> compiler/rustc_middle/src/ty/print/pretty.rs:3064:30
     |
3057 | / macro_rules! forward_display_to_print {
3058 | |     ($($ty:ty),+) => {
3059 | |         // Some of the $ty arguments may not actually use 'tcx
3060 | |         $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
...    |
3064 | |                     tcx.lift(*self)
     | |                         ---- ^^^^^ unsatisfied trait bound
     | |                         |
     | |                         required by a bound introduced by this call
...    |
3072 | |     };
3073 | | }
     | |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | |     ty::Region<'tcx>,
3095 | |     Ty<'tcx>,
3096 | |     &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | |     ty::Const<'tcx>,
3098 | |     &'tcx ty::PlaceholderType<'tcx>
3099 | | }
     | |_- in this macro invocation
     |
     = help: the trait `Lift<context::TyCtxt<'_>>` is not implemented for `&rustc_type_ir::Placeholder<context::TyCtxt<'tcx>, BoundTy>`
note: required by a bound in `context::TyCtxt::<'tcx>::lift`
    --> compiler/rustc_middle/src/ty/context.rs:1807:20
     |
1807 |     pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
     |                    ^^^^^^^^^^^^^^^^^^ required by this bound in `TyCtxt::<'tcx>::lift`
     = note: the full name for the type has been written to '/home/jambar02/Documents/arm/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-16e5c44041028d8b.long-type-3843651570422266958.txt'
     = note: consider using `--verbose` to print the full type name to the console
help: consider dereferencing here
     |
3064 |                     tcx.lift(**self)
     |                              +

error[E0282]: type annotations needed
    --> compiler/rustc_middle/src/ty/print/pretty.rs:3064:21
     |
3057 | /  macro_rules! forward_display_to_print {
3058 | |      ($($ty:ty),+) => {
3059 | |          // Some of the $ty arguments may not actually use 'tcx
3060 | |          $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
...    |
3064 | |/                     tcx.lift(*self)
3065 | ||                         .expect("could not lift for printing")
     | ||______________________________________________________________^ cannot infer type
...    |
3072 | |      };
3073 | |  }
     | |__- in this expansion of `forward_display_to_print!`
...
3093 |  / forward_display_to_print! {
3094 |  |     ty::Region<'tcx>,
3095 |  |     Ty<'tcx>,
3096 |  |     &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 |  |     ty::Const<'tcx>,
3098 |  |     &'tcx ty::PlaceholderType<'tcx>
3099 |  | }
     |  |_- in this macro invocation

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 2, 2025
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford Jamesbarford force-pushed the chore/refactor-struct-placeholder branch from b0c34e1 to e9e240f Compare December 2, 2025 09:18
@Jamesbarford Jamesbarford force-pushed the chore/refactor-struct-placeholder branch from e9e240f to 31df95c Compare December 2, 2025 09:21
@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)
---- [ui] tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/non_lifetime_binders/bad-sized-cond/bad-sized-cond.stderr`
diff of stderr:

23 LL |     for<V> V: Sized,
24    |               ^^^^^ required by this bound in `foo`
25 
- error[E0277]: `V` is not an iterator
+ error[E0277]: `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)` is not an iterator
27   --> $DIR/bad-sized-cond.rs:20:5
28    |
29 LL |     bar();

-    |     ^^^^^ `V` is not an iterator
+    |     ^^^^^ `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)` is not an iterator
31    |
-    = help: the trait `Iterator` is not implemented for `V`
+    = help: the trait `Iterator` is not implemented for `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)`
33    = note: required for `V` to implement `IntoIterator`
34 note: required by a bound in `bar`
35   --> $DIR/bad-sized-cond.rs:12:15

40 LL |     for<V> V: IntoIterator,
41    |               ^^^^^^^^^^^^ required by this bound in `bar`
42 
- error[E0277]: the size for values of type `V` cannot be known at compilation time
+ error[E0277]: the size for values of type `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)` cannot be known at compilation time
44   --> $DIR/bad-sized-cond.rs:20:5
45    |
46 LL |     bar();

47    |     ^^^^^ doesn't have a size known at compile-time
48    |
-    = help: the trait `Sized` is not implemented for `V`
+    = help: the trait `Sized` is not implemented for `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)`
50    = note: required for `V` to implement `IntoIterator`
51 note: required by a bound in `bar`
52   --> $DIR/bad-sized-cond.rs:12:15


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 traits/non_lifetime_binders/bad-sized-cond.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/traits/non_lifetime_binders/bad-sized-cond.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/traits/non_lifetime_binders/bad-sized-cond" "-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 `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs:1:12
   |
---
  --> /checkout/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs:6:15
   |
LL | pub fn foo()
   |        --- required by a bound in this function
LL | where
LL |     for<V> V: Sized,
   |               ^^^^^ required by this bound in `foo`

error[E0277]: `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)` is not an iterator
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs:20:5
   |
LL |     bar();
   |     ^^^^^ `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)` is not an iterator
   |
   = help: the trait `Iterator` is not implemented for `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)`
   = note: required for `V` to implement `IntoIterator`
note: required by a bound in `bar`
  --> /checkout/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs:12:15
   |
LL | pub fn bar()
   |        --- required by a bound in this function
LL | where
LL |     for<V> V: IntoIterator,
   |               ^^^^^^^^^^^^ required by this bound in `bar`

error[E0277]: the size for values of type `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)` cannot be known at compilation time
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs:20:5
   |
LL |     bar();
   |     ^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `!3_DefId(0:6 ~ bad_sized_cond[f3a6]::bar::V)`
   = note: required for `V` to implement `IntoIterator`
note: required by a bound in `bar`
  --> /checkout/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs:12:15
   |
LL | pub fn bar()
   |        --- required by a bound in this function
LL | where
LL |     for<V> V: IntoIterator,
   |               ^^^^^^^^^^^^ required by this bound in `bar`

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

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

---- [ui] tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs stdout end ----
---- [ui] tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs#bad stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad/placeholders-dont-outlive-static.bad.stderr`
diff of stderr:

7    = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8    = note: `#[warn(incomplete_features)]` on by default
9 
- error[E0310]: the placeholder type `T` may not live long enough
+ error[E0310]: the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` may not live long enough
11   --> $DIR/placeholders-dont-outlive-static.rs:13:5
12    |
13 LL |     foo();

14    |     ^^^^^
15    |     |
-    |     the placeholder type `T` must be valid for the static lifetime...
-    |     ...so that the type `T` will meet its required lifetime bounds
+    |     the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` must be valid for the static lifetime...
+    |     ...so that the type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` will meet its required lifetime bounds
18    |
19 help: consider adding an explicit lifetime bound
20    |

- LL | fn bad() where T: 'static {
-    |          ++++++++++++++++
+ LL | fn bad() where !1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T): 'static {
+    |          +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 
24 error: aborting due to 1 previous error; 1 warning emitted
25 


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 traits/non_lifetime_binders/placeholders-dont-outlive-static.rs`

error in revision `bad`: 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/traits/non_lifetime_binders/placeholders-dont-outlive-static.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" "bad" "--check-cfg" "cfg(test,FALSE,good,bad)" "--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/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad" "-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 `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs:6:12
   |
LL | #![feature(non_lifetime_binders)]
   |            ^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
   = note: `#[warn(incomplete_features)]` on by default

error[E0310]: the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` may not live long enough
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs:13:5
   |
LL |     foo();
   |     ^^^^^
   |     |
   |     the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` must be valid for the static lifetime...
   |     ...so that the type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn bad() where !1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T): 'static {
   |          +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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

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

7    = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8    = note: `#[warn(incomplete_features)]` on by default
9 
- error[E0310]: the placeholder type `T` may not live long enough
+ error[E0310]: the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` may not live long enough
11   --> $DIR/placeholders-dont-outlive-static.rs:19:5
12    |
13 LL |     foo();

14    |     ^^^^^
15    |     |
-    |     the placeholder type `T` must be valid for the static lifetime...
-    |     ...so that the type `T` will meet its required lifetime bounds
+    |     the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` must be valid for the static lifetime...
+    |     ...so that the type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` will meet its required lifetime bounds
18    |
19 help: consider adding an explicit lifetime bound
20    |

- LL | fn good() where for<T> T: 'static, T: 'static {
-    |                                  ++++++++++++
+ LL | fn good() where for<T> T: 'static, !1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T): 'static {
+    |                                  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 
24 error: aborting due to 1 previous error; 1 warning emitted
25 


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 traits/non_lifetime_binders/placeholders-dont-outlive-static.rs`

error in revision `good`: 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/traits/non_lifetime_binders/placeholders-dont-outlive-static.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" "good" "--check-cfg" "cfg(test,FALSE,good,bad)" "--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/traits/non_lifetime_binders/placeholders-dont-outlive-static.good" "-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 `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs:6:12
   |
LL | #![feature(non_lifetime_binders)]
   |            ^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
   = note: `#[warn(incomplete_features)]` on by default

error[E0310]: the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` may not live long enough
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs:19:5
   |
LL |     foo();
   |     ^^^^^
   |     |
   |     the placeholder type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` must be valid for the static lifetime...
   |     ...so that the type `!1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T)` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL | fn good() where for<T> T: 'static, !1_DefId(0:4 ~ placeholders_dont_outlive_static[9c4a]::foo::T): 'static {
   |                                  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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

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

7    = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8    = note: `#[warn(incomplete_features)]` on by default
9 
- error[E0309]: the placeholder type `F` may not live long enough
+ error[E0309]: the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` may not live long enough
11   --> $DIR/type-match-with-late-bound.rs:8:1
12    |
13 LL |   async fn walk2<'a, T: 'a>(_: T)

-    |   ^              -- the placeholder type `F` must be valid for the lifetime `'a` as defined here...
+    |   ^              -- the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` must be valid for the lifetime `'a` as defined here...
15    |  _|
16    | |
17 LL | | where

18 LL | |     for<F> F: 'a,
-    | |_________________^ ...so that the type `F` will meet its required lifetime bounds...
+    | |_________________^ ...so that the type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` will meet its required lifetime bounds...
20    |
21 note: ...that is required by this bound
22   --> $DIR/type-match-with-late-bound.rs:10:15

25    |               ^^
26 help: consider adding an explicit lifetime bound
27    |
- LL |     for<F> F: 'a, F: 'a
-    |                   +++++
+ LL |     for<F> F: 'a, !1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F): 'a
+    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 
- error[E0309]: the placeholder type `F` may not live long enough
+ error[E0309]: the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` may not live long enough
32   --> $DIR/type-match-with-late-bound.rs:11:1
33    |
34 LL | async fn walk2<'a, T: 'a>(_: T)

-    |                -- the placeholder type `F` must be valid for the lifetime `'a` as defined here...
+    |                -- the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` must be valid for the lifetime `'a` as defined here...
36 ...
37 LL | {}
-    | ^^ ...so that the type `F` will meet its required lifetime bounds
+    | ^^ ...so that the type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` will meet its required lifetime bounds
39    |
40 help: consider adding an explicit lifetime bound
41    |

- LL |     for<F> F: 'a, F: 'a
-    |                   +++++
+ LL |     for<F> F: 'a, !1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F): 'a
+    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
44 
- error[E0309]: the placeholder type `F` may not live long enough
+ error[E0309]: the placeholder type `!2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` may not live long enough
46   --> $DIR/type-match-with-late-bound.rs:11:1
47    |
48 LL | async fn walk2<'a, T: 'a>(_: T)

-    |                -- the placeholder type `F` must be valid for the lifetime `'a` as defined here...
+    |                -- the placeholder type `!2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` must be valid for the lifetime `'a` as defined here...
50 ...
51 LL | {}
-    | ^^ ...so that the type `F` will meet its required lifetime bounds
+    | ^^ ...so that the type `!2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` will meet its required lifetime bounds
53    |
-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
55 help: consider adding an explicit lifetime bound
56    |
- LL |     for<F> F: 'a, F: 'a
-    |                   +++++
+ LL |     for<F> F: 'a, !2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F): 'a
+    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59 
60 error: aborting due to 3 previous errors; 1 warning emitted
61 


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 traits/non_lifetime_binders/type-match-with-late-bound.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/traits/non_lifetime_binders/type-match-with-late-bound.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/traits/non_lifetime_binders/type-match-with-late-bound" "-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" "--edition=2021"
stdout: none
--- stderr -------------------------------
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
##[warning]  --> /checkout/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs:6:12
   |
LL | #![feature(non_lifetime_binders)]
   |            ^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
   = note: `#[warn(incomplete_features)]` on by default

error[E0309]: the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` may not live long enough
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs:8:1
   |
LL |   async fn walk2<'a, T: 'a>(_: T)
   |   ^              -- the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` must be valid for the lifetime `'a` as defined here...
   |  _|
   | |
LL | | where
LL | |     for<F> F: 'a,
   | |_________________^ ...so that the type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` will meet its required lifetime bounds...
   |
note: ...that is required by this bound
  --> /checkout/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs:10:15
   |
LL |     for<F> F: 'a,
   |               ^^
help: consider adding an explicit lifetime bound
   |
LL |     for<F> F: 'a, !1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F): 'a
   |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0309]: the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` may not live long enough
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs:11:1
   |
LL | async fn walk2<'a, T: 'a>(_: T)
   |                -- the placeholder type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` must be valid for the lifetime `'a` as defined here...
...
LL | {}
   | ^^ ...so that the type `!1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     for<F> F: 'a, !1_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F): 'a
   |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0309]: the placeholder type `!2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` may not live long enough
##[error]  --> /checkout/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs:11:1
   |
LL | async fn walk2<'a, T: 'a>(_: T)
   |                -- the placeholder type `!2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` must be valid for the lifetime `'a` as defined here...
...
LL | {}
   | ^^ ...so that the type `!2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F)` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     for<F> F: 'a, !2_DefId(0:6 ~ type_match_with_late_bound[266d]::walk2::F): 'a
   |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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

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

@lcnr
Copy link
Contributor

lcnr commented Dec 2, 2025

  • compiler/rustc_infer/src/infer/region_constraints/mod.rs GenericKind I can't call write!(f, "{p}") due to error 1. Which looks like I may need to implement Lift for Placeholder?

Using Display should be totally fine here unless the Display impl for Placeholder is wrong 🤔

The IrPrint impl used is

impl<T> rustc_type_ir::ir_print::IrPrint<T> for TyCtxt<'_>
where
    T: Copy + for<'a, 'tcx> Lift<TyCtxt<'tcx>, Lifted: Print<'tcx, FmtPrinter<'a, 'tcx>>>,

Yeah, it's the Lift impl currently in TrivialTypeTraversalAndLiftImpls! for PlaceholderType. You probably have to copy the manual lift impl of Binder

  • Using the define_print_and_forward_display! for ty::PlaceholderType caused error 2, as I've moved the struct it no longer exists in the crate. I suspect because I'm not using that macro it causes the error for GenericKind

Yeah, you should instead only use define_print as we've manually written the forward impl in rustc_type_ir

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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