File tree 2 files changed +16
-7
lines changed
2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -206,8 +206,8 @@ impl AttributeExt for Attribute {
206
206
}
207
207
}
208
208
209
- fn style ( & self ) -> AttrStyle {
210
- self . style
209
+ fn opt_style ( & self ) -> Option < AttrStyle > {
210
+ Some ( self . style )
211
211
}
212
212
}
213
213
@@ -806,7 +806,11 @@ pub trait AttributeExt: Debug {
806
806
/// * `#[doc(...)]` returns `None`.
807
807
fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > ;
808
808
809
- fn style ( & self ) -> AttrStyle ;
809
+ fn style ( & self ) -> AttrStyle {
810
+ self . opt_style ( ) . unwrap ( )
811
+ }
812
+
813
+ fn opt_style ( & self ) -> Option < AttrStyle > ;
810
814
}
811
815
812
816
// FIXME(fn_delegation): use function delegation instead of manually forwarding
Original file line number Diff line number Diff line change @@ -1245,11 +1245,11 @@ impl AttributeExt for Attribute {
1245
1245
}
1246
1246
1247
1247
#[ inline]
1248
- fn style ( & self ) -> AttrStyle {
1248
+ fn opt_style ( & self ) -> Option < AttrStyle > {
1249
1249
match & self {
1250
- Attribute :: Unparsed ( u) => u. style ,
1251
- Attribute :: Parsed ( AttributeKind :: DocComment { style, .. } ) => * style,
1252
- _ => panic ! ( ) ,
1250
+ Attribute :: Unparsed ( u) => Some ( u. style ) ,
1251
+ Attribute :: Parsed ( AttributeKind :: DocComment { style, .. } ) => Some ( * style) ,
1252
+ _ => None ,
1253
1253
}
1254
1254
}
1255
1255
}
@@ -1345,6 +1345,11 @@ impl Attribute {
1345
1345
pub fn style ( & self ) -> AttrStyle {
1346
1346
AttributeExt :: style ( self )
1347
1347
}
1348
+
1349
+ #[ inline]
1350
+ pub fn opt_style ( & self ) -> Option < AttrStyle > {
1351
+ AttributeExt :: opt_style ( self )
1352
+ }
1348
1353
}
1349
1354
1350
1355
/// Attributes owned by a HIR owner.
You can’t perform that action at this time.
0 commit comments