diff options
| author | Douglas Campos <qmx@qmx.me> | 2017-09-29 21:57:12 -0400 |
|---|---|---|
| committer | Douglas Campos <qmx@qmx.me> | 2017-09-29 22:34:49 -0400 |
| commit | 59e778e5e1932eaa97cd46bca8f58a8233c579d1 (patch) | |
| tree | b55eff65aadc4c166cb633279ed12b631da3a976 | |
| parent | 08e1f0b9d74ac5cdf115b9548d10da1ca01f966d (diff) | |
| download | rust-59e778e5e1932eaa97cd46bca8f58a8233c579d1.tar.gz rust-59e778e5e1932eaa97cd46bca8f58a8233c579d1.zip | |
improve documentation for resolve()
| -rw-r--r-- | src/librustc/ty/instance.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 6f1be020c7b..9560d6359a5 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -116,8 +116,24 @@ impl<'a, 'b, 'tcx> Instance<'tcx> { self.def.def_id() } - /// The point where linking happens. Resolve a (def_id, substs) - /// pair to an instance. + /// Resolve a (def_id, substs) pair to an (optional) instance -- most commonly, + /// this is used to find the precise code that will run for a trait method invocation, + /// if known. + /// + /// Returns `None` if we cannot resolve `Instance` to a specific instance. + /// For example, in a context like this, + /// + /// ``` + /// fn foo<T: Debug>(t: T) { ... } + /// ``` + /// + /// trying to resolve `Debug::fmt` applied to `T` will yield `None`, because we do not + /// know what code ought to run. (Note that this setting is also affected by the + /// `RevealMode` in the parameter environment.) + /// + /// Presuming that coherence and type-check have succeeded, if this method is invoked + /// in a monomorphic context (i.e., like during trans), then it is guaranteed to return + /// `Some`. pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, def_id: DefId, |
