-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
In some cases suggested change regarding or_fun_call lint does not compile. Here's an example:
struct Pair {
a: u32,
b: u32,
}
fn foo(x: u32) -> u32 { x }
fn bar(pair: &mut Pair) {
let borrow = &mut pair.a;
let b = None.unwrap_or(foo(pair.b));
}pair is partially borrowed. Calling id(pair.b) is valid, because compiler can see that only field a is borrowed, so field b can be freely used. Clippy suggests to use unwrap_or_else, and move function call into a closure. However, the closure will borrow pair fully which is not possible, and the code will not compile.
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions