diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-01-27 15:25:37 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-01-27 15:25:37 +1100 |
| commit | b079ebeb8da4198112831af05c88b48974268337 (patch) | |
| tree | 23961d6c6f7d9d5183a197d1b695682ad5cf5453 /src/libsyntax/ext/deriving/zero.rs | |
| parent | 0b7f823156a9e11126792529ec45c7490fea2fc3 (diff) | |
| download | rust-b079ebeb8da4198112831af05c88b48974268337.tar.gz rust-b079ebeb8da4198112831af05c88b48974268337.zip | |
syntax: improve the spans of some #[deriving] traits.
This makes error messages about (e.g.) `#[deriving(Clone)] struct Foo {
x: Type }` point at `x: Type` rather than `Clone` in the header (while
still referring to the `#[deriving(Clone)]` in the expansion info).
Diffstat (limited to 'src/libsyntax/ext/deriving/zero.rs')
| -rw-r--r-- | src/libsyntax/ext/deriving/zero.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 31020b4a562..dd99e821620 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -57,7 +57,7 @@ pub fn expand_deriving_zero(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn zero_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn zero_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let zero_ident = ~[ cx.ident_of("std"), cx.ident_of("num"), @@ -71,24 +71,24 @@ fn zero_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { match *summary { Unnamed(ref fields) => { if fields.is_empty() { - cx.expr_ident(span, substr.type_ident) + cx.expr_ident(trait_span, substr.type_ident) } else { let exprs = fields.map(|sp| zero_call(*sp)); - cx.expr_call_ident(span, substr.type_ident, exprs) + cx.expr_call_ident(trait_span, substr.type_ident, exprs) } } Named(ref fields) => { let zero_fields = fields.map(|&(ident, span)| { cx.field_imm(span, ident, zero_call(span)) }); - cx.expr_struct_ident(span, substr.type_ident, zero_fields) + cx.expr_struct_ident(trait_span, substr.type_ident, zero_fields) } } } StaticEnum(..) => { - cx.span_err(span, "`Zero` cannot be derived for enums, only structs"); + cx.span_err(trait_span, "`Zero` cannot be derived for enums, only structs"); // let compilation continue - cx.expr_uint(span, 0) + cx.expr_uint(trait_span, 0) } _ => cx.bug("Non-static method in `deriving(Zero)`") }; |
