diff options
| author | bors <bors@rust-lang.org> | 2018-04-25 01:50:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-25 01:50:56 +0000 |
| commit | 0c5740feb24bff4f13b68b565288dd8a42ab93f6 (patch) | |
| tree | f4ae998795d7e3ec2cfcbf0ccd3aa1c6816ccb08 /src/test/run-pass-fulldeps | |
| parent | 190a6c41cf2afdb11e81545846f2639ee96998e8 (diff) | |
| parent | d6feab6f57a4fd284640b255a53b6e5727cf1b78 (diff) | |
| download | rust-0c5740feb24bff4f13b68b565288dd8a42ab93f6.tar.gz rust-0c5740feb24bff4f13b68b565288dd8a42ab93f6.zip | |
Auto merge of #49986 - zofrex:better-derived-argument-names, r=Manishearth
Provide better names for builtin deriving-generated attributes First attempt at fixing #49967 Not in love with any choices here, don't be shy if you aren't happy with anything :) I've tested that this produces nicer names in documentation, and that it no longer has issues conflicting with constants with the same name. (I guess we _could_ make a test for that... unsure if that would be valuable) In all cases I took the names from the methods as declared in the relevant trait. In some cases I had to prepend the names with _ otherwise there were errors about un-used variables. I'm uneasy with the inconsistency... do they all need to be like that? Is there a way to generate an alternate impl or use a different name (`_`?) in the cases where the arguments are not used? Lastly the gensym addition to Ident I implemented largely as suggested, but I want to point out it's a little circuitous (at least, as far as I understand it). `cx.ident_of(name)` is just `Ident::from_str`, so we create an Ident then another Ident from it. `Ident::with_empty_ctxt(Symbol::gensym(string))` may or may not be equivalent, I don't know if it's important to intern it _then_ gensym it. It seems like either we could use that, or if we do want a new method to make this convenient, it could be on Ident instead (`from_str_gensymed`?)
Diffstat (limited to 'src/test/run-pass-fulldeps')
| -rw-r--r-- | src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/deriving-hygiene.rs | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs index f485982e2d3..6d5e82c68cc 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs @@ -58,7 +58,7 @@ fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, it name: "eq", generics: LifetimeBounds::empty(), explicit_self: borrowed_explicit_self(), - args: vec![borrowed_self()], + args: vec![(borrowed_self(), "other")], ret_ty: Literal(deriving::generic::ty::Path::new_local("bool")), attributes: attrs, is_unsafe: false, diff --git a/src/test/run-pass-fulldeps/deriving-hygiene.rs b/src/test/run-pass-fulldeps/deriving-hygiene.rs new file mode 100644 index 00000000000..532f2456599 --- /dev/null +++ b/src/test/run-pass-fulldeps/deriving-hygiene.rs @@ -0,0 +1,25 @@ +// Copyright 2018 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. + +#![feature(rustc_private)] +extern crate serialize; + +pub const other: u8 = 1; +pub const f: u8 = 1; +pub const d: u8 = 1; +pub const s: u8 = 1; +pub const state: u8 = 1; +pub const cmp: u8 = 1; + +#[derive(Ord,Eq,PartialOrd,PartialEq,Debug,Decodable,Encodable,Hash)] +struct Foo {} + +fn main() { +} |
