Skip to content

Commit 748f2e0

Browse files
committed
improve comment
1 parent 7eae204 commit 748f2e0

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

src/rustc/middle/typeck/infer.rs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,16 +1053,40 @@ impl unify_methods for infer_ctxt {
10531053
}
10541054

10551055
// Resolution is the process of removing type variables and replacing
1056-
// them with their inferred values. There are several "modes" for
1057-
// resolution. The first is a shallow resolution: this only resolves
1058-
// one layer, but does not resolve any nested variables. So, for
1059-
// example, if we have two variables A and B, and the constraint that
1060-
// A <: ~[B] and B <: int, then shallow resolution on A would yield
1061-
// ~[B]. Deep resolution, on the other hand, would yield ~[int].
1056+
// them with their inferred values. Unfortunately our inference has
1057+
// become fairly complex and so there are a number of options to
1058+
// control *just how much* you want to resolve and how you want to do
1059+
// it.
10621060
//
1063-
// But there is one more knob: the `force_level` variable controls
1064-
// the behavior in the face of unconstrained type and region
1065-
// variables.
1061+
// # Controlling the scope of resolution
1062+
//
1063+
// The options resolve_* determine what kinds of variables get
1064+
// resolved. Generally resolution starts with a top-level type
1065+
// variable; we will always resolve this. However, once we have
1066+
// resolved that variable, we may end up with a type that still
1067+
// contains type variables. For example, if we resolve `<T0>` we may
1068+
// end up with something like `[<T1>]`. If the option
1069+
// `resolve_nested_tvar` is passed, we will then go and recursively
1070+
// resolve `<T1>`.
1071+
//
1072+
// The options `resolve_rvar` and `resolve_ivar` control whether we
1073+
// resolve region and integral variables, respectively.
1074+
//
1075+
// # What do if things are unconstrained
1076+
//
1077+
// Sometimes we will encounter a variable that has no constraints, and
1078+
// therefore cannot sensibly be mapped to any particular result. By
1079+
// default, we will leave such variables as is (so you will get back a
1080+
// variable in your result). The options force_* will cause the
1081+
// resolution to fail in this case intead, except for the case of
1082+
// integral variables, which resolve to `int` if forced.
1083+
//
1084+
// # resolve_all and force_all
1085+
//
1086+
// The options are a bit set, so you can use the *_all to resolve or
1087+
// force all kinds of variables (including those we may add in the
1088+
// future). If you want to resolve everything but one type, you are
1089+
// probably better off writing `resolve_all - resolve_ivar`.
10661090

10671091
const resolve_nested_tvar: uint = 0b00000001;
10681092
const resolve_rvar: uint = 0b00000010;

0 commit comments

Comments
 (0)