Skip to content

Commit

Permalink
re-name params + add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
b-naber committed Oct 3, 2022
1 parent a8f17e3 commit e83dcf4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,8 +2057,8 @@ struct RegionFolder<'a, 'tcx> {
region_map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
name: &'a mut (
dyn FnMut(
Option<ty::DebruijnIndex>,
ty::DebruijnIndex,
Option<ty::DebruijnIndex>, // Debruijn index of the folded late-bound region
ty::DebruijnIndex, // Index corresponding to binder level
ty::BoundRegion,
) -> ty::Region<'tcx>
+ 'a
Expand Down Expand Up @@ -2246,15 +2246,21 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
})
} else {
let tcx = self.tcx;
let mut name = |db: Option<ty::DebruijnIndex>,
binder_level: ty::DebruijnIndex,

// Closure used in `RegionFolder` to create names for anonymous late-bound
// regions. We use two `DebruijnIndex`es (one for the currently folded
// late-bound region and the other for the binder level) to determine
// whether a name has already been created for the currently folded region,
// see issue #102392.
let mut name = |lifetime_idx: Option<ty::DebruijnIndex>,
binder_level_idx: ty::DebruijnIndex,
br: ty::BoundRegion| {
let (name, kind) = match br.kind {
ty::BrAnon(_) | ty::BrEnv => {
let name = next_name(&self);

if let Some(db) = db {
if db > binder_level {
if let Some(lt_idx) = lifetime_idx {
if lt_idx > binder_level_idx {
let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name);
return tcx.mk_region(ty::ReLateBound(
ty::INNERMOST,
Expand All @@ -2268,8 +2274,8 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
ty::BrNamed(def_id, kw::UnderscoreLifetime) => {
let name = next_name(&self);

if let Some(db) = db {
if db > binder_level {
if let Some(lt_idx) = lifetime_idx {
if lt_idx > binder_level_idx {
let kind = ty::BrNamed(def_id, name);
return tcx.mk_region(ty::ReLateBound(
ty::INNERMOST,
Expand All @@ -2281,8 +2287,8 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
(name, ty::BrNamed(def_id, name))
}
ty::BrNamed(_, name) => {
if let Some(db) = db {
if db > binder_level {
if let Some(lt_idx) = lifetime_idx {
if lt_idx > binder_level_idx {
let kind = br.kind;
return tcx.mk_region(ty::ReLateBound(
ty::INNERMOST,
Expand Down

0 comments on commit e83dcf4

Please sign in to comment.