Skip to content

Commit e359ee2

Browse files
authored
New infcx usage (#1571)
Fixes rust-lang/rustc-dev-guide#1543
1 parent 4a1d549 commit e359ee2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/type-inference.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ signature, such as the `'a` in `for<'a> fn(&'a u32)`. A region is
3636

3737
## Creating an inference context
3838

39-
You create and "enter" an inference context by doing something like
39+
You create an inference context by doing something like
4040
the following:
4141

4242
```rust,ignore
43-
tcx.infer_ctxt().enter(|infcx| {
44-
// Use the inference context `infcx` here.
45-
})
43+
let infcx = tcx.infer_ctxt().build();
44+
// Use the inference context `infcx` here.
4645
```
4746

48-
Within the closure,
49-
`infcx` has the type `InferCtxt<'a, 'tcx>` for some fresh `'a`,
50-
while `'tcx` is the same as outside the inference context.
47+
`infcx` has the type `InferCtxt<'tcx>`, the same `'tcx` lifetime as on
48+
the `tcx` it was built from.
5149

5250
The `tcx.infer_ctxt` method actually returns a builder, which means
5351
there are some kinds of configuration you can do before the `infcx` is

0 commit comments

Comments
 (0)