Skip to content

Conversation

@mu001999
Copy link
Contributor

@mu001999 mu001999 commented Dec 8, 2025

Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?).

Fixes #149756

@rustbot
Copy link
Collaborator

rustbot commented Dec 8, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@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 Dec 8, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 8, 2025

r? @eholk

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

@jdonszelmann
Copy link
Contributor

r? jdonszelmann

Some(unsafe_since) => path_span.edition() >= unsafe_since,
};

let may_from_proc_macro = if diag_span.from_expansion()
Copy link
Contributor

Choose a reason for hiding this comment

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

can_be_used_for_suggestions() might be more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@mu001999 mu001999 Dec 9, 2025

Choose a reason for hiding this comment

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

I think such suggestions should still be emitted, how do you think about it?

Copy link
Contributor

@jdonszelmann jdonszelmann left a comment

Choose a reason for hiding this comment

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

some smol nits, looks good otherwise!

View changes since this review

@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 Dec 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 9, 2025

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

@bors
Copy link
Collaborator

bors commented Dec 9, 2025

☔ The latest upstream changes (presumably #149798) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Dec 9, 2025

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.

@mu001999
Copy link
Contributor Author

mu001999 commented Dec 9, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 9, 2025
@mu001999 mu001999 requested a review from jdonszelmann December 9, 2025 14:58
@jdonszelmann
Copy link
Contributor

indeed, @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 9, 2025

📌 Commit 50e9839 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels Dec 9, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Dec 10, 2025
…nszelmann

Don't suggest wrapping attr in unsafe if it may come from proc macro

Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?).

Fixes rust-lang#149756
Zalathar added a commit to Zalathar/rust that referenced this pull request Dec 10, 2025
…nszelmann

Don't suggest wrapping attr in unsafe if it may come from proc macro

Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?).

Fixes rust-lang#149756
bors added a commit that referenced this pull request Dec 10, 2025
Rollup of 12 pull requests

Successful merges:

 - #147602 (Deduplicate higher-ranked lifetime capture errors in impl Trait)
 - #147725 (Remove -Zoom=panic)
 - #148294 (callconv: fix mips64 aggregate argument passing for C FFI)
 - #148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type)
 - #149417 (tidy: Detect outdated workspaces in workspace list)
 - #149458 (Run clippy on cg_gcc in CI)
 - #149679 (Restrict spe_acc to PowerPC SPE targets)
 - #149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro)
 - #149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std)
 - #149816 (Make typo in field and name suggestions verbose)
 - #149824 (Add a regression test for issue 145748)
 - #149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Dec 10, 2025
Rollup of 10 pull requests

Successful merges:

 - #147725 (Remove -Zoom=panic)
 - #148294 (callconv: fix mips64 aggregate argument passing for C FFI)
 - #148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type)
 - #149458 (Run clippy on cg_gcc in CI)
 - #149679 (Restrict spe_acc to PowerPC SPE targets)
 - #149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro)
 - #149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std)
 - #149816 (Make typo in field and name suggestions verbose)
 - #149824 (Add a regression test for issue 145748)
 - #149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 087ca1f into rust-lang:main Dec 10, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 10, 2025
rust-timer added a commit that referenced this pull request Dec 10, 2025
Rollup merge of #149781 - mu001999-contrib:fix/149756, r=jdonszelmann

Don't suggest wrapping attr in unsafe if it may come from proc macro

Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?).

Fixes #149756
@nnethercote
Copy link
Contributor

Thanks for doing this, @mu001999!

A suggestion for next time: for PRs that improve error messages I like to do it in two steps:

  • A first commit that adds a test showing the sub-optimal error message.
  • A second commit with the code changes and the expected output changes.

This makes reviewing easier, because it's really clear how the error message changed.

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 11, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#147725 (Remove -Zoom=panic)
 - rust-lang/rust#148294 (callconv: fix mips64 aggregate argument passing for C FFI)
 - rust-lang/rust#148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type)
 - rust-lang/rust#149458 (Run clippy on cg_gcc in CI)
 - rust-lang/rust#149679 (Restrict spe_acc to PowerPC SPE targets)
 - rust-lang/rust#149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro)
 - rust-lang/rust#149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std)
 - rust-lang/rust#149816 (Make typo in field and name suggestions verbose)
 - rust-lang/rust#149824 (Add a regression test for issue 145748)
 - rust-lang/rust#149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling)

r? `@ghost`
`@rustbot` modify labels: rollup
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-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.

Incorrect help suggestion in "unsafe attribute used without unsafe" error

6 participants