-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.
Description
In code like this rustc could warn that the 'b lifetime is not needed:
fn select<'a, 'b, const N: usize>(data: &'a mut [u32; N],
keep: &'b mut [bool; N]) -> &'a [u32] {
let mut pos = 0;
for (i, &b) in keep.iter().enumerate() {
if b {
data[pos] = data[i];
pos += 1;
}
}
&data[.. pos]
}
fn main() {
let mut data = [1, 2, 3, 4, 5];
let mut keep = [true, false, true, false, true];
println!("{:?}", select(&mut data, &mut keep));
}
(Currently rustc also doesn't spot that the 'keep' function argument doesn't need to be &mut).
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.