Use token::Lit
in ast::ExprKind::Lit
.
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
This commit is contained in:
parent
01760265cb
commit
358a603f11
45 changed files with 701 additions and 581 deletions
|
@ -373,8 +373,12 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
|||
}
|
||||
|
||||
fn print_literal(&mut self, lit: &ast::Lit) {
|
||||
self.maybe_print_comment(lit.span.lo());
|
||||
self.word(lit.token_lit.to_string())
|
||||
self.print_token_literal(lit.token_lit, lit.span)
|
||||
}
|
||||
|
||||
fn print_token_literal(&mut self, token_lit: token::Lit, span: Span) {
|
||||
self.maybe_print_comment(span.lo());
|
||||
self.word(token_lit.to_string())
|
||||
}
|
||||
|
||||
fn print_string(&mut self, st: &str, style: ast::StrStyle) {
|
||||
|
@ -1735,7 +1739,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
ast::Extern::Explicit(abi, _) => {
|
||||
self.word_nbsp("extern");
|
||||
self.print_literal(&abi.as_lit());
|
||||
self.print_token_literal(abi.as_token_lit(), abi.span);
|
||||
self.nbsp();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue