about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-10-26 13:33:36 +0200
committerUrgau <urgau@numericable.fr>2024-10-26 13:33:36 +0200
commitf5b6f938cec70d7b6ef3681217ad4c1d84e597e0 (patch)
treedd0b94c533c37123417968620a5d0f8fdfab3059 /compiler
parentf249fdd9621ab1dd65904c46f5db634c2b677da6 (diff)
downloadrust-f5b6f938cec70d7b6ef3681217ad4c1d84e597e0.tar.gz
rust-f5b6f938cec70d7b6ef3681217ad4c1d84e597e0.zip
Print unsafety of attribute in AST unpretty
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs
index 2cdec2138ad..1e18f0779f0 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state.rs
@@ -627,6 +627,13 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
 
     fn print_attr_item(&mut self, item: &ast::AttrItem, span: Span) {
         self.ibox(0);
+        match item.unsafety {
+            ast::Safety::Unsafe(_) => {
+                self.word("unsafe");
+                self.popen();
+            }
+            ast::Safety::Default | ast::Safety::Safe(_) => {}
+        }
         match &item.args {
             AttrArgs::Delimited(DelimArgs { dspan: _, delim, tokens }) => self.print_mac_common(
                 Some(MacHeader::Path(&item.path)),
@@ -655,6 +662,10 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
                 self.word(token_str);
             }
         }
+        match item.unsafety {
+            ast::Safety::Unsafe(_) => self.pclose(),
+            ast::Safety::Default | ast::Safety::Safe(_) => {}
+        }
         self.end();
     }