Closed
Description
During work on Cargo, I found a seeming bug where the compiler doesn't warn about an unnecessary mut
qualifier. This version does not warn:
fn bar<'a>(foo: &'a String) -> bool {
foo == "foo"
}
fn main() {
let res = {
let mut foo = String::from("foo");
bar(&foo)
};
println!("{:?}", res);
}
This version does warn:
fn bar<'a>(foo: &'a String) -> bool {
foo == "foo"
}
fn main() {
let mut foo = String::from("foo");
let res = bar(&foo);
println!("{:?}", res);
}
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.Bugs fixed, but only when NLL is enabled.