Skip to content
Permalink
Browse files

document `shallow_resolve`

  • Loading branch information...
nikomatsakis committed Oct 2, 2019
1 parent 5d64b3d commit 5fea1d279bdc7863f38a7bf2b58ecf66c18ef6d7
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/librustc/infer/mod.rs
@@ -1307,6 +1307,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}

/// Resolve any type variables found in `value` -- but only one
/// level. So, if the variable `?X` is bound to some type
/// `Foo<?Y>`, then this would return `Foo<?Y>` (but `?Y` may
/// itself be bound to a type).
///
/// Useful when you only need to inspect the outermost level of
/// the type and don't care about nested types (or perhaps you
/// will be resolving them as well, e.g. in a loop).
pub fn shallow_resolve<T>(&self, value: T) -> T
where
T: TypeFoldable<'tcx>,
@@ -1567,6 +1575,9 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
ShallowResolver { infcx }
}

/// If `typ` is a type variable of some kind, resolve it one level
/// (but do not resolve types found in the result). If `typ` is
/// not a type variable, just return it unmodified.
pub fn shallow_resolve(&mut self, typ: Ty<'tcx>) -> Ty<'tcx> {
match typ.kind {
ty::Infer(ty::TyVar(v)) => {

0 comments on commit 5fea1d2

Please sign in to comment.
You can’t perform that action at this time.