-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Provide better names for builtin deriving-generated attributes #49986
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
Changes from all commits
4ae9488
24d410a
a3241d1
b9b650c
1a72d6d
d80797b
27b0f1e
d6feab6
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 |
---|---|---|
|
@@ -148,8 +148,8 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, | |
], | ||
}, | ||
explicit_self: borrowed_explicit_self(), | ||
args: vec![Ptr(Box::new(Literal(Path::new_local(typaram))), | ||
Borrowed(None, Mutability::Mutable))], | ||
args: vec![(Ptr(Box::new(Literal(Path::new_local(typaram))), | ||
Borrowed(None, Mutability::Mutable)), "s")], | ||
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. "encoder"? |
||
ret_ty: Literal(Path::new_( | ||
pathvec_std!(cx, result::Result), | ||
None, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -543,6 +543,10 @@ impl<'a, 'b> Context<'a, 'b> { | |
let mut pats = Vec::new(); | ||
let mut heads = Vec::new(); | ||
|
||
let names_pos: Vec<_> = (0..self.args.len()).map(|i| { | ||
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. This had to go all the way up here because... something to do with E0382. Self gets moved into the expression below with |
||
self.ecx.ident_of(&format!("arg{}", i)).gensym() | ||
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. Bikeshed opportunity: 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. shrug this is never exposed so it doesn't matter |
||
}).collect(); | ||
|
||
// First, build up the static array which will become our precompiled | ||
// format "string" | ||
let pieces = self.ecx.expr_vec_slice(self.fmtsp, self.str_pieces); | ||
|
@@ -560,7 +564,7 @@ impl<'a, 'b> Context<'a, 'b> { | |
// of each variable because we don't want to move out of the arguments | ||
// passed to this function. | ||
for (i, e) in self.args.into_iter().enumerate() { | ||
let name = self.ecx.ident_of(&format!("__arg{}", i)); | ||
let name = names_pos[i]; | ||
let span = | ||
DUMMY_SP.with_ctxt(e.span.ctxt().apply_mark(self.ecx.current_expansion.mark)); | ||
pats.push(self.ecx.pat_ident(span, name)); | ||
|
@@ -570,14 +574,12 @@ impl<'a, 'b> Context<'a, 'b> { | |
heads.push(self.ecx.expr_addr_of(e.span, e)); | ||
} | ||
for pos in self.count_args { | ||
let name = self.ecx.ident_of(&match pos { | ||
Exact(i) => format!("__arg{}", i), | ||
_ => panic!("should never happen"), | ||
}); | ||
let span = match pos { | ||
Exact(i) => spans_pos[i], | ||
let index = match pos { | ||
Exact(i) => i, | ||
_ => panic!("should never happen"), | ||
}; | ||
let name = names_pos[index]; | ||
let span = spans_pos[index]; | ||
counts.push(Context::format_arg(self.ecx, self.macsp, span, &Count, name)); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)] | ||
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. nit: spaces between commas (also change the commit message to just "test deriving hygiene") 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. (noted, although I was advised on IRC that I should squash the commits before merging anyway so I've been giving the commit messages a little less care – let me know if that's not the case) 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. You're free to, but I personally prefer them to stay logically separate if possible, provided they build individually. So squash the fixups together into logical changes, but you can leave them separate otherwise. Or just squash it all if you want, either way. |
||
struct Foo {} | ||
|
||
fn main() { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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. | ||
|
||
pub const arg0: u8 = 1; | ||
|
||
pub fn main() { | ||
format!("{}", 1); | ||
} |
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.
"decoder"?
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.
Also from the trait. Relatedly... are these (decodable/encodable) even used? I couldn't find any references to these in the docs.
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.
They are, they're from a deprecated builtin thing. See the rustc_serialize crate.