]> git.lizzy.rs Git - rust.git/commitdiff
Add a span to ast::TyParam
authorNick Cameron <ncameron@mozilla.com>
Thu, 3 Apr 2014 00:53:57 +0000 (13:53 +1300)
committerNick Cameron <ncameron@mozilla.com>
Wed, 23 Apr 2014 00:30:58 +0000 (12:30 +1200)
src/libsyntax/ast.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/deriving/ty.rs
src/libsyntax/fold.rs
src/libsyntax/parse/parser.rs

index 2b6f94e6bf5188008b4ab65f54f22157c3cd9145..5d0b24fdb3ec3abf0d7bceb17c18b291276ec6f5 100644 (file)
@@ -181,7 +181,8 @@ pub struct TyParam {
     pub ident: Ident,
     pub id: NodeId,
     pub bounds: OwnedSlice<TyParamBound>,
-    pub default: Option<P<Ty>>
+    pub default: Option<P<Ty>>,
+    pub span: Span
 }
 
 #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
index 203edf6590fb771cdad0e7f5edde1bc0474c65c7..c1289ef98588a038875a1f0bf0441b0241216fd8 100644 (file)
@@ -66,6 +66,7 @@ fn ty_rptr(&self, span: Span,
     fn strip_bounds(&self, bounds: &Generics) -> Generics;
 
     fn typaram(&self,
+               span: Span,
                id: ast::Ident,
                bounds: OwnedSlice<ast::TyParamBound>,
                default: Option<P<ast::Ty>>) -> ast::TyParam;
@@ -368,6 +369,7 @@ fn ty_nil(&self) -> P<ast::Ty> {
     }
 
     fn typaram(&self,
+               span: Span,
                id: ast::Ident,
                bounds: OwnedSlice<ast::TyParamBound>,
                default: Option<P<ast::Ty>>) -> ast::TyParam {
@@ -375,7 +377,8 @@ fn typaram(&self,
             ident: id,
             id: ast::DUMMY_NODE_ID,
             bounds: bounds,
-            default: default
+            default: default,
+            span: span
         }
     }
 
index 1d4aa08f9e3bd7f6b7f3fa80ad66e80e704b2381..c040361a8ebb282366dfb8be932b672faa87d3ea 100644 (file)
@@ -380,7 +380,7 @@ fn create_derived_impl(&self,
             // 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,
index c4ca2601f601e27bc056ea9a41c30f1e26873388..a6bbad62b8e795f7818fc798b46e6d71e0b010c4 100644 (file)
@@ -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<ast::Lifetime> ,  ty_params: Vec<ast::TyParam> ) -> Generics {
index 73ad2664be4c078312b400f54e1f46d585bc691d..72be633d456ad4dd51f6d5f749d667a4abb86a71 100644 (file)
@@ -448,7 +448,8 @@ pub fn fold_ty_param<T: Folder>(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
     }
 }
 
index 6485b5a3622c9db9683bcceba305fe8711830b03..85480bebc90ef95ab8dee94ec2634f2f60b5c30e 100644 (file)
@@ -3393,6 +3393,7 @@ fn parse_optional_ty_param_bounds(&mut self, allow_any_lifetime: bool)
     // 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 "<T>" and "<T:>".
         let bounds = opt_bounds.unwrap_or_default();
@@ -3407,7 +3408,8 @@ fn parse_ty_param(&mut self) -> TyParam {
             ident: ident,
             id: ast::DUMMY_NODE_ID,
             bounds: bounds,
-            default: default
+            default: default,
+            span: span,
         }
     }