diff options
| author | Yuki Okushi <yuki.okushi@huawei.com> | 2021-07-02 18:14:28 +0900 |
|---|---|---|
| committer | Yuki Okushi <yuki.okushi@huawei.com> | 2021-07-03 01:12:31 +0900 |
| commit | e28a93365abfa6b506f2017eac2f0971fc839306 (patch) | |
| tree | 86bc8a48ae4934a032457aba553d9724ee04ab20 | |
| parent | 13e116f1f70cce9759ce7d957e23241895542ec9 (diff) | |
| download | rust-e28a93365abfa6b506f2017eac2f0971fc839306.tar.gz rust-e28a93365abfa6b506f2017eac2f0971fc839306.zip | |
Correct `visit_region` implementation
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index ac10ebd2dd7..0f507cfb997 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -39,7 +39,7 @@ impl<'tcx> BoundVarsCollector<'tcx> { } fn into_vars(self, tcx: TyCtxt<'tcx>) -> &'tcx ty::List<ty::BoundVariableKind> { - let max = self.vars.iter().map(|(k, _)| *k).max().unwrap_or_else(|| 0); + let max = self.vars.iter().map(|(k, _)| *k).max().unwrap_or(0); for i in 0..max { if let None = self.vars.get(&i) { panic!("Unknown variable: {:?}", i); @@ -90,6 +90,31 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> { } fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { + use std::collections::btree_map::Entry; + match r { + ty::ReLateBound(index, br) if *index == self.binder_index => match br.kind { + ty::BrNamed(_def_id, _name) => { + // FIXME + } + + ty::BrAnon(var) => match self.vars.entry(var) { + Entry::Vacant(entry) => { + entry.insert(ty::BoundVariableKind::Region(br.kind)); + } + Entry::Occupied(entry) => match entry.get() { + ty::BoundVariableKind::Region(_) => {} + _ => bug!("Conflicting bound vars"), + }, + }, + + ty::BrEnv => { + // FIXME + } + }, + + _ => (), + }; + r.super_visit_with(self) } } |
