Skip to content

Commit 357633b

Browse files
committed
warn on suspicious elision resolutions
1 parent 026e9ed commit 357633b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

compiler/rustc_resolve/src/late.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,20 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20392039
if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) {
20402040
panic!("lifetime {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)")
20412041
}
2042+
match candidate {
2043+
LifetimeElisionCandidate::Missing(missing) => match res {
2044+
LifetimeRes::Static => tracing::warn!(?missing, "static"),
2045+
LifetimeRes::Param { param, binder } => {
2046+
tracing::warn!(?missing, ?param, ?binder, "named")
2047+
}
2048+
LifetimeRes::Fresh { .. }
2049+
| LifetimeRes::Infer
2050+
| LifetimeRes::Error
2051+
| LifetimeRes::ElidedAnchor { .. } => {}
2052+
},
2053+
LifetimeElisionCandidate::Ignore | LifetimeElisionCandidate::Named => {}
2054+
}
2055+
20422056
match res {
20432057
LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static => {
20442058
if let Some(ref mut candidates) = self.lifetime_elision_candidates {

0 commit comments

Comments
 (0)