Skip to content

start properly testing attributes in positions #140948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mejrs
Copy link
Contributor

@mejrs mejrs commented May 12, 2025

See the readme for the motivation. Just doing three attributes for now to get feedback on the overall implementation and direction.

Please let me know if there are additional positions that need testing!

@rustbot
Copy link
Collaborator

rustbot commented May 12, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
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

@rustbot rustbot added 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 May 12, 2025
@jieyouxu
Copy link
Member

r? jieyouxu

@rustbot rustbot assigned jieyouxu and unassigned wesleywiser May 12, 2025
@ehuss
Copy link
Contributor

ehuss commented May 12, 2025

Oh, this is great! I was just recently working on this, but happy to have someone actually make it happen.

I look forward to this being accepted. Let me know if you want any help.

I think there are a few tests that could eventually get deleted once everything gets covered. For example:

  • ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs -- This is a bit of a mess
  • ui/issues/issue-54044.rs
  • ui/issues/issue-78957.rs
  • ui/lint/unused/unused_attributes-must_use.rs
  • Probably others...

Some suggestions:

  • Inner attributes on outline modules sometimes go through a different code path. I'm wondering if it would be helpful to include that? Unfortunately that could double the number of files.
  • Some others that seem to be missing:
    • Inner attributes:
      • Trait definition
      • Const blocks (which are handled differently than regular blocks)
      • match block
      • Unstable things:
        • gen block
        • try block
    • Outer attributes:
      • Closure arguments (seems to be included in allow.rs though?)
      • Struct pattern fields
      • type: bare function parameter
      • type: bare function ...

@jieyouxu jieyouxu added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label May 12, 2025
@jieyouxu
Copy link
Member

cc @jdonszelmann (as you may want to co-review)

@jdonszelmann
Copy link
Contributor

Yes, I'd like that. might take a little because of rust week @rustbot claim

@rustbot rustbot assigned jdonszelmann and unassigned jieyouxu May 12, 2025
@jieyouxu jieyouxu self-assigned this May 12, 2025
@mejrs
Copy link
Contributor Author

mejrs commented May 12, 2025

I think we also ought to test combinations of attributes. Such as

#[ATTRIBUTE]
#[naked]
extern "C" fn naked(){}

Are there more like that?

Closure arguments (seems to be included in allow.rs though?)

Just added another commit with these. I originally had them..not sure where they went...

@mejrs mejrs marked this pull request as draft May 13, 2025 09:35
@mejrs
Copy link
Contributor Author

mejrs commented May 13, 2025

Just these couple of edits have already been quite annoying and error prone. Doing this for dozens of attributes is going to be untenable in the long run.

This needs to be automatically generated, and I have some ideas about how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants