File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -206,8 +206,8 @@ impl AttributeExt for Attribute {
206206 }
207207 }
208208
209- fn style ( & self ) -> AttrStyle {
210- self . style
209+ fn opt_style ( & self ) -> Option < AttrStyle > {
210+ Some ( self . style )
211211 }
212212}
213213
@@ -806,7 +806,14 @@ pub trait AttributeExt: Debug {
806806 /// * `#[doc(...)]` returns `None`.
807807 fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > ;
808808
809- fn style ( & self ) -> AttrStyle ;
809+ fn style ( & self ) -> AttrStyle {
810+ match self . opt_style ( ) {
811+ Some ( style) => style,
812+ None => panic ! ( "AttributeExt::style: `{self:?}` has no style" ) ,
813+ }
814+ }
815+
816+ fn opt_style ( & self ) -> Option < AttrStyle > ;
810817}
811818
812819// 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 {
12451245 }
12461246
12471247 #[ inline]
1248- fn style ( & self ) -> AttrStyle {
1248+ fn opt_style ( & self ) -> Option < AttrStyle > {
12491249 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 ,
12531253 }
12541254 }
12551255}
@@ -1345,6 +1345,11 @@ impl Attribute {
13451345 pub fn style ( & self ) -> AttrStyle {
13461346 AttributeExt :: style ( self )
13471347 }
1348+
1349+ #[ inline]
1350+ pub fn opt_style ( & self ) -> Option < AttrStyle > {
1351+ AttributeExt :: opt_style ( self )
1352+ }
13481353}
13491354
13501355/// Attributes owned by a HIR owner.
You can’t perform that action at this time.
0 commit comments