Skip to content

Remove AttributeExt#155041

Draft
mejrs wants to merge 1 commit intorust-lang:mainfrom
mejrs:nix_attributeext
Draft

Remove AttributeExt#155041
mejrs wants to merge 1 commit intorust-lang:mainfrom
mejrs:nix_attributeext

Conversation

@mejrs
Copy link
Copy Markdown
Contributor

@mejrs mejrs commented Apr 9, 2026

Part of #131229 (comment)

Removes AttributeExt, turning some of its methods into inherent methods where necessary.

I had to choose between fn is_doc_comment(&self) -> Option<Span> (trait) and fn is_doc_comment(&self) -> bool (inherent). I chose the latter because nothing is actually using the span.

This PR does not make further changes as

  • that changes many files and would be very prone to merge conflicts
  • many places that call methods like path and name are subtly wrong and IMO should be fixed in standalone prs.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 9, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, parser
  • compiler, parser expanded to 69 candidates
  • Random selection from 12 candidates

!attr.is_doc_comment()
// FIXME(jdonszelmann) have a better way to handle ignored attrs
&& !attr.name().is_some_and(|ident| is_ignored_attr(ident))
})
Copy link
Copy Markdown
Contributor Author

@mejrs mejrs Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

This is an example of one of those "subtly wrong" places. #154924 will take care of it.

@rust-log-analyzer

This comment has been minimized.

@mejrs mejrs force-pushed the nix_attributeext branch from 666cd1b to 3f450b5 Compare April 9, 2026 14:26
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
     | ^^^^^^^^^^^^^^^^^^^^
note: function defined here
    --> compiler/rustc_resolve/src/rustdoc.rs:358:8
     |
 358 | pub fn inner_docs(attrs: &[ast::Attribute]) -> bool {
     |        ^^^^^^^^^^

error[E0271]: expected `impl Iterator<Item = (&'a hir::Attribute, Option<DefId>)>` to be an iterator that yields `(&Attribute, Option<DefId>)`, but it yields `(&Attribute, Option<DefId>)`
    --> src/librustdoc/clean/types.rs:1066:65
     |
1066 |         let (doc_strings, other_attrs) = attrs_to_doc_fragments(attrs, doc_only);
     |                                          ---------------------- ^^^^^ expected `rustc_ast::Attribute`, found `rustc_hir::Attribute`
     |                                          |
     |                                          required by a bound introduced by this call
     |
     = note: `rustc_hir::Attribute` and `rustc_ast::Attribute` have similar names, but are actually distinct types
---
    --> compiler/rustc_resolve/src/rustdoc.rs:200:26
     |
 199 | pub fn attrs_to_doc_fragments<'a>(
     |        ---------------------- required by a bound in this function
 200 |     attrs: impl Iterator<Item = (&'a ast::Attribute, Option<DefId>)>,
     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `attrs_to_doc_fragments`

error[E0308]: mismatched types
    --> src/librustdoc/clean/types.rs:1067:35
     |
1067 |         Attributes { doc_strings, other_attrs }
---

error[E0308]: mismatched types
    --> src/librustdoc/passes/collect_intra_doc_links.rs:1077:64
     |
1077 |                 && !has_primitive_or_keyword_or_attribute_docs(&item.attrs.other_attrs)
     |                     ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^ expected `&[Attribute]`, found `&ThinVec<Attribute>`
     |                     |
     |                     arguments to this function are incorrect
     |
     = note: expected reference `&[rustc_ast::Attribute]`
                found reference `&ThinVec<rustc_hir::Attribute>`
note: function defined here
    --> compiler/rustc_resolve/src/rustdoc.rs:368:8
     |
 368 | pub fn has_primitive_or_keyword_or_attribute_docs(attrs: &[ast::Attribute]) -> bool {
     |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0271, E0308, E0432.
For more information about an error, try `rustc --explain E0271`.
[RUSTC-TIMING] rustdoc test:false 3.454

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

JonathanBrouwer commented Apr 9, 2026

We need to wait with merging this until we've made a decision on whether we revert the lint attribut port (see #152369), I'll review when the decision has been made

@JonathanBrouwer JonathanBrouwer added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Apr 9, 2026
@mejrs mejrs marked this pull request as draft April 9, 2026 17:29
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants