-
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
Changes from all commits
2a7fb35
8d5208a
07bbde8
6d951b2
b8fad35
03b568a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,7 +276,6 @@ | |
|
||
#![stable] | ||
|
||
use clone::Clone; | ||
use cmp::PartialEq; | ||
use std::fmt::Show; | ||
use slice; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,11 +52,19 @@ fn cs_clone( | |
name: &str, | ||
cx: &mut ExtCtxt, trait_span: Span, | ||
substr: &Substructure) -> P<Expr> { | ||
let clone_ident = substr.method_ident; | ||
let ctor_ident; | ||
let all_fields; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Won't this break deriving when using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most crates (those that don't use Users of |
||
cx.ident_of("clone"), | ||
cx.ident_of("Clone"), | ||
cx.ident_of("clone"), | ||
]; | ||
let subcall = |field: &FieldInfo| { | ||
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())]; | ||
|
||
cx.expr_call_global(field.span, fn_path.clone(), args) | ||
}; | ||
|
||
match *substr.fields { | ||
Struct(ref af) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[deriving(Clone)] | ||
enum Test<'a> { | ||
Slice(&'a int) | ||
} | ||
|
||
fn main() {} |
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 didmake clean
before trying a newmake
). 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!