You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggest adding & when a lifetime immediately precedes a type in a generic arg list #59325
the compiler could suggest adding a & before the lifetime. This can be more useful in a generic parameter, where a high concentration of special characters makes it easy to not notice the mistake:
fnfoo(bar:&mutHashSet<'static SomeStruct>){ ...}
Currently, the error message is just expected one of `,` or `>`, found `SomeStruct` .
I didn't know about this issue but I fixed it in PR #139854 a year ago.
The compiler output now looks like this for your snippet:
error: expected type, found lifetime
--> src/lib.rs:1:13
|
1 | fn foo(bar:'staticSomeStruct){}
| ^^^^^^^ expected type
|
help: you might have meant to write a reference type here
|
1 | fn foo(bar:&'static SomeStruct){}
| +
changed the title [-]Suggest & when a lifetime precedes a type.[/-][+]Suggest adding `&` when a lifetime immediately precedes a type in a generic arg list[/+]on Sep 20, 2026
Activity
fmease commentedon Sep 20, 2026
I didn't know about this issue but I fixed it in PR #139854 a year ago.
The compiler output now looks like this for your snippet:
[-]Suggest & when a lifetime precedes a type.[/-][+]Suggest adding `&` when a lifetime immediately precedes a type in a generic arg list[/+]fmease commentedon Sep 20, 2026
Ah but your 2nd example has not been addressed.
Rollup merge of rust-lang#163454 - Tehforsch:fix-lifetime-preceding-t…
Unrolled build for #163454 in rollup 163695