@@ -26,7 +26,7 @@ pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
26
26
27
27
pub ( crate ) fn get_span_without_attrs ( stmt : & ast:: Stmt ) -> Span {
28
28
match stmt. kind {
29
- ast:: StmtKind :: Local ( ref local) => local. span ,
29
+ ast:: StmtKind :: Let ( ref local) => local. span ,
30
30
ast:: StmtKind :: Item ( ref item) => item. span ,
31
31
ast:: StmtKind :: Expr ( ref expr) | ast:: StmtKind :: Semi ( ref expr) => expr. span ,
32
32
ast:: StmtKind :: MacCall ( ref mac_stmt) => mac_stmt. mac . span ( ) ,
@@ -353,10 +353,18 @@ impl Rewrite for ast::Attribute {
353
353
354
354
// 1 = `[`
355
355
let shape = shape. offset_left ( prefix. len ( ) + 1 ) ?;
356
- Some (
357
- meta. rewrite ( context, shape)
358
- . map_or_else ( || snippet. to_owned ( ) , |rw| format ! ( "{}[{}]" , prefix, rw) ) ,
359
- )
356
+ Some ( meta. rewrite ( context, shape) . map_or_else (
357
+ || snippet. to_owned ( ) ,
358
+ |rw| match & self . kind {
359
+ ast:: AttrKind :: Normal ( normal_attr) => match normal_attr. item . unsafety {
360
+ // For #![feature(unsafe_attributes)]
361
+ // See https://github.com/rust-lang/rust/issues/123757
362
+ ast:: Safety :: Unsafe ( _) => format ! ( "{}[unsafe({})]" , prefix, rw) ,
363
+ _ => format ! ( "{}[{}]" , prefix, rw) ,
364
+ } ,
365
+ _ => format ! ( "{}[{}]" , prefix, rw) ,
366
+ } ,
367
+ ) )
360
368
} else {
361
369
Some ( snippet. to_owned ( ) )
362
370
}
0 commit comments