-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
cleanups and fixes for #[derive] #32139
Conversation
High five? No high five? ✋ 😿 |
☔ The latest upstream changes (presumably #32009) made this pull request unmergeable. Please resolve the merge conflicts. |
The failing test is here and I don't really know how to interpret it. I guess the |
I think that issue (#24047) should not be worked around in derive but it may be fixed directly instead. |
I can back out that commit and leave it for later. On Tue, Mar 8, 2016 at 10:59 PM, bluss notifications@github.com wrote:
|
let eq = cx.expr_binary(span, | ||
BinOpKind::Ne, | ||
cx.expr_addr_of(span, self_f), | ||
cx.expr_addr_of(span, other_f.clone())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the past we've had subtle bugs where fields didn't actually implement some trait you were deriving but it worked anyway, so I'm curious why the extra &
is needed here? In theory that should all happen automatically, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because of this: http://is.gd/Dgj5u2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I'm somewhat confused, each of those lines works independently? Perhaps this is a case where UFCS should be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah maybe we should use UFCS in the derive expansion, but there's a deeper issue (which is why @bluss suggested not working around it here)... line 17 should be exactly the same as line 19, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps yeah? I'm not too familiar with auto-ref and how that works
Wait this is an issue that can be fixed? |
Oh then I keep reading and realize it's |
Yes it can be fixed. The code snippet I showed in that issue is a bug that's independent of derive itself. |
OK I addressed the comments and removed the two commits related to #24047 (don't worry I still have them in another branch!). Let's see if it builds! |
@@ -8,32 +8,33 @@ | |||
// option. This file may not be copied, modified, or distributed | |||
// except according to those terms. | |||
|
|||
#![feature(rand, collections, rustc_private)] | |||
#![no_std] | |||
// no-prefer-dynamic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record I have no idea what this does, but without it it asks for the lang items (even though this is supposed to be a lib).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah building a dylib requires lang items to be resolved, but as an rlib (what no-prefer-dynamic asks for) means that they can stay dangling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already says #![crate_type = "rlib"]
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but that's ignored as --crate-type dylib
is passed on the command line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I'll take that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually #![crate_type = "rlib"]
and // no-prefer-dynamic
are required for it not to try and resolve the lang items.
3831056
to
47900e6
Compare
/// Construct a name for the inner type parameter that can't collide with any type parameters of | ||
/// the item. This is achieved by starting with a base and then concatenating the names of all | ||
/// other type parameters. | ||
fn hygienic_type_parameter(item: &Annotatable, base: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this may want to continue to have a FIXME for doing something "more correct" here, this seems like it's still kinda a hack to get the job done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a hack yes (but a better one than before IMO). I'll add a FIXME.
Thanks @durka! Just a comment to be added I think but other than that looks good to me. |
Added the FIXME comment. |
cleanups and fixes for #[derive] This contains a bunch of little cleanups and fixes to `#[derive]`. There are more extensive comments on each individual commit. - hygiene cleanups - use `discriminant_value` instead of variant index in `#[derive(Hash)]` - ~~don't move out of borrowed content in `#[derive(PartialOrd, PartialEq)]`~~ - use `intrinsics::unreachable()` instead of `unreachable!()` I don't believe there are any breaking changes in here, but I do want some more eyes on that. Fixes #2810 (!), I believe (we still assume that "std" or "core" is the standard library but so does the rest of rustc...). Fixes #21714 (cc @apasel422). ~~Fixes~~ (postponed) #24047 (cc @withoutboats @bluss). Fixes #31714 (cc @alexcrichton @bluss). Fixes #31886 (cc @oli-obk).
💔 Test failed - auto-mac-32-opt |
@bors: retry On Sun, Mar 13, 2016 at 12:24 PM, bors notifications@github.com wrote:
|
⌛ Testing commit a037073 with merge fb9b646... |
@bors: retry force |
⌛ Testing commit a037073 with merge afacbfd... |
💔 Test failed - auto-mac-32-opt |
Okay what the heck is going on. |
@bors retry |
⌛ Testing commit a037073 with merge 97339bc... |
💔 Test failed - auto-mac-32-opt |
This is starting to seem legitimate just by repetition! I'm thinking I
|
Something seems to be getting oddly mixed up as it's referencing stage1 dylibs? Probably couldn't hurt to break apart though I guess? |
derive: use intrinsics::unreachable over unreachable!() derive: use intrinsics::unreachable over unreachable!() Fixes #31574. Spawned from #32139. r? @alexcrichton
derive: clean up hygiene derive: clean up hygiene Fixes #2810. Spawned from #32139. r? @alexcrichton
derive: assume enum repr defaults to isize derive: assume enum repr defaults to isize Fixes #31886. Spawned from #32139. r? @alexcrichton
derive: use discriminant_value in #[derive(Hash)] derive: use discriminant_value in #[derive(Hash)] Fixes #21714. Spawned from #32139. r? @alexcrichton
derive: use discriminant_value in #[derive(Hash)] derive: use discriminant_value in #[derive(Hash)] Fixes #21714. Spawned from #32139. r? @alexcrichton
derive: use discriminant_value in #[derive(Hash)] derive: use discriminant_value in #[derive(Hash)] Fixes rust-lang#21714. Spawned from rust-lang#32139. r? @alexcrichton
This contains a bunch of little cleanups and fixes to
#[derive]
. There are more extensive comments on each individual commit.discriminant_value
instead of variant index in#[derive(Hash)]
don't move out of borrowed content in#[derive(PartialOrd, PartialEq)]
intrinsics::unreachable()
instead ofunreachable!()
I don't believe there are any breaking changes in here, but I do want some more eyes on that.
Fixes #2810 (!), I believe (we still assume that "std" or "core" is the standard library but so does the rest of rustc...).
Fixes #21714 (cc @apasel422).
Fixes(postponed) #24047 (cc @withoutboats @bluss).Fixes #31714 (cc @alexcrichton @bluss).
Fixes #31886 (cc @oli-obk).