I was cross-building a new project for the first time and ran into an unexpected error, since it is only reported on one(!) Tier 1 target.
I tried this code:
use std::cell::RefCell;
use std::marker::PhantomData;
pub(crate) struct ThreadContext<'a, 'w: 'a, 's> {
_foo: PhantomData<&'w str>,
_bar: PhantomData<&'s str>,
_baz: PhantomData<&'a str>,
}
thread_local! {
pub(crate) static THREAD_CONTEXT_CELL: RefCell<ThreadContext> = const {
RefCell::new(ThreadContext { _foo: PhantomData, _bar: PhantomData, _baz: PhantomData })
};
}
fn main() { let _ = THREAD_CONTEXT_CELL.with_borrow(|_| {}); }
I expected to see this build without errors, as it does under x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc, aarch64-apple-darwin (and maybe others?).
Instead, this happened, only when building for x86_64-pc-windows-gnu:
error[E0106]: missing lifetime specifiers
--> src/main.rs:16:63
|
16 | pub(crate) static THREAD_CONTEXT_CELL: RefCell<Option<ThreadContext>> = const {
| ^^^^^^^^^^^^^ expected 3 lifetime parameters
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
16 | pub(crate) static THREAD_CONTEXT_CELL: RefCell<Option<ThreadContext<'static, 'static, 'static>>> = const {
| +++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0106`.
error: could not compile `bug-lifetime-report` (bin "bug-lifetime-report") due to 1 previous error
Meta
rustc --version --verbose:
rustc 1.97.1 (8bab26f4f 2026-07-14)
binary: rustc
commit-hash: 8bab26f4f68e0e26f0bb7960be334d5b520ea452
commit-date: 2026-07-14
host: x86_64-unknown-linux-gnu
release: 1.97.1
LLVM version: 22.1.6
Also reproducible on nightly:
rustc 1.99.0-nightly (b6839f4d0 2026-07-17)
binary: rustc
commit-hash: b6839f4d0e2bd63b960bbff8619c6fdea27d81e5
commit-date: 2026-07-17
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
I was cross-building a new project for the first time and ran into an unexpected error, since it is only reported on one(!) Tier 1 target.
I tried this code:
I expected to see this build without errors, as it does under
x86_64-unknown-linux-gnu,x86_64-pc-windows-msvc,aarch64-apple-darwin(and maybe others?).Instead, this happened, only when building for
x86_64-pc-windows-gnu:Meta
rustc --version --verbose:Also reproducible on nightly: