Skip to content

Unsafe kept in help text#156791

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
obi1kenobi:unsafe-kept-in-help-text
May 21, 2026
Merged

Unsafe kept in help text#156791
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
obi1kenobi:unsafe-kept-in-help-text

Conversation

@ariagivens
Copy link
Copy Markdown
Contributor

Currently when encountering a malformed attribute, the compiler will suggest removing unsafe in the well-formed template even when unsafe is required. This PR preserves whatever unsafe (or lack) exists in the user's code.

r? @jdonszelmann

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 21, 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 May 21, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 21, 2026

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented May 21, 2026

Hey, I think Jana might be a bit busy because of Rustweek thing, do you mind if I take a look?

pub fn suggestions(
&self,
style: AttrSuggestionStyle,
wrap_with_unsafe: bool,
Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer May 21, 2026

Choose a reason for hiding this comment

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

I'd prefer to pass the Safety in here, instead of a bool

View changes since the 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 May 21, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 21, 2026

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

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 21, 2026

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@ariagivens
Copy link
Copy Markdown
Contributor Author

@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 May 21, 2026
@ariagivens
Copy link
Copy Markdown
Contributor Author

First time contributing to rustc after Jana's excellent workshop. Would related changes like suggesting:

- #[unsafe(export_name = ident)]
+ #[unsafe(export_name = "ident")]

go in this PR or a new one?

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented May 21, 2026

go in this PR or a new one?

Sounds like a something for a new PR

Copy link
Copy Markdown
Member

@Kivooeo Kivooeo left a comment

Choose a reason for hiding this comment

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

Looks good to me, @JonathanBrouwer how you feel about it?

View changes since this review

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.

@bors r=JonathanBrouwer,Kivooeo rollup

View changes since this review

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 21, 2026

📌 Commit 970cb15 has been approved by JonathanBrouwer,Kivooeo

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-review Status: Awaiting review from the assignee but also interested parties. labels May 21, 2026
rust-bors Bot pushed a commit that referenced this pull request May 21, 2026
…uwer

Rollup of 2 pull requests

Successful merges:

 - #156242 (Remove unsound `target_feature_inline_always` feature)
 - #156791 (Unsafe kept in help text)
rust-timer added a commit that referenced this pull request May 21, 2026
Rollup merge of #156791 - obi1kenobi:unsafe-kept-in-help-text, r=JonathanBrouwer,Kivooeo

Unsafe kept in help text

Currently when encountering a malformed attribute, the compiler will suggest removing unsafe in the well-formed template even when unsafe is required. This PR preserves whatever unsafe (or lack) exists in the user's code.

r? @jdonszelmann
@rust-bors rust-bors Bot merged commit f84347a into rust-lang:main May 21, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 21, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@rust-timer build c5fccf7

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (c5fccf7): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.1%, secondary -1.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-3.5%, -3.3%] 2
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Binary size

Results (primary -0.0%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 34
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 6
All ❌✅ (primary) -0.0% [-0.1%, -0.0%] 34

Bootstrap: 514.377s -> 517.8s (0.67%)
Artifact size: 400.61 MiB -> 400.56 MiB (-0.01%)

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Perf is noise

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.

7 participants