I tried the following code (based on this test file):
#![feature(decl_macro)]
macro lifetime_hygiene($f:ident<$a:lifetime>) {
#[allow(unused_lifetimes, dead_code)]
fn $f<$a, 'a>() {
let _: &'_ () = &();
let _: &'static str = "";
}
}
lifetime_hygiene!(f<'a>);
and wanted to expand the file with -Zunpretty=expanded,hygiene.
Steps to Reproduce
- Save the code above to a file (e.g.,
test.rs)
- Run
rustc -Zunpretty=expanded,hygiene test.rs
- Observe the output
Expected Behavior
#[allow /* 370#4 */(unused_lifetimes, dead_code)]
fn f /* 917#0 */<'a /* 2538#0 */, 'a /* 2538#1 */>() {
let _: &'_ /* 56 */ () = &();
let _: &'static /* 55 */ str /* 2104#4 */ = "";
}
The two lifetimes called 'a would have "hygiene comments" making it clear these were different lifetimes (to the compiler).
Actual Behavior
#[allow /* 370#4 */(unused_lifetimes, dead_code)]
fn f /* 917#0 */<'a /* 2538 */, 'a /* 2538 */>() {
let _: &'_ /* 56 */ () = &();
let _: &'static /* 55 */ str /* 2104#4 */ = "";
}
We did not get the "hygiene comments" on the 'a, so we cannot tell that rustc thinks these are different lifetimes.
Key difference: Expected /* 2538#0 */ and /* 2538#1 */ (with distinct suffixes), but got /* 2538 */ for both (no suffix to distinguish them).
Meta
rustc --version --verbose:
rustc 1.95.0-nightly (873d4682c 2026-01-25)
binary: rustc
commit-hash: 873d4682c7d285540b8f28bfe637006cef8918a6
commit-date: 2026-01-25
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
I tried the following code (based on this test file):
and wanted to expand the file with
-Zunpretty=expanded,hygiene.Steps to Reproduce
test.rs)rustc -Zunpretty=expanded,hygiene test.rsExpected Behavior
The two lifetimes called
'awould have "hygiene comments" making it clear these were different lifetimes (to the compiler).Actual Behavior
We did not get the "hygiene comments" on the
'a, so we cannot tell thatrustcthinks these are different lifetimes.Key difference: Expected
/* 2538#0 */and/* 2538#1 */(with distinct suffixes), but got/* 2538 */for both (no suffix to distinguish them).Meta
rustc --version --verbose: