-
Notifications
You must be signed in to change notification settings - Fork 13.6k
print raw lifetime idents with r# #144897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
print raw lifetime idents with r# #144897
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
This PR modifies |
compiler/rustc_span/src/symbol.rs
Outdated
if let Some(ident) = self.as_raw_lifetime_name_without_apostrophe() { | ||
write!(f, "'{}", IdentPrinter::new(ident.name, true, None)) | ||
} else { | ||
fmt::Display::fmt(&IdentPrinter::new(self.name, self.is_raw_guess(), None), f) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not a change in IdentPrinter
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you propose us to make the check in IdentPrinter
? It doesn't know about editions because it only accepts the symbol. is_raw_guess
and as_raw_lifetime_name_without_apostrophe
both need the span edition to know whether some identifier is treated as a keyword or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it could accept edition as a parameter? otherwise I'm not sure what's even the point of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise I'm not sure what's even the point of it
Just looked at the code again. IdentPrinter is used from two general places. One where one has the token data (sorta at the parsing/ast/proc macro stage) in which rawness of idents are known and do not need to be guessed, and one at a later stage where they do. that's why rawness was originally passed as a bool. To improve the design as you highlighted I chose to change the original bool into an enum, but we still have to guess whether a raw lifetime should be printed here and not inside IdentPrinter.
This comment has been minimized.
This comment has been minimized.
5805f0a
to
9705706
Compare
| | ||
help: consider introducing lifetime `'r#fn` here | ||
| | ||
LL | fn a<'fn>(_: dyn Trait + 'r#fn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't actually sugg 'r#fn
here and one and two below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh.... that must have changed between my blesses or smth. Will take a look
9705706
to
b74a97e
Compare
This replaces #143185 and fixes #143150
cc @fmease