-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Use UFCS in the expansion of #[deriving(Clone)]
#18578
Conversation
@@ -276,7 +276,6 @@ | |||
|
|||
#![stable] | |||
|
|||
use clone::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.
Won't these imports still be needed for stage0?
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.
These imports get flagged by the #[deny(unused_imports]
lint on stage1. But the compiler bootstraps fine after I removed them (I did make clean
before trying a new make
). So... yeah I'm not sure why this actually works.
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.
You may have to tag these with #[cfg(stage0)]
to get past both stage0 and stage1+
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 meant that this passes all the stages as it is.
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.
Interesting... well let's see what bors says!
Looks great, thanks @japaric! |
@alexcrichton Had to rebase after the last roll-up. re-r? |
let subcall = |field: &FieldInfo| | ||
cx.expr_method_call(field.span, field.self_.clone(), clone_ident, Vec::new()); | ||
let fn_path = vec![ | ||
cx.ident_of("std"), |
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.
Won't this break deriving when using #[no_std]
? It seems like this should be core
.
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.
Most crates (those that don't use #[no_std]
) don't link to the core
crate, hence ::core::clone::Clone
yields "error: failed to resolve. Maybe a missing extern crate core
?".
Users of #[no_std]
can use this work around to access this syntax extension.
Changes the return expression of expanded
clone
method from e.g.Slice((*__self_0).clone())
toSlice(::std::clone::Clone::clone(&(*__self_0)))
Fixes the second half of #15689
(The first half will be fixed by #18467)
Note #18523 must be merged first or this will ICE during
make
r? @alexcrichton
(I can squash the commits after the review)