Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New infcx usage #1571

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/type-inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down