Add a new trait to Debug
things with an infcx available
This commit is contained in:
parent
4dd1719b34
commit
3fdb443e4e
10 changed files with 474 additions and 105 deletions
|
@ -332,6 +332,39 @@ pub struct InferCtxt<'tcx> {
|
|||
next_trait_solver: bool,
|
||||
}
|
||||
|
||||
impl<'tcx> ty::InferCtxtLike<TyCtxt<'tcx>> for InferCtxt<'tcx> {
|
||||
fn universe_of_ty(&self, ty: ty::InferTy) -> Option<ty::UniverseIndex> {
|
||||
use InferTy::*;
|
||||
match ty {
|
||||
// FIXME(BoxyUwU): this is kind of jank and means that printing unresolved
|
||||
// ty infers will give you the universe of the var it resolved to not the universe
|
||||
// it actually had. It also means that if you have a `?0.1` and infer it to `u8` then
|
||||
// try to print out `?0.1` it will just print `?0`.
|
||||
TyVar(ty_vid) => match self.probe_ty_var(ty_vid) {
|
||||
Err(universe) => Some(universe),
|
||||
Ok(_) => None,
|
||||
},
|
||||
IntVar(_) | FloatVar(_) | FreshTy(_) | FreshIntTy(_) | FreshFloatTy(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn universe_of_ct(&self, ct: ty::InferConst<'tcx>) -> Option<ty::UniverseIndex> {
|
||||
use ty::InferConst::*;
|
||||
match ct {
|
||||
// Same issue as with `universe_of_ty`
|
||||
Var(ct_vid) => match self.probe_const_var(ct_vid) {
|
||||
Err(universe) => Some(universe),
|
||||
Ok(_) => None,
|
||||
},
|
||||
Fresh(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex> {
|
||||
Some(self.universe_of_region_vid(lt))
|
||||
}
|
||||
}
|
||||
|
||||
/// See the `error_reporting` module for more details.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable)]
|
||||
pub enum ValuePairs<'tcx> {
|
||||
|
@ -1068,6 +1101,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
self.inner.borrow_mut().unwrap_region_constraints().universe(r)
|
||||
}
|
||||
|
||||
/// Return the universe that the region variable `r` was created in.
|
||||
pub fn universe_of_region_vid(&self, vid: ty::RegionVid) -> ty::UniverseIndex {
|
||||
self.inner.borrow_mut().unwrap_region_constraints().var_universe(vid)
|
||||
}
|
||||
|
||||
/// Number of region variables created so far.
|
||||
pub fn num_region_vars(&self) -> usize {
|
||||
self.inner.borrow_mut().unwrap_region_constraints().num_region_vars()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue