Skip to content

Commit e28a933

Browse files
committed
Correct visit_region implementation
1 parent 13e116f commit e28a933

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

compiler/rustc_ty_utils/src/instance.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'tcx> BoundVarsCollector<'tcx> {
3939
}
4040

4141
fn into_vars(self, tcx: TyCtxt<'tcx>) -> &'tcx ty::List<ty::BoundVariableKind> {
42-
let max = self.vars.iter().map(|(k, _)| *k).max().unwrap_or_else(|| 0);
42+
let max = self.vars.iter().map(|(k, _)| *k).max().unwrap_or(0);
4343
for i in 0..max {
4444
if let None = self.vars.get(&i) {
4545
panic!("Unknown variable: {:?}", i);
@@ -90,6 +90,31 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
9090
}
9191

9292
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
93+
use std::collections::btree_map::Entry;
94+
match r {
95+
ty::ReLateBound(index, br) if *index == self.binder_index => match br.kind {
96+
ty::BrNamed(_def_id, _name) => {
97+
// FIXME
98+
}
99+
100+
ty::BrAnon(var) => match self.vars.entry(var) {
101+
Entry::Vacant(entry) => {
102+
entry.insert(ty::BoundVariableKind::Region(br.kind));
103+
}
104+
Entry::Occupied(entry) => match entry.get() {
105+
ty::BoundVariableKind::Region(_) => {}
106+
_ => bug!("Conflicting bound vars"),
107+
},
108+
},
109+
110+
ty::BrEnv => {
111+
// FIXME
112+
}
113+
},
114+
115+
_ => (),
116+
};
117+
93118
r.super_visit_with(self)
94119
}
95120
}

0 commit comments

Comments
 (0)