-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-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
Please check the code bellow
https://play.rust-lang.org/?gist=c0dd3d93bde346c4bd4d&version=nightly
#![feature(drain)]
use std::sync::{Arc, RwLock};
fn main() {
let files = RwLock::new(vec![Arc::new(1u32)]);
// WONT compile
let a: Vec<_> = files.write().unwrap().drain(..1).collect();
// WONT compile
let a: Vec<_> = {
let mut temp = files.write().unwrap();
temp.drain(..1).collect()
};
// compiles
let a: Vec<_> = {
let mut temp = files.write().unwrap();
let res = temp.drain(..1).collect();
res
};
println!("{:?}", a);
}
I suppose all of them should compile as they do the same thing, but only the last one does.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-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.