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

Typecheck refactor for ! #35787

Merged
merged 20 commits into from
Sep 5, 2016
Merged

Conversation

canndrew
Copy link
Contributor

Ping @nikomatsakis @eddyb. This is the PR for the typeck refactor for !. Is this what you guys had in mind? Is there anything else that needs doing on it?

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -38,12 +38,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.write_ty(pat.id, expected);
}
PatKind::Lit(ref lt) => {
self.check_expr(&lt);
let expr_ty = self.expr_ty(&lt);
let expr_t = self.check_expr(&lt);
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? expr_ty is a better name for such a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because having a method named expr_ty and a variable named expr_ty is confusing.

Copy link
Member

Choose a reason for hiding this comment

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

I find _t worse. Besides, why do we still need the expr_ty method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expr_ty is still used in a few places. I can keep going trying to remove it entirely if you like. Otherwise I can rename the variable ty.

Copy link
Member

Choose a reason for hiding this comment

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

Either sound good, thanks!

@arielb1
Copy link
Contributor

arielb1 commented Aug 18, 2016

I would move the match in check_expr_with_expectation_and_lvalue_pref to its own function, to prevent confusion if someone introduces a return there.

}
hir::ExprBlock(ref b) => {
self.check_block_with_expected(&b, expected);
self.write_ty(id, self.node_ty(b.id));
self.node_ty(b.id)
Copy link
Member

Choose a reason for hiding this comment

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

check_block_with_expected should return the type.

@canndrew
Copy link
Contributor Author

@eddyb is this PR good to go? I can do the same thing with patterns (factoring out write_ty) if you'd like.

@eddyb
Copy link
Member

eddyb commented Aug 22, 2016

@canndrew Yeah, doing that would be great. Are there many expr_ty calls left, btw?

@bors
Copy link
Contributor

bors commented Aug 27, 2016

☔ The latest upstream changes (presumably #36030) made this pull request unmergeable. Please resolve the merge conflicts.

@canndrew canndrew force-pushed the bang_type_refactor_check branch from a5c390f to 234939a Compare August 27, 2016 17:21
@canndrew
Copy link
Contributor Author

I've done the factoring-out for patterns. There's still some uses of expr_ty left though most of them look like they'll be non-trivial to get rid of (the ones in coercion.rs and confirm.rs).

@eddyb
Copy link
Member

eddyb commented Aug 27, 2016

@canndrew Can't both of those takes the types in? Although not confirm.rs if it's a late adjustment.
That is, I'd like to remove uses of expr_ty that are done near the expression being type-checked, and keep only those that are deferred, possibly manually getting the node type if there's only 2-3 of them.

@canndrew
Copy link
Contributor Author

I've made the coercions code take the types as arguments.

The code in confirm.rs walks over a big expression tree reading the types using expr_ty. So there's no way to pass the types in there. I could replace the expr_tys with node_tys but it means that code will no longer be able to see the AdjustNeverToAny coercion (does that matter?).

@@ -414,11 +414,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
_ => result_ty
};

let mut arm_tys = Vec::new();
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be needed though. The design was such that no extra bookkeeping was needed.

@canndrew
Copy link
Contributor Author

Any idea what these LLVM linker errors are about?

@bors
Copy link
Contributor

bors commented Sep 3, 2016

☔ The latest upstream changes (presumably #36016) made this pull request unmergeable. Please resolve the merge conflicts.

@canndrew canndrew force-pushed the bang_type_refactor_check branch from 12e74d8 to c9a340e Compare September 5, 2016 06:43
@canndrew
Copy link
Contributor Author

canndrew commented Sep 5, 2016

@eddyb I rebased this and now it's passing. Is it good to merge?

@eddyb
Copy link
Member

eddyb commented Sep 5, 2016

@bors r+ Thanks!

@bors
Copy link
Contributor

bors commented Sep 5, 2016

📌 Commit c9a340e has been approved by eddyb

@bors
Copy link
Contributor

bors commented Sep 5, 2016

⌛ Testing commit c9a340e with merge 58dc448...

bors added a commit that referenced this pull request Sep 5, 2016
Typecheck refactor for `!`

Ping @nikomatsakis @eddyb. This is the PR for the typeck refactor for `!`. Is this what you guys had in mind? Is there anything else that needs doing on it?
@bors bors merged commit c9a340e into rust-lang:master Sep 5, 2016
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.

6 participants