Skip to content

Missing unnecessary unsafe block warning #45107

Closed
@bluss

Description

@bluss

The following code uses a redundant unsafe block inside a closure.

This is a warning on stable but there is no warning on nightly.

To reproduce (playground):

fn main() {
    let mut v = Vec::<i32>::with_capacity(24);
    
    unsafe {
        let f = |v: &mut Vec<_>| {
            unsafe {
                v.set_len(24);
            }
        };
        
        v.set_len(0);
        f(&mut v);
    }
}

Probably due to #44700, cc @arielb1

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions