-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Description
Simple example:
use std::cmp::Ordering;
fn something<T,F>(slice: &mut [T], mut compare: F) where
F: FnMut(&T,&T) -> Ordering
{
// This compiles fine:
if compare(&slice[0], &slice[1]) == Ordering::Less {
slice.swap(0, 1);
}
// But this does not:
let mut cmp = |a,b| compare(a,b) == Ordering::Less;
if cmp(&slice[0], &slice[1]) {
slice.swap(0, 1);
}
}
Playpen: http://is.gd/niaLAa
It seems like it marks the closure return value as a borrowed value from slice
, even though it is just a bool.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.