diff options
| author | nils <48135649+Nilstrieb@users.noreply.github.com> | 2023-01-30 16:08:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-31 00:08:16 +0900 |
| commit | f3243f302490b536ce99cd68a34f03c42ec28f23 (patch) | |
| tree | 40ec8b0b86a86ca78bebd27fdb14e594a8d0cd17 /src/doc/rustc-dev-guide | |
| parent | a0840d6a9ba9025918bf8eca44c978711c84a69a (diff) | |
| download | rust-f3243f302490b536ce99cd68a34f03c42ec28f23.tar.gz rust-f3243f302490b536ce99cd68a34f03c42ec28f23.zip | |
New infcx usage (#1571)
Fixes https://github.com/rust-lang/rustc-dev-guide/issues/1543
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/type-inference.md | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/doc/rustc-dev-guide/src/type-inference.md b/src/doc/rustc-dev-guide/src/type-inference.md index ca88c168636..2bafeb24792 100644 --- a/src/doc/rustc-dev-guide/src/type-inference.md +++ b/src/doc/rustc-dev-guide/src/type-inference.md @@ -36,18 +36,16 @@ signature, such as the `'a` in `for<'a> fn(&'a u32)`. A region is ## Creating an inference context -You create and "enter" an inference context by doing something like +You create an inference context by doing something like the following: ```rust,ignore -tcx.infer_ctxt().enter(|infcx| { - // Use the inference context `infcx` here. -}) +let infcx = tcx.infer_ctxt().build(); +// Use the inference context `infcx` here. ``` -Within the closure, -`infcx` has the type `InferCtxt<'a, 'tcx>` for some fresh `'a`, -while `'tcx` is the same as outside the inference context. +`infcx` has the type `InferCtxt<'tcx>`, the same `'tcx` lifetime as on +the `tcx` it was built from. The `tcx.infer_ctxt` method actually returns a builder, which means there are some kinds of configuration you can do before the `infcx` is |
