Suppress unnecessary outlives

This commit is contained in:
Michael Goulet 2023-07-31 18:23:12 +00:00
parent 9295817bad
commit 1c35634efe
4 changed files with 11 additions and 22 deletions

View File

@ -552,8 +552,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
for (region_a, region_a_idx) in &regions {
// Ignore `'static` lifetimes for the purpose of this lint: it's
// because we know it outlives everything and so doesn't give meaningful
// clues
if let ty::ReStatic = **region_a {
// clues. Also ignore `ReError`, to avoid knock-down errors.
if let ty::ReStatic | ty::ReError(_) = **region_a {
continue;
}
// For each region argument (e.g., `'a` in our example), check for a
@ -596,8 +596,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
// on the GAT itself.
for (region_b, region_b_idx) in &regions {
// Again, skip `'static` because it outlives everything. Also, we trivially
// know that a region outlives itself.
if ty::ReStatic == **region_b || region_a == region_b {
// know that a region outlives itself. Also ignore `ReError`, to avoid
// knock-down errors.
if matches!(**region_b, ty::ReStatic | ty::ReError(_)) || region_a == region_b {
continue;
}
if region_known_to_outlive(

View File

@ -942,6 +942,10 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
generic_ty: Ty<'tcx>,
min: ty::Region<'tcx>,
) -> bool {
if let ty::ReError(_) = *min {
return true;
}
match bound {
VerifyBound::IfEq(verify_if_eq_b) => {
let verify_if_eq_b = var_values.normalize(self.region_rels.tcx, *verify_if_eq_b);

View File

@ -7,7 +7,6 @@ trait Iterable {
fn iter(&self) -> impl Iterator<Item = Self::Item<'missing>>;
//~^ ERROR use of undeclared lifetime name `'missing`
//~| ERROR the parameter type `Self` may not live long enough
}
fn main() {}

View File

@ -18,21 +18,6 @@ help: consider introducing lifetime `'missing` here
LL | trait Iterable<'missing> {
| ++++++++++
error[E0311]: the parameter type `Self` may not live long enough
--> $DIR/missing-lt-outlives-in-rpitit-114274.rs:8:37
|
LL | fn iter(&self) -> impl Iterator<Item = Self::Item<'missing>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `Self: 'a`...
= note: ...so that the type `Self` will meet its required lifetime bounds...
note: ...that is required by this bound
--> $DIR/missing-lt-outlives-in-rpitit-114274.rs:6:15
|
LL | Self: 'a;
| ^^
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0261, E0311.
For more information about an error, try `rustc --explain E0261`.
For more information about this error, try `rustc --explain E0261`.