Skip to content

Attributes containing rustc#153532

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
jdonszelmann:attributes-containing-rustc
Apr 2, 2026
Merged

Attributes containing rustc#153532
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
jdonszelmann:attributes-containing-rustc

Conversation

@jdonszelmann
Copy link
Copy Markdown
Contributor

r? @petrochenkov

I noticed that attributes containing the word rustc as a segment also error with a message referring to "starting with rustc". The first commit shows this going wrong by re-exporting #[test], a built-in macro, from a module called rustc.

The 2nd commit addresses this by changing the diagnostic. However, given the wording I wonder if the real solution shouldn't be to allow attributes containing a rustc segment and only disallow them when they start. In other words, actually implement the behavior that the original diagnostic pointed out.

@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 Mar 7, 2026
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@jdonszelmann jdonszelmann force-pushed the attributes-containing-rustc branch 2 times, most recently from 53123a4 to f6b4e4e Compare March 7, 2026 09:41
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the attributes-containing-rustc branch from f6b4e4e to 951e9d7 Compare March 9, 2026 09:19
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

Removed the test I added in commit 1, since we already test similar behavior somewhere else (see the other test I blessed). Kept it in the first commit to demonstrate old behavior.

Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

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

Not sure if you want specifically petrochenkov to take a look, if not r=me

View changes since this review

@@ -618,15 +612,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}

// Report errors for the resolved macro.
let mut first = true;
for segment in &path.segments {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I'd prefer doing this with enumerate rather than a variable

@petrochenkov
Copy link
Copy Markdown
Contributor

r=me with #153532 (comment) addressed.
@rustbot author

@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 Mar 10, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 10, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jdonszelmann jdonszelmann force-pushed the attributes-containing-rustc branch from 951e9d7 to 3e0572e Compare April 2, 2026 09:10
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 2, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@bors r=petrochenkov

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 2, 2026

📌 Commit 3e0572e has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 2, 2026
…-rustc, r=petrochenkov

Attributes containing rustc

r? @petrochenkov

I noticed that attributes *containing* the word rustc as a segment also error with a message referring to "starting with rustc". The first commit shows this going wrong by re-exporting `#[test]`, a built-in macro, from a module called rustc.

The 2nd commit addresses this by changing the diagnostic. However, given the wording I wonder if the real solution shouldn't be to allow attributes containing a `rustc` segment and only disallow them when they start. In other words, actually implement the behavior that the original diagnostic pointed out.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 2, 2026
…-rustc, r=petrochenkov

Attributes containing rustc

r? @petrochenkov

I noticed that attributes *containing* the word rustc as a segment also error with a message referring to "starting with rustc". The first commit shows this going wrong by re-exporting `#[test]`, a built-in macro, from a module called rustc.

The 2nd commit addresses this by changing the diagnostic. However, given the wording I wonder if the real solution shouldn't be to allow attributes containing a `rustc` segment and only disallow them when they start. In other words, actually implement the behavior that the original diagnostic pointed out.
rust-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #153105 (Compute the result of a projection type with region errors)
 - #153286 (various fixes for scalable vectors)
 - #153532 (Attributes containing rustc)
 - #153960 (Make `layout_of` cycles fatal errors)
 - #154527 (Emit pre-expansion feature gate warnings for negative impls and specialization)
 - #154666 (Remove `StableHashContext` impls)
 - #154669 (Introduce #[diagnostic::on_move] on `Arc`)
 - #154710 (opaque_generic_const_args -> generic_const_args)
 - #154712 (Revert "`-Znext-solver` Remove the forced ambiguity hack from search graph")
 - #154713 (Stop compiling when we get resolving crate failure)
 - #154213 (tidy-alphabetical: fix line number in error message)
 - #154425 (Migrate transmute tests)
 - #154442 (Export `derive` at the crate root: `core::derive` and `std::derive`)
 - #154469 (mGCA: Lower spans for literal const args)
 - #154578 (Rename `probe_ty_var` to `try_resolve_ty_var`)
 - #154615 (Moving issues)
 - #154644 (rustdoc: seperate methods and associated functions in sidebar)
 - #154660 (Avoid creating async return opaques for foreign async fns)
 - #154671 (Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args)
 - #154680 ([rustdoc] Replace `DocContext` with `TyCtxt` wherever possible)
 - #154709 (Revert `Ty` type alias in `rustc_type_ir`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 2, 2026
…-rustc, r=petrochenkov

Attributes containing rustc

r? @petrochenkov

I noticed that attributes *containing* the word rustc as a segment also error with a message referring to "starting with rustc". The first commit shows this going wrong by re-exporting `#[test]`, a built-in macro, from a module called rustc.

The 2nd commit addresses this by changing the diagnostic. However, given the wording I wonder if the real solution shouldn't be to allow attributes containing a `rustc` segment and only disallow them when they start. In other words, actually implement the behavior that the original diagnostic pointed out.
rust-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #153105 (Compute the result of a projection type with region errors)
 - #153286 (various fixes for scalable vectors)
 - #153532 (Attributes containing rustc)
 - #153960 (Make `layout_of` cycles fatal errors)
 - #154527 (Emit pre-expansion feature gate warnings for negative impls and specialization)
 - #154666 (Remove `StableHashContext` impls)
 - #154669 (Introduce #[diagnostic::on_move] on `Arc`)
 - #154710 (opaque_generic_const_args -> generic_const_args)
 - #154712 (Revert "`-Znext-solver` Remove the forced ambiguity hack from search graph")
 - #153614 (`FindParamInClause` handle edge-cases)
 - #154213 (tidy-alphabetical: fix line number in error message)
 - #154425 (Migrate transmute tests)
 - #154442 (Export `derive` at the crate root: `core::derive` and `std::derive`)
 - #154469 (mGCA: Lower spans for literal const args)
 - #154578 (Rename `probe_ty_var` to `try_resolve_ty_var`)
 - #154615 (Moving issues)
 - #154644 (rustdoc: seperate methods and associated functions in sidebar)
 - #154660 (Avoid creating async return opaques for foreign async fns)
 - #154671 (Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args)
 - #154680 ([rustdoc] Replace `DocContext` with `TyCtxt` wherever possible)
 - #154709 (Revert `Ty` type alias in `rustc_type_ir`)
rust-bors bot pushed a commit that referenced this pull request Apr 2, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #153105 (Compute the result of a projection type with region errors)
 - #153532 (Attributes containing rustc)
 - #153960 (Make `layout_of` cycles fatal errors)
 - #154527 (Emit pre-expansion feature gate warnings for negative impls and specialization)
 - #154666 (Remove `StableHashContext` impls)
 - #154669 (Introduce #[diagnostic::on_move] on `Arc`)
 - #154710 (opaque_generic_const_args -> generic_const_args)
 - #154712 (Revert "`-Znext-solver` Remove the forced ambiguity hack from search graph")
 - #153614 (`FindParamInClause` handle edge-cases)
 - #154213 (tidy-alphabetical: fix line number in error message)
 - #154425 (Migrate transmute tests)
 - #154442 (Export `derive` at the crate root: `core::derive` and `std::derive`)
 - #154469 (mGCA: Lower spans for literal const args)
 - #154578 (Rename `probe_ty_var` to `try_resolve_ty_var`)
 - #154615 (Moving issues)
 - #154644 (rustdoc: seperate methods and associated functions in sidebar)
 - #154660 (Avoid creating async return opaques for foreign async fns)
 - #154671 (Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args)
 - #154680 ([rustdoc] Replace `DocContext` with `TyCtxt` wherever possible)
 - #154709 (Revert `Ty` type alias in `rustc_type_ir`)
@rust-bors rust-bors bot merged commit 45cec8b into rust-lang:main Apr 2, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 2, 2026
rust-timer added a commit that referenced this pull request Apr 2, 2026
Rollup merge of #153532 - jdonszelmann:attributes-containing-rustc, r=petrochenkov

Attributes containing rustc

r? @petrochenkov

I noticed that attributes *containing* the word rustc as a segment also error with a message referring to "starting with rustc". The first commit shows this going wrong by re-exporting `#[test]`, a built-in macro, from a module called rustc.

The 2nd commit addresses this by changing the diagnostic. However, given the wording I wonder if the real solution shouldn't be to allow attributes containing a `rustc` segment and only disallow them when they start. In other words, actually implement the behavior that the original diagnostic pointed out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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