Skip to content

Refactor upvar mode inference #20432

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

Merged
merged 8 commits into from
Jan 3, 2015
Merged

Conversation

nikomatsakis
Copy link
Contributor

Previously, the borrow mode of each upvar was inferred as part of regionck. This PR moves it into its own separate step. It also employs the ExprUseVisitor, further simplifying the code. The eventual goal is to support better inference of Fn vs FnMut vs FnOnce that is not based on the expected type, as well as supporting individual by-move upvars.

r? @eddyb

}).ty
base_ty.map(|t| {
ty::deref(t, false).unwrap_or_else(|| {
panic!("encountered BindByRef with non &-type");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this panic! still here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Just an ICE waiting to happen.

expr-use-visitor) early.  Turns out I was wrong to remove this; it
causes a lot of pain trying to run EUV etc during typeck without
ICEing on erroneous programs.
… overflow,

which should always result in an error.

NB. Some of the hunks in this commit rely on a later commit which adds
`tcx` into `param_env` and modifies `ParameterEnvironment` to
implement `Typer`.
`UnboxedClosureTyper`. This requires adding a `tcx` field to
`ParameterEnvironment` but generally simplifies everything since we
only need to pass along an `UnboxedClosureTyper` or `Typer`.
and which uses EUV. For now, upvar inference is not any smarter than
it ever was, but regionck is simpler because it doesn't have to do as
many things at once.
bors added a commit that referenced this pull request Jan 3, 2015
Previously, the borrow mode of each upvar was inferred as part of regionck. This PR moves it into its own separate step. It also employs the `ExprUseVisitor`, further simplifying the code. The eventual goal is to support better inference of `Fn` vs `FnMut` vs `FnOnce` that is not based on the expected type, as well as supporting individual by-move upvars.

r? @eddyb
@bors bors merged commit cbeff8b into rust-lang:master Jan 3, 2015
edwardw added a commit to edwardw/rust that referenced this pull request Jan 23, 2015
As part of rust-lang#20432, upvar checking is now moved out of regionck to its
own pass and before regionck. But regionck has some type resolution of
it own. Without them, now separated upvar checking may be tripped over
by residue `ty_infer`.

Closes rust-lang#21306
edwardw added a commit to edwardw/rust that referenced this pull request Jan 23, 2015
As part of rust-lang#20432, upvar checking is now moved out of regionck to its
own pass and before regionck. But regionck has some type resolution of
its own. Without them, now separated upvar checking may be tripped over
by residue `ty_infer`.

Closes rust-lang#21306
bors added a commit that referenced this pull request Jan 25, 2015
As part of #20432, upvar checking is now moved out of regionck to its
own pass and before regionck. But regionck has some type resolution of
its own. Without them, now separated upvar checking may be tripped over
by residue `ty_infer`.

Closes #21306
@nikomatsakis nikomatsakis deleted the fn-inference-2 branch March 30, 2016 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants