rustc: Correctly pretty-print macro delimiters
This commit updates the `Mac_` AST structure to keep track of the delimiters that it originally had for its invocation. This allows us to faithfully pretty-print macro invocations not using parentheses (e.g. `vec![...]`). This in turn helps procedural macros due to #43081. Closes #50840
This commit is contained in:
@@ -1239,9 +1239,17 @@ pub type Mac = Spanned<Mac_>;
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct Mac_ {
|
||||
pub path: Path,
|
||||
pub delim: MacDelimiter,
|
||||
pub tts: ThinTokenStream,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum MacDelimiter {
|
||||
Parenthesis,
|
||||
Bracket,
|
||||
Brace,
|
||||
}
|
||||
|
||||
impl Mac_ {
|
||||
pub fn stream(&self) -> TokenStream {
|
||||
self.tts.clone().into()
|
||||
|
||||
Reference in New Issue
Block a user