Skip to content

False positive for unused-unsafe #7626

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

Closed
cmichi opened this issue Sep 3, 2021 · 2 comments
Closed

False positive for unused-unsafe #7626

cmichi opened this issue Sep 3, 2021 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@cmichi
Copy link

cmichi commented Sep 3, 2021

Lint name: unused-unsafe

I tried this code:

src/lib.rs:

pub extern fn test() {
  unsafe { core::arch::wasm32::unreachable(); }
}

Cargo.toml:

[package]
name = "test"
version = "0.1.0"
edition = "2018"

[lib]
name = "test"
path = "src/lib.rs"
crate-type =["cdylib"]

[dependencies]

I expected to see this happen: No lint error should be reported.

Instead, this happened:

$ cargo clippy --verbose --no-default-features --target wasm32-unknown-unknown -- -D warnings
…
error: unnecessary `unsafe` block
 --> src/lib.rs:2:2                                                                                                                                            
  |                                                                                                                                                            
2 |     unsafe { core::arch::wasm32::unreachable(); }                                                                                                          
  |     ^^^^^^ unnecessary `unsafe` block                                                                                                                      
  |                                                                            
  = note: `-D unused-unsafe` implied by `-D warnings`

The function is marked as unsafe though: https://doc.rust-lang.org/stable/core/arch/wasm32/fn.unreachable.html.

There is also no lint error reported if I switch to rustup override set nightly-2021-08-13.

Meta

Rust version (rustc -Vv):

rustc 1.56.0-nightly (371f3cd3f 2021-09-02)
binary: rustc
commit-hash: 371f3cd3fe523d0b398ed1db1620667c53ba7d02
commit-date: 2021-09-02
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 13.0.0
@cmichi cmichi added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 3, 2021
@rustbot

This comment has been minimized.

@cmichi
Copy link
Author

cmichi commented Sep 3, 2021

Turns out the function was indeed recently marked as safe: https://doc.rust-lang.org/nightly/core/arch/wasm32/fn.unreachable.html.

This function is safe to call and immediately aborts the execution.

@cmichi cmichi closed this as completed Sep 3, 2021
bors added a commit that referenced this issue Sep 5, 2021
…=llogiq

Updating issue templates again for rustbot

It turns out that our current issue template can sometimes trigger a rustbot error message, as can be seen in [#7626](#7626). I originally tested this in #7599, but it's apparently a bit inconsistent. This PR adds backticks to the commands, as correctly suggested by `@mikerite` in the comments. (Thank you!)

``@rustbot` label +S-blocked`

---

Now I also pushed a tiny link fix as well. 🙃

---

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

2 participants