Skip to content

false negative unused_mut #57248

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr
struct SomeStruct {
	path: std::path::PathBuf,
}

impl SomeStruct {
	fn path_exists(&mut self) -> bool { // false negative unused_mut
		// path.exists() does not need mutable reference:
		// pub fn exists(&self) -> bool { ... } 
		self.path.exists()
	}
}

fn main() {
    let mut s = SomeStruct { path: std::path::PathBuf::from("/tmp/a"), };
    println!("{}", s.path_exists());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions