Skip to content

Commit 4edcd63

Browse files
committed
Figure out better names for opaque types!
1 parent 5b95e9c commit 4edcd63

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo};
2929
use crate::member_constraints::{MemberConstraintSet, NllMemberConstraintIndex};
3030
use crate::nll::PoloniusOutput;
3131
use crate::region_infer::reverse_sccs::ReverseSccGraph;
32-
use crate::region_infer::values::{
33-
LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex,
34-
};
32+
use crate::region_infer::values::{LivenessValues, RegionElement, RegionValues, ToElementIndex};
3533
use crate::type_check::free_region_relations::UniversalRegionRelations;
3634
use crate::type_check::Locations;
3735
use crate::universal_regions::UniversalRegions;

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
212212

213213
// Special handling of higher-ranked regions.
214214
if !self.scc_universe(scc).is_root() {
215-
// FIXME: the original logic was: if this SCC contains one single
216-
// placeholder, equal to vid, then construct a
217-
// ty::Region::new_placeholder out of it, somehow. This no longer
218-
// works as an approach, since we cannot get the prerequisite indices.
215+
if self
216+
.constraint_sccs
217+
.annotation(scc)
218+
.placeholder_representative()
219+
.is_some_and(|representative| representative == vid)
220+
{
221+
if let NllRegionVariableOrigin::Placeholder(p) =
222+
self.definitions[vid].origin
223+
{
224+
return ty::Region::new_placeholder(tcx, p);
225+
}
226+
}
219227
debug!("Cannot get a nice name for higher-ranked region {vid:?} as {region:?}");
220228
return region;
221229
}

0 commit comments

Comments
 (0)