Fix unused_unsafe label with unsafe_block_in_unsafe_fn#81110
Fix unused_unsafe label with unsafe_block_in_unsafe_fn#81110bors merged 1 commit intorust-lang:masterfrom
unused_unsafe label with unsafe_block_in_unsafe_fn#81110Conversation
|
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
|
I don't see the problem here? What you describe in the OP is intended behavior!
|
|
IOW, the feature gate itself should not change anything (as is common for feature gates). The feature gate merely unlocks the ability to use some other syntax to change something; in this case, that other syntax is |
|
Oh, wait, I misunderstood... I thought you wanted to not show the warning, but instead you want to show more information with the warning? I have no idea why that has anything to do with the feature flag though... |
There was a problem hiding this comment.
FWIW, this error is kind of confusing because the "because" comes before the thing it is justifying. I guess there's also the error 'title' thing "unnecessary unsafe block", so it's probably okay, but just reading the spans things are in the wrong order... not sure how we usually handle situations where code order and "justification order" disagree.
There was a problem hiding this comment.
This is how the warning is emitted today (without unsafe_block_in_unsafe_fn). I guess any improvement here should be made in another PR
|
Right, sorry, I was probably not clear enough in the OP. This PR "restores" the "because it's nested under this unsafe fn" label in the warning when the lint is allowed, to match the behavior when the feature gate is not present. |
|
And as a drive-by fix it replaces a |
|
@RalfJung do you intend to fully review this PR? |
|
I guess at this point I just as well might.^^ |
5421029 to
2136a5c
Compare
|
@RalfJung This should be ready for another review |
|
Looking good, thanks! |
|
📌 Commit 2136a5c has been approved by |
…abel, r=RalfJung
Fix `unused_unsafe` label with `unsafe_block_in_unsafe_fn
Previously, the following code:
```rust
#![feature(unsafe_block_in_unsafe_fn)]
unsafe fn foo() {
unsafe { unsf() }
}
unsafe fn unsf() {}
```
Would give the following warning:
```
warning: unnecessary `unsafe` block
--> src/lib.rs:4:5
|
4 | unsafe { unsf() }
| ^^^^^^ unnecessary `unsafe` block
|
= note: `#[warn(unused_unsafe)]` on by default
```
which doesn't point out that the block is in an `unsafe fn`.
Tracking issue: rust-lang#71668
cc rust-lang#79208
unused_unsafe label with `unsafe_block_in_unsafe_fnunused_unsafe label with unsafe_block_in_unsafe_fn
|
☀️ Test successful - checks-actions |
Previously, the following code:
Would give the following warning:
which doesn't point out that the block is in an
unsafe fn.Tracking issue: #71668
cc #79208