Skip to content

Commit 5fea1d2

Browse files
committed
document shallow_resolve
1 parent 5d64b3d commit 5fea1d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/librustc/infer/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13071307
}
13081308
}
13091309

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

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

0 commit comments

Comments
 (0)