Skip to content

Commit 6dcd744

Browse files
committed
Consider all possible one letter lifetimes in suggestion
1 parent 224ad32 commit 6dcd744

File tree

1 file changed

+3
-3
lines changed
  • src/librustc_infer/infer/error_reporting

1 file changed

+3
-3
lines changed

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17421742
let new_lt = generics
17431743
.as_ref()
17441744
.and_then(|(parent_g, g)| {
1745-
let possible = ["'a", "'b", "'c", "'d", "'e", "'f", "'g", "'h", "'i", "'j", "'k"];
1745+
let possible: Vec<_> = (b'a'..=b'z').map(|c| format!("'{}", c as char)).collect();
17461746
let mut lts_names = g
17471747
.params
17481748
.iter()
@@ -1758,9 +1758,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17581758
);
17591759
}
17601760
let lts = lts_names.iter().map(|s| -> &str { &*s }).collect::<Vec<_>>();
1761-
possible.iter().filter(|&candidate| !lts.contains(&*candidate)).next().map(|s| *s)
1761+
possible.into_iter().find(|candidate| !lts.contains(&candidate.as_str()))
17621762
})
1763-
.unwrap_or("'lt");
1763+
.unwrap_or("'lt".to_string());
17641764
let add_lt_sugg = generics
17651765
.as_ref()
17661766
.and_then(|(_, g)| g.params.first())

0 commit comments

Comments
 (0)