Rollup merge of #130149 - GrigorenkoPV:lifetime-suggestion, r=cjgillot
Helper function for formatting with `LifetimeSuggestionPosition`
This commit is contained in:
commit
68ae3b27f5
3 changed files with 15 additions and 29 deletions
|
@ -852,18 +852,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
impl<'hir, 'tcx> hir::intravisit::Visitor<'hir> for LifetimeReplaceVisitor<'tcx, '_> {
|
||||
fn visit_lifetime(&mut self, lt: &'hir hir::Lifetime) {
|
||||
if lt.res == self.needle {
|
||||
let (pos, span) = lt.suggestion_position();
|
||||
let new_lt = &self.new_lt;
|
||||
let sugg = match pos {
|
||||
hir::LifetimeSuggestionPosition::Normal => format!("{new_lt}"),
|
||||
hir::LifetimeSuggestionPosition::Ampersand => format!("{new_lt} "),
|
||||
hir::LifetimeSuggestionPosition::ElidedPath => format!("<{new_lt}>"),
|
||||
hir::LifetimeSuggestionPosition::ElidedPathArgument => {
|
||||
format!("{new_lt}, ")
|
||||
}
|
||||
hir::LifetimeSuggestionPosition::ObjectDefault => format!("+ {new_lt}"),
|
||||
};
|
||||
self.add_lt_suggs.push((span, sugg));
|
||||
self.add_lt_suggs.push(lt.suggestion(self.new_lt));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue