diff options
| -rw-r--r-- | compiler/rustc_ast/src/attr/mod.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 22 |
2 files changed, 11 insertions, 23 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 755bd3577ea..44865c493b3 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -217,13 +217,13 @@ impl AttributeExt for Attribute { _ => None, } } +} - fn style(&self) -> AttrStyle { +impl Attribute { + pub fn style(&self) -> AttrStyle { self.style } -} -impl Attribute { pub fn may_have_doc_links(&self) -> bool { self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str())) } @@ -826,8 +826,6 @@ pub trait AttributeExt: Debug { /// commented module (for inner doc) vs within its parent module (for outer /// doc). fn doc_resolution_scope(&self) -> Option<AttrStyle>; - - fn style(&self) -> AttrStyle; } // FIXME(fn_delegation): use function delegation instead of manually forwarding @@ -902,8 +900,4 @@ impl Attribute { pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> { AttributeExt::doc_str_and_comment_kind(self) } - - pub fn style(&self) -> AttrStyle { - AttributeExt::style(self) - } } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 883161318d3..73ece05377c 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1207,6 +1207,14 @@ pub enum Attribute { } impl Attribute { + pub fn style(&self) -> AttrStyle { + match &self { + Attribute::Unparsed(u) => u.style, + Attribute::Parsed(AttributeKind::DocComment { style, .. }) => *style, + _ => panic!(), + } + } + pub fn get_normal_item(&self) -> &AttrItem { match &self { Attribute::Unparsed(normal) => &normal, @@ -1355,15 +1363,6 @@ impl AttributeExt for Attribute { _ => None, } } - - #[inline] - fn style(&self) -> AttrStyle { - match &self { - Attribute::Unparsed(u) => u.style, - Attribute::Parsed(AttributeKind::DocComment { style, .. }) => *style, - _ => panic!(), - } - } } // FIXME(fn_delegation): use function delegation instead of manually forwarding @@ -1452,11 +1451,6 @@ impl Attribute { pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> { AttributeExt::doc_str_and_comment_kind(self) } - - #[inline] - pub fn style(&self) -> AttrStyle { - AttributeExt::style(self) - } } /// Attributes owned by a HIR owner. |
