Skip to content

unused_unsafe gives wrong reason #48131

Closed
@main--

Description

@main--
pub unsafe fn outer() {
    fn inner() {
        unsafe { /* unnecessary */ }
    }
    
    inner()
}
warning: unnecessary `unsafe` block
 --> src/main.rs:3:9
  |
1 | pub unsafe fn outer() {
  | --------------------- because it's nested under this `unsafe` fn
2 |     fn inner() {
3 |         unsafe { /* unnecessary */ }
  |         ^^^^^^ unnecessary `unsafe` block
  |
  = note: #[warn(unused_unsafe)] on by default

The unsafe block is clearly unnecessary, but it being inside a safe function which is nested in an unsafe function is clearly not the reason. Playpen

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions