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

Check other rvalues #19

Merged
merged 17 commits into from
Dec 2, 2017

Conversation

spastorino
Copy link
Collaborator

@spastorino spastorino commented Nov 28, 2017

#15 but done on top of nll-master

This should close rust-lang#45827 and rust-lang#45959.

@spastorino spastorino mentioned this pull request Nov 28, 2017
@spastorino spastorino force-pushed the check_other_rvalues branch 5 times, most recently from 2943e65 to 5b8a13d Compare November 28, 2017 05:48
Copy link
Owner

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Lookin' good. Two nits.

@@ -59,7 +59,7 @@ pub fn type_check<'a, 'gcx, 'tcx>(
}

fn mirbug(tcx: TyCtxt, span: Span, msg: &str) {
tcx.sess.diagnostic().span_bug(span, msg);
tcx.sess.diagnostic().delay_span_bug(span, msg);
Copy link
Owner

Choose a reason for hiding this comment

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

maybe worth a comment here -- something like:

// We sometimes see MIR failures (notably predicate failures) due to
// the fact that we check rvalue sized predicates here. So use `delay_span_bug`
// to avoid reporting bugs in those cases.


AggregateKind::Closure(def_id, substs) |
AggregateKind::Generator(def_id, substs, _) => {
tcx.predicates_of(*def_id).instantiate(tcx, substs.substs)
Copy link
Owner

Choose a reason for hiding this comment

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

I realized that this code should probably move into this match arm

@spastorino
Copy link
Collaborator Author

@nikomatsakis addressed both things

self.prove_aggregate_predicates(aggregate_kind, location);

match aggregate_kind {
if *aggregate_kind == AggregateKind::Tuple {
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: if we are going to "return early" for tuples, we should have bug! cases for the prove_aggregate_predicates function etc. Otherwise if people tried to add code there there might be confusion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The other thing we could do is to leave prove_aggregate_predicates before the early return as it was ... so if you want to handle Tuples there you can.

Copy link
Owner

Choose a reason for hiding this comment

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

Either would be fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Otherwise, `run-pass/typeck-fn-to-unsafe-fn-ptr.rs` fails the MIR type checker.
These tests had FIXMEs for errors that were not previously being
reported.
@nikomatsakis nikomatsakis merged commit 3eb4284 into nikomatsakis:nll-master Dec 2, 2017
nikomatsakis pushed a commit that referenced this pull request Sep 12, 2019
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.

2 participants