Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit da2b714

Browse files
Clarifying comment
1 parent a9e262a commit da2b714

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎compiler/rustc_hir_analysis/src/check/wfcheck.rs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,13 +2089,19 @@ fn lint_redundant_lifetimes<'tcx>(
20892089
let mut shadowed = FxHashSet::default();
20902090

20912091
for (idx, &candidate) in lifetimes.iter().enumerate() {
2092-
// Don't suggest removing a lifetime twice.
2092+
// Don't suggest removing a lifetime twice. We only need to check this
2093+
// here and not up in the `victim` loop because equality is transitive,
2094+
// so if A = C and B = C, then A must = B, so it'll be shadowed too in
2095+
// A's victim loop.
20932096
if shadowed.contains(&candidate) {
20942097
continue;
20952098
}
20962099

20972100
for &victim in &lifetimes[(idx + 1)..] {
2098-
// We only care about lifetimes that are "real", i.e. that have a def-id.
2101+
// We should only have late-bound lifetimes of the `BrNamed` variety,
2102+
// since we get these signatures straight from `hir_lowering`. And any
2103+
// other regions (ReError/ReStatic/etc.) shouldn't matter, since we
2104+
// can't really suggest to remove them.
20992105
let (ty::ReEarlyParam(ty::EarlyParamRegion { def_id, .. })
21002106
| ty::ReLateParam(ty::LateParamRegion {
21012107
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
@@ -2113,7 +2119,7 @@ fn lint_redundant_lifetimes<'tcx>(
21132119
continue;
21142120
}
21152121

2116-
// If there are no lifetime errors, then we have proven that `'candidate = 'victim`!
2122+
// If `candidate <: victim` and `victim <: candidate`, then they're equal.
21172123
if outlives_env.free_region_map().sub_free_regions(tcx, candidate, victim)
21182124
&& outlives_env.free_region_map().sub_free_regions(tcx, victim, candidate)
21192125
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /