Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=comp… · rust-lang/rust@fec98b3 (original) (raw)
1
1
`use rustc_errors::Diag;
`
``
2
`+
use rustc_hir::def_id::LocalDefId;
`
2
3
`use rustc_infer::infer::canonical::Canonical;
`
3
4
`use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
`
4
5
`use rustc_infer::infer::region_constraints::Constraint;
`
`@@ -241,7 +242,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
`
241
242
` mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query);
`
242
243
`let ocx = ObligationCtxt::new(&infcx);
`
243
244
`type_op_prove_predicate_with_cause(&ocx, key, cause);
`
244
``
`-
try_extract_error_from_fulfill_cx(&ocx, placeholder_region, error_region)
`
``
245
`+
try_extract_error_from_fulfill_cx(&ocx, mbcx.mir_def_id(), placeholder_region, error_region)
`
245
246
`}
`
246
247
`}
`
247
248
``
`@@ -287,7 +288,7 @@ where
`
287
288
`let (param_env, value) = key.into_parts();
`
288
289
`let _ = ocx.normalize(&cause, param_env, value.value);
`
289
290
``
290
``
`-
try_extract_error_from_fulfill_cx(&ocx, placeholder_region, error_region)
`
``
291
`+
try_extract_error_from_fulfill_cx(&ocx, mbcx.mir_def_id(), placeholder_region, error_region)
`
291
292
`}
`
292
293
`}
`
293
294
``
`@@ -318,7 +319,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
`
318
319
` mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query);
`
319
320
`let ocx = ObligationCtxt::new(&infcx);
`
320
321
`type_op_ascribe_user_type_with_span(&ocx, key, Some(cause.span)).ok()?;
`
321
``
`-
try_extract_error_from_fulfill_cx(&ocx, placeholder_region, error_region)
`
``
322
`+
try_extract_error_from_fulfill_cx(&ocx, mbcx.mir_def_id(), placeholder_region, error_region)
`
322
323
`}
`
323
324
`}
`
324
325
``
`@@ -342,6 +343,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
`
342
343
`) -> Option<Diag<'tcx>> {
`
343
344
`try_extract_error_from_region_constraints(
`
344
345
` mbcx.infcx,
`
``
346
`+
mbcx.mir_def_id(),
`
345
347
` placeholder_region,
`
346
348
` error_region,
`
347
349
`self.region_constraints.as_ref().unwrap(),
`
`@@ -358,6 +360,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
`
358
360
`#[instrument(skip(ocx), level = "debug")]
`
359
361
`fn try_extract_error_from_fulfill_cx<'tcx>(
`
360
362
`ocx: &ObligationCtxt<'_, 'tcx>,
`
``
363
`+
generic_param_scope: LocalDefId,
`
361
364
`placeholder_region: ty::Region<'tcx>,
`
362
365
`error_region: Option<ty::Region<'tcx>>,
`
363
366
`) -> Option<Diag<'tcx>> {
`
`@@ -368,6 +371,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
`
368
371
`let region_constraints = ocx.infcx.with_region_constraints(|r| r.clone());
`
369
372
`try_extract_error_from_region_constraints(
`
370
373
` ocx.infcx,
`
``
374
`+
generic_param_scope,
`
371
375
` placeholder_region,
`
372
376
` error_region,
`
373
377
`®ion_constraints,
`
`@@ -379,6 +383,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
`
379
383
`#[instrument(level = "debug", skip(infcx, region_var_origin, universe_of_region))]
`
380
384
`fn try_extract_error_from_region_constraints<'tcx>(
`
381
385
`infcx: &InferCtxt<'tcx>,
`
``
386
`+
generic_param_scope: LocalDefId,
`
382
387
`placeholder_region: ty::Region<'tcx>,
`
383
388
`error_region: Option<ty::Region<'tcx>>,
`
384
389
`region_constraints: &RegionConstraintData<'tcx>,
`
`@@ -452,15 +457,18 @@ fn try_extract_error_from_region_constraints<'tcx>(
`
452
457
`RegionResolutionError::ConcreteFailure(cause.clone(), sub_region, placeholder_region)
`
453
458
`}
`
454
459
`};
`
455
``
`-
NiceRegionError::new(&infcx.err_ctxt(), error).try_report_from_nll().or_else(|| {
`
456
``
`-
if let SubregionOrigin::Subtype(trace) = cause {
`
457
``
`-
Some(
`
458
``
`-
infcx
`
459
``
`-
.err_ctxt()
`
460
``
`-
.report_and_explain_type_error(*trace, TypeError::RegionsPlaceholderMismatch),
`
461
``
`-
)
`
462
``
`-
} else {
`
463
``
`-
None
`
464
``
`-
}
`
465
``
`-
})
`
``
460
`+
NiceRegionError::new(&infcx.err_ctxt(), generic_param_scope, error)
`
``
461
`+
.try_report_from_nll()
`
``
462
`+
.or_else(|| {
`
``
463
`+
if let SubregionOrigin::Subtype(trace) = cause {
`
``
464
`+
Some(
`
``
465
`+
infcx.err_ctxt().report_and_explain_type_error(
`
``
466
`+
*trace,
`
``
467
`+
TypeError::RegionsPlaceholderMismatch,
`
``
468
`+
),
`
``
469
`+
)
`
``
470
`+
} else {
`
``
471
`+
None
`
``
472
`+
}
`
``
473
`+
})
`
466
474
`}
`