pprust: Do not convert attributes into `MetaItem`s for printing
Fixes https://github.com/rust-lang/rust/issues/62628
This commit is contained in:
parent
160c40bc88
commit
75896011dc
|
@ -617,21 +617,17 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
|
|||
ast::AttrStyle::Outer => self.word("#["),
|
||||
}
|
||||
self.ibox(0);
|
||||
if let Some(mi) = attr.meta() {
|
||||
self.print_meta_item(&mi);
|
||||
} else {
|
||||
match attr.tokens.trees().next() {
|
||||
Some(TokenTree::Delimited(_, delim, tts)) => {
|
||||
self.print_mac_common(
|
||||
Some(&attr.path), false, None, delim, tts, true, attr.span
|
||||
);
|
||||
}
|
||||
tree => {
|
||||
self.print_path(&attr.path, false, 0);
|
||||
if tree.is_some() {
|
||||
self.space();
|
||||
self.print_tts(attr.tokens.clone(), true);
|
||||
}
|
||||
match attr.tokens.trees().next() {
|
||||
Some(TokenTree::Delimited(_, delim, tts)) => {
|
||||
self.print_mac_common(
|
||||
Some(&attr.path), false, None, delim, tts, true, attr.span
|
||||
);
|
||||
}
|
||||
tree => {
|
||||
self.print_path(&attr.path, false, 0);
|
||||
if tree.is_some() {
|
||||
self.space();
|
||||
self.print_tts(attr.tokens.clone(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#![feature(rustc_attrs)]
|
||||
|
||||
fn main() {
|
||||
#![rustc_dummy("hi", 1, 2, 1.012, pi = 3.14, bye, name("John"))]
|
||||
#![rustc_dummy("hi" , 1 , 2 , 1.012 , pi = 3.14 , bye , name ("John"))]
|
||||
#[rustc_dummy = 8]
|
||||
fn f() { }
|
||||
|
||||
#[rustc_dummy(1, 2, 3)]
|
||||
#[rustc_dummy(1 , 2 , 3)]
|
||||
fn g() { }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// Keywords in attribute paths are printed as raw idents,
|
||||
// but keywords in attribute arguments are not.
|
||||
|
||||
// pp-exact
|
||||
|
||||
#[rustfmt::r#final(final)]
|
||||
fn main() { }
|
Loading…
Reference in New Issue