diff options
| author | ouz-a <ouz.agz@gmail.com> | 2023-11-18 14:35:13 +0300 |
|---|---|---|
| committer | ouz-a <ouz.agz@gmail.com> | 2023-11-20 23:13:36 +0300 |
| commit | f68c6c9528606e3d8e31dac47af95b568372c644 (patch) | |
| tree | 853d9440804dea1a27faa952407074c9b1bec762 /compiler | |
| parent | 61d3b263a793b390f6231f08d862e8c71d04e3ef (diff) | |
| download | rust-f68c6c9528606e3d8e31dac47af95b568372c644.tar.gz rust-f68c6c9528606e3d8e31dac47af95b568372c644.zip | |
Fix early param lifetimes in generic_const_exprs
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 76c5a06c80d..1069f544f57 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -35,7 +35,7 @@ use crate::session_diagnostics::{ LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote, }; -use super::{OutlivesSuggestionBuilder, RegionName}; +use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource}; use crate::region_infer::{BlameConstraint, ExtraConstraintInfo}; use crate::{ nll::ConstraintDescription, @@ -763,7 +763,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let err = LifetimeOutliveErr { span: *span }; let mut diag = self.infcx.tcx.sess.create_err(err); - let fr_name = self.give_region_a_name(*fr).unwrap(); + // In certain scenarios, such as the one described in issue #118021, + // we might encounter a lifetime that cannot be named. + // These situations are bound to result in errors. + // To prevent an immediate ICE, we opt to create a dummy name instead. + let fr_name = self.give_region_a_name(*fr).unwrap_or(RegionName { + name: kw::UnderscoreLifetime, + source: RegionNameSource::Static, + }); fr_name.highlight_region_name(&mut diag); let outlived_fr_name = self.give_region_a_name(*outlived_fr).unwrap(); outlived_fr_name.highlight_region_name(&mut diag); |
