Auto merge of #139587 - lcnr:revealing-use-closures, r= · rust-lang/rust@14ea441 (original) (raw)
`@@ -23,7 +23,6 @@ use rustc_trait_selection::error_reporting::infer::nice_region_error::{
`
23
23
`self, HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor, find_anon_type,
`
24
24
` find_param_with_region, suggest_adding_lifetime_params,
`
25
25
`};
`
26
``
`-
use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic;
`
27
26
`use rustc_trait_selection::infer::InferCtxtExt;
`
28
27
`use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
`
29
28
`use tracing::{debug, instrument, trace};
`
`@@ -84,9 +83,6 @@ impl<'tcx> RegionErrors<'tcx> {
`
84
83
`let guar = self.1.sess.dcx().delayed_bug(format!("{val:?}"));
`
85
84
`self.0.push((val, guar));
`
86
85
`}
`
87
``
`-
pub(crate) fn is_empty(&self) -> bool {
`
88
``
`-
self.0.is_empty()
`
89
``
`-
}
`
90
86
`pub(crate) fn into_iter(
`
91
87
`self,
`
92
88
`) -> impl Iterator<Item = (RegionErrorKind<'tcx>, ErrorGuaranteed)> {
`
`@@ -108,18 +104,6 @@ pub(crate) enum RegionErrorKind<'tcx> {
`
108
104
`` /// A generic bound failure for a type test (T: 'a).
``
109
105
`TypeTestError { type_test: TypeTest<'tcx> },
`
110
106
``
111
``
`-
/// An unexpected hidden region for an opaque type.
`
112
``
`-
UnexpectedHiddenRegion {
`
113
``
`-
/// The span for the member constraint.
`
114
``
`-
span: Span,
`
115
``
`-
/// The hidden type.
`
116
``
`-
hidden_ty: Ty<'tcx>,
`
117
``
`-
/// The opaque type.
`
118
``
`-
key: ty::OpaqueTypeKey<'tcx>,
`
119
``
`-
/// The unexpected region.
`
120
``
`-
member_region: ty::Region<'tcx>,
`
121
``
`-
},
`
122
``
-
123
107
`/// Higher-ranked subtyping error.
`
124
108
`BoundUniversalRegionError {
`
125
109
`/// The placeholder free region.
`
`@@ -312,9 +296,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
`
312
296
`` // buffered in the MirBorrowckCtxt.
``
313
297
``
314
298
`let mut outlives_suggestion = OutlivesSuggestionBuilder::default();
`
315
``
`-
let mut last_unexpected_hidden_region: Option<(Span, Ty<'_>, ty::OpaqueTypeKey<'tcx>)> =
`
316
``
`-
None;
`
317
``
-
318
299
`for (nll_error, _) in nll_errors.into_iter() {
`
319
300
`match nll_error {
`
320
301
`RegionErrorKind::TypeTestError { type_test } => {
`
`@@ -364,30 +345,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
`
364
345
`}
`
365
346
`}
`
366
347
``
367
``
`-
RegionErrorKind::UnexpectedHiddenRegion { span, hidden_ty, key, member_region } => {
`
368
``
`-
let named_ty =
`
369
``
`-
self.regioncx.name_regions_for_member_constraint(self.infcx.tcx, hidden_ty);
`
370
``
`-
let named_key =
`
371
``
`-
self.regioncx.name_regions_for_member_constraint(self.infcx.tcx, key);
`
372
``
`-
let named_region = self
`
373
``
`-
.regioncx
`
374
``
`-
.name_regions_for_member_constraint(self.infcx.tcx, member_region);
`
375
``
`-
let diag = unexpected_hidden_region_diagnostic(
`
376
``
`-
self.infcx,
`
377
``
`-
self.mir_def_id(),
`
378
``
`-
span,
`
379
``
`-
named_ty,
`
380
``
`-
named_region,
`
381
``
`-
named_key,
`
382
``
`-
);
`
383
``
`-
if last_unexpected_hidden_region != Some((span, named_ty, named_key)) {
`
384
``
`-
self.buffer_error(diag);
`
385
``
`-
last_unexpected_hidden_region = Some((span, named_ty, named_key));
`
386
``
`-
} else {
`
387
``
`-
diag.delay_as_bug();
`
388
``
`-
}
`
389
``
`-
}
`
390
``
-
391
348
`RegionErrorKind::BoundUniversalRegionError {
`
392
349
` longer_fr,
`
393
350
` placeholder,
`