diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-04-24 18:00:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-24 18:00:27 +0200 |
| commit | aef9eb50cdeef69245eb2ffc402fec4011d28ac0 (patch) | |
| tree | 5e545e5f2f3d0dccf7e4bd3d53cbea131700b7f1 /compiler/rustc_borrowck | |
| parent | 7daa1c92ec551488601f28fc788440003aee40f3 (diff) | |
| parent | 8d561d25e3307568255fc7c78ebb500294495561 (diff) | |
| download | rust-aef9eb50cdeef69245eb2ffc402fec4011d28ac0.tar.gz rust-aef9eb50cdeef69245eb2ffc402fec4011d28ac0.zip | |
Rollup merge of #96352 - marmeladema:fix-nll-lifetime-bound-suggestions, r=jackh726
Improve span for `consider adding an explicit lifetime bound` suggestions under NLL Because NLL borrowck is run after typeck, `in_progress_typeck_results` was always `None` which was preventing the retrieval of the span to which the suggestion is suppose to add the lifetime bound. We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure` so that under NLL, we give the owner id of the current body. This helps with #96332
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 5fd9ecf4513..fd78b483b75 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -4,6 +4,7 @@ use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed use rustc_infer::infer::{ error_reporting::nice_region_error::NiceRegionError, error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin, + RelateParamBound, }; use rustc_middle::hir::place::PlaceBase; use rustc_middle::mir::{ConstraintCategory, ReturnConstraint}; @@ -166,11 +167,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let type_test_span = type_test.locations.span(&self.body); if let Some(lower_bound_region) = lower_bound_region { + let generic_ty = type_test.generic_kind.to_ty(self.infcx.tcx); + let origin = RelateParamBound(type_test_span, generic_ty, None); self.buffer_error(self.infcx.construct_generic_bound_failure( type_test_span, - None, + Some(origin), type_test.generic_kind, lower_bound_region, + self.body.source.def_id().as_local(), )); } else { // FIXME. We should handle this case better. It |
