Remove style() from AttributeExt trait

This commit is contained in:
David Tolnay
2025-06-20 11:52:24 -07:00
parent e51c37c34c
commit 86f40acce3
2 changed files with 12 additions and 24 deletions

View File

@@ -217,13 +217,13 @@ impl AttributeExt for Attribute {
_ => None,
}
}
fn style(&self) -> AttrStyle {
self.style
}
}
impl Attribute {
pub fn style(&self) -> AttrStyle {
self.style
}
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)
}
}

View File

@@ -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.