Open
Description
I hope this is a genuine bug and not just working as intended🙈
I tried this code:
trait Assoc {
type Type;
}
trait Static: 'static {
type Same<T>: Assoc<Type: Static>;
}
I expected to see this happen: The code compiles.
Instead, this happened: The code produces the following compile error:
error[E0310]: the associated type `<<Self as Static>::Same<T> as Assoc>::Type` may not live long enough
--> src/lib.rs:6:28
|
6 | type Same<T>: Assoc<Type: Static>;
| ^^^^^^
| |
| the associated type `<<Self as Static>::Same<T> as Assoc>::Type` must be valid for the static lifetime...
| ...so that the type `<<Self as Static>::Same<T> as Assoc>::Type` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> src/lib.rs:5:15
|
5 | trait Static: 'static {
| ^^^^^^^
help: consider adding an explicit lifetime bound
|
6 | type Same<T>: Assoc<Type: Static> where <<Self as Static>::Same<T> as Assoc>::Type: 'static;
|
Note that either removing <T>
or replacing it with <T: 'static>
makes the error go away.
Meta
rustc --version --verbose
:
rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5
Also persists on latest nightly:
rustc 1.86.0-nightly (f85c6de55 2025-01-26)
binary: rustc
commit-hash: f85c6de55206dbee5ffedfd821df1503a7b92346
commit-date: 2025-01-26
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7