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

Use UFCS in the expansion of #[deriving(Clone)] #18578

Merged
merged 6 commits into from
Nov 4, 2014
Merged

Conversation

japaric
Copy link
Member

@japaric japaric commented Nov 3, 2014

Changes the return expression of expanded clone method from e.g. Slice((*__self_0).clone()) to Slice(::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)

@@ -276,7 +276,6 @@

#![stable]

use clone::Clone;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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+

Copy link
Member Author

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.

Copy link
Member

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!

@alexcrichton
Copy link
Member

Looks great, thanks @japaric!

@japaric
Copy link
Member Author

japaric commented Nov 3, 2014

@alexcrichton Had to rebase after the last roll-up. re-r?

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Nov 4, 2014
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"),
Copy link
Contributor

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.

Copy link
Member Author

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.

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.

4 participants