Skip to content

Commit 1b5f969

Browse files
committed
Remove style() from AttributeExt trait
1 parent 10f1cc4 commit 1b5f969

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ impl AttributeExt for Attribute {
205205
_ => None,
206206
}
207207
}
208+
}
208209

209-
fn style(&self) -> AttrStyle {
210+
impl Attribute {
211+
pub fn style(&self) -> AttrStyle {
210212
self.style
211213
}
212-
}
213214

214-
impl Attribute {
215215
pub fn may_have_doc_links(&self) -> bool {
216216
self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str()))
217217
}
@@ -805,8 +805,6 @@ pub trait AttributeExt: Debug {
805805
/// * `#[doc = "doc"]` returns `Some(("doc", CommentKind::Line))`.
806806
/// * `#[doc(...)]` returns `None`.
807807
fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)>;
808-
809-
fn style(&self) -> AttrStyle;
810808
}
811809

812810
// FIXME(fn_delegation): use function delegation instead of manually forwarding
@@ -881,8 +879,4 @@ impl Attribute {
881879
pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> {
882880
AttributeExt::doc_str_and_comment_kind(self)
883881
}
884-
885-
pub fn style(&self) -> AttrStyle {
886-
AttributeExt::style(self)
887-
}
888882
}

compiler/rustc_hir/src/hir.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,14 @@ pub enum Attribute {
12071207
}
12081208

12091209
impl Attribute {
1210+
pub fn style(&self) -> AttrStyle {
1211+
match &self {
1212+
Attribute::Unparsed(u) => u.style,
1213+
Attribute::Parsed(AttributeKind::DocComment { style, .. }) => *style,
1214+
_ => panic!(),
1215+
}
1216+
}
1217+
12101218
pub fn get_normal_item(&self) -> &AttrItem {
12111219
match &self {
12121220
Attribute::Unparsed(normal) => &normal,
@@ -1344,15 +1352,6 @@ impl AttributeExt for Attribute {
13441352
_ => None,
13451353
}
13461354
}
1347-
1348-
#[inline]
1349-
fn style(&self) -> AttrStyle {
1350-
match &self {
1351-
Attribute::Unparsed(u) => u.style,
1352-
Attribute::Parsed(AttributeKind::DocComment { style, .. }) => *style,
1353-
_ => panic!(),
1354-
}
1355-
}
13561355
}
13571356

13581357
// FIXME(fn_delegation): use function delegation instead of manually forwarding
@@ -1441,11 +1440,6 @@ impl Attribute {
14411440
pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> {
14421441
AttributeExt::doc_str_and_comment_kind(self)
14431442
}
1444-
1445-
#[inline]
1446-
pub fn style(&self) -> AttrStyle {
1447-
AttributeExt::style(self)
1448-
}
14491443
}
14501444

14511445
/// Attributes owned by a HIR owner.

compiler/rustc_resolve/src/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<Box<str>, MalformedGen
355355
///
356356
/// If there are no doc-comments, return true.
357357
/// FIXME(#78591): Support both inner and outer attributes on the same item.
358-
pub fn inner_docs(attrs: &[impl AttributeExt]) -> bool {
358+
pub(crate) fn inner_docs(attrs: &[ast::Attribute]) -> bool {
359359
attrs.iter().find(|a| a.doc_str().is_some()).is_none_or(|a| a.style() == ast::AttrStyle::Inner)
360360
}
361361

0 commit comments

Comments
 (0)