@@ -107,9 +107,6 @@ impl std::fmt::Debug for RegionErrors<'_> {
107107#[ derive( Clone , Debug ) ]
108108pub ( crate ) enum RegionErrorKind < ' tcx > {
109109 /// 'a outlives 'b, and both are placeholders.
110- /// This is a more general variant of `UnexpectedHiddenRegion`,
111- /// for cases where the mismatched region is a hidden region
112- /// from an opaque type.
113110 PlaceholderMismatch {
114111 rvid_a : RegionVid ,
115112 rvid_b : RegionVid ,
@@ -127,6 +124,10 @@ pub(crate) enum RegionErrorKind<'tcx> {
127124 } ,
128125
129126 /// An unexpected hidden region for an opaque type.
127+ /// This is a more specific variant of `UnexpectedHiddenRegion`,
128+ /// for cases where the mismatched region isn't a hidden region
129+ /// from an opaque type, but rather any other unexpected, invalid,
130+ /// or undeclared element.
130131 UnexpectedHiddenRegion {
131132 /// The span for the member constraint.
132133 span : Span ,
@@ -330,8 +331,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
330331 generic_kind,
331332 lower_bound,
332333 span,
333- failed_due_to_placeholders,
334- } if failed_due_to_placeholders => {
334+ failed_due_to_placeholders : true ,
335+ } => {
335336 // FIXME. We should handle this case better. It
336337 // indicates that we have e.g., some region variable
337338 // whose value is like `'a+'b` where `'a` and `'b` are
@@ -357,26 +358,22 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
357358 lower_bound,
358359 span,
359360 generic_kind,
360- failed_due_to_placeholders : _ ,
361+ failed_due_to_placeholders : false ,
361362 } => {
362363 // Try to convert the lower-bound region into something named we can print for
363364 // the user.
364- let lower_bound_region = self . to_error_region ( lower_bound) ;
365-
366- let type_test_span = span;
367-
368- let Some ( lower_bound_region) = lower_bound_region else {
365+ let Some ( lower_bound_region) = self . to_error_region ( lower_bound) else {
369366 unreachable ! (
370- "Found nothing good; lower bound was: {lower_bound:?} for {generic_kind:?} at {type_test_span :?}"
367+ "Found nothing good; lower bound was: {lower_bound:?} for {generic_kind:?} at {span :?}"
371368 ) ;
372369 } ;
373370 debug ! ( ?lower_bound_region) ;
374371 let generic_ty =
375372 self . name_regions ( self . infcx . tcx , generic_kind. to_ty ( self . infcx . tcx ) ) ;
376- let origin = RelateParamBound ( type_test_span , generic_ty, None ) ;
373+ let origin = RelateParamBound ( span , generic_ty, None ) ;
377374 self . buffer_error ( self . infcx . err_ctxt ( ) . construct_generic_bound_failure (
378375 self . body . source . def_id ( ) . expect_local ( ) ,
379- type_test_span ,
376+ span ,
380377 Some ( origin) ,
381378 self . name_regions ( self . infcx . tcx , generic_kind) ,
382379 lower_bound_region,
0 commit comments