diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2b6f94e6bf518..5d0b24fdb3ec3 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -181,7 +181,8 @@ pub struct TyParam { pub ident: Ident, pub id: NodeId, pub bounds: OwnedSlice, - pub default: Option> + pub default: Option>, + pub span: Span } #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 203edf6590fb7..c1289ef98588a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -66,6 +66,7 @@ pub trait AstBuilder { fn strip_bounds(&self, bounds: &Generics) -> Generics; fn typaram(&self, + span: Span, id: ast::Ident, bounds: OwnedSlice, default: Option>) -> ast::TyParam; @@ -368,6 +369,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn typaram(&self, + span: Span, id: ast::Ident, bounds: OwnedSlice, default: Option>) -> ast::TyParam { @@ -375,7 +377,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ident: id, id: ast::DUMMY_NODE_ID, bounds: bounds, - default: default + default: default, + span: span } } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 1d4aa08f9e3bd..c040361a8ebb2 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -380,7 +380,7 @@ impl<'a> TraitDef<'a> { // require the current trait bounds.push(cx.typarambound(trait_path.clone())); - cx.typaram(ty_param.ident, OwnedSlice::from_vec(bounds), None) + cx.typaram(self.span, ty_param.ident, OwnedSlice::from_vec(bounds), None) })); let trait_generics = Generics { lifetimes: lifetimes, diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index c4ca2601f601e..a6bbad62b8e79 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -193,7 +193,7 @@ fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, bounds: &[Path], let path = b.to_path(cx, span, self_ident, self_generics); cx.typarambound(path) }).collect(); - cx.typaram(cx.ident_of(name), bounds, None) + cx.typaram(span, cx.ident_of(name), bounds, None) } fn mk_generics(lifetimes: Vec , ty_params: Vec ) -> Generics { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 73ad2664be4c0..72be633d456ad 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -448,7 +448,8 @@ pub fn fold_ty_param(tp: &TyParam, fld: &mut T) -> TyParam { ident: tp.ident, id: id, bounds: tp.bounds.map(|x| fold_ty_param_bound(x, fld)), - default: tp.default.map(|x| fld.fold_ty(x)) + default: tp.default.map(|x| fld.fold_ty(x)), + span: tp.span } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6485b5a3622c9..85480bebc90ef 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3393,6 +3393,7 @@ impl<'a> Parser<'a> { // matches typaram = IDENT optbounds ( EQ ty )? fn parse_ty_param(&mut self) -> TyParam { let ident = self.parse_ident(); + let span = self.span; let (_, opt_bounds) = self.parse_optional_ty_param_bounds(false); // For typarams we don't care about the difference b/w "" and "". let bounds = opt_bounds.unwrap_or_default(); @@ -3407,7 +3408,8 @@ impl<'a> Parser<'a> { ident: ident, id: ast::DUMMY_NODE_ID, bounds: bounds, - default: default + default: default, + span: span, } }