@@ -1346,12 +1346,13 @@ impl AttributeExt for Attribute {
1346
1346
}
1347
1347
}
1348
1348
1349
- #[ inline]
1350
- fn style ( & self ) -> AttrStyle {
1351
- match & self {
1352
- Attribute :: Unparsed ( u) => u. style ,
1353
- Attribute :: Parsed ( AttributeKind :: DocComment { style, .. } ) => * style,
1354
- _ => panic ! ( ) ,
1349
+ fn doc_resolution_scope ( & self ) -> Option < AttrStyle > {
1350
+ match self {
1351
+ Attribute :: Parsed ( AttributeKind :: DocComment { style, .. } ) => Some ( * style) ,
1352
+ Attribute :: Unparsed ( attr) if self . has_name ( sym:: doc) && self . value_str ( ) . is_some ( ) => {
1353
+ Some ( attr. style )
1354
+ }
1355
+ _ => None ,
1355
1356
}
1356
1357
}
1357
1358
}
@@ -1442,11 +1443,6 @@ impl Attribute {
1442
1443
pub fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > {
1443
1444
AttributeExt :: doc_str_and_comment_kind ( self )
1444
1445
}
1445
-
1446
- #[ inline]
1447
- pub fn style ( & self ) -> AttrStyle {
1448
- AttributeExt :: style ( self )
1449
- }
1450
1446
}
1451
1447
1452
1448
/// Attributes owned by a HIR owner.
@@ -2286,16 +2282,9 @@ pub struct Expr<'hir> {
2286
2282
}
2287
2283
2288
2284
impl Expr < ' _ > {
2289
- pub fn precedence (
2290
- & self ,
2291
- for_each_attr : & dyn Fn ( HirId , & mut dyn FnMut ( & Attribute ) ) ,
2292
- ) -> ExprPrecedence {
2285
+ pub fn precedence ( & self , has_attr : & dyn Fn ( HirId ) -> bool ) -> ExprPrecedence {
2293
2286
let prefix_attrs_precedence = || -> ExprPrecedence {
2294
- let mut has_outer_attr = false ;
2295
- for_each_attr ( self . hir_id , & mut |attr : & Attribute | {
2296
- has_outer_attr |= matches ! ( attr. style( ) , AttrStyle :: Outer )
2297
- } ) ;
2298
- if has_outer_attr { ExprPrecedence :: Prefix } else { ExprPrecedence :: Unambiguous }
2287
+ if has_attr ( self . hir_id ) { ExprPrecedence :: Prefix } else { ExprPrecedence :: Unambiguous }
2299
2288
} ;
2300
2289
2301
2290
match & self . kind {
@@ -2351,7 +2340,7 @@ impl Expr<'_> {
2351
2340
| ExprKind :: Use ( ..)
2352
2341
| ExprKind :: Err ( _) => prefix_attrs_precedence ( ) ,
2353
2342
2354
- ExprKind :: DropTemps ( expr, ..) => expr. precedence ( for_each_attr ) ,
2343
+ ExprKind :: DropTemps ( expr, ..) => expr. precedence ( has_attr ) ,
2355
2344
}
2356
2345
}
2357
2346
0 commit comments