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

update error E0451 to new format #36054

Merged
merged 1 commit into from
Aug 30, 2016
Merged

update error E0451 to new format #36054

merged 1 commit into from
Aug 30, 2016

Conversation

mikhail-m1
Copy link
Contributor

Fixes #35928 as part of #35233.

r? @jonathandturner

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jonathandturner (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@sophiajt
Copy link
Contributor

Thanks for the PR!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 27, 2016

📌 Commit a24ea73 has been approved by jonathandturner

@mikhail-m1
Copy link
Contributor Author

I broke compile-fail/functional-struct-update-respects-privacy.rs, trying to fix it

self.check_field(expr.span, adt, field);
for (field, field_span) in variant.fields.iter()
.zip(fields.iter().map(|f| f.span)) {
self.check_field(field_span, adt, field);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mikhail-m1: The problem, I believe, is that fields contains less fields than variant.fields, which means that not all fields are iterated over.

Also I don't think it's guaranteed that the fields in fields and variant.fields occur in the same order - my intuition would be that variant.fields is in the order the fields were defined and fields is in the order the fields were written in the struct literal.

@mikhail-m1
Copy link
Contributor Author

librustc_llvm fails

@TimNN
Copy link
Contributor

TimNN commented Aug 29, 2016

The LLVM error is #36077, to be fixed by #36080.

} else {
expr.span
};
self.check_field(span, adt, field);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should work now, however I'm a bit concerned that the complexity here went from linear to quadratic (for all struct literals). I'm not sure how much of an impact this will have on real world code however there are crates with structs with 1500+ fields in which case this may not be ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't expect so big structs, but this code works only on matching expressions, does any one match more then tens fields?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand the situation correctly, this code runs for every struct literal, ie. let _ = Foo { bar: "hi!" }. And initialising such large structs does happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll rework it

@TimNN
Copy link
Contributor

TimNN commented Aug 29, 2016

I did some (absolutely non-scientific) performance measurements between local stage 1 builds (with and without this pr) and found no real differences in compile time, so the current implementation is probably fine.

@sophiajt
Copy link
Contributor

@TimNN - thanks for checking. Sounds like we're good. Will get this moving again.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 29, 2016

📌 Commit 46fc80c has been approved by jonathandturner

@sophiajt
Copy link
Contributor

@bors r-

I missed the "I broke compile-fail/functional-struct-update-respects-privacy.rs, trying to fix it" comment. Let me know when this gets fixed and I'll put it back through review.

@TimNN
Copy link
Contributor

TimNN commented Aug 29, 2016

@jonathandturner: That should habe been fixed by the updated commit as well.

@sophiajt
Copy link
Contributor

@TimNN - Oh okay. With Travis down for the moment, we're having to guess what will pass based on what failed in previous builds. If you think it's ready, I can re:r+ it

@TimNN
Copy link
Contributor

TimNN commented Aug 29, 2016

@jonathandturner - I'm confident that the previous failure of compile-fail/functional-struct-update-respects-privacy.rs has been fixed. Also since there is no other NOTE matched in that test, the test should be fine as well.

As such I think this pr is good to go.

@sophiajt
Copy link
Contributor

@TimNN - great, thanks for checking

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 29, 2016

📌 Commit 46fc80c has been approved by jonathandturner

bors added a commit that referenced this pull request Aug 29, 2016
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 30, 2016
bors added a commit that referenced this pull request Aug 30, 2016
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 30, 2016
bors added a commit that referenced this pull request Aug 30, 2016
@bors bors merged commit 46fc80c into rust-lang:master Aug 30, 2016
@mikhail-m1 mikhail-m1 deleted the master2 branch November 30, 2016 20:48
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.

5 participants