Skip to content

Commit c3b2f2b

Browse files
committed
Add a span to ast::TyParam
1 parent 09bfb92 commit c3b2f2b

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

src/libsyntax/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ pub struct TyParam {
181181
pub ident: Ident,
182182
pub id: NodeId,
183183
pub bounds: OwnedSlice<TyParamBound>,
184-
pub default: Option<P<Ty>>
184+
pub default: Option<P<Ty>>,
185+
pub span: Span
185186
}
186187

187188
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]

src/libsyntax/ext/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub trait AstBuilder {
6666
fn strip_bounds(&self, bounds: &Generics) -> Generics;
6767

6868
fn typaram(&self,
69+
span: Span,
6970
id: ast::Ident,
7071
bounds: OwnedSlice<ast::TyParamBound>,
7172
default: Option<P<ast::Ty>>) -> ast::TyParam;
@@ -368,14 +369,16 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
368369
}
369370

370371
fn typaram(&self,
372+
span: Span,
371373
id: ast::Ident,
372374
bounds: OwnedSlice<ast::TyParamBound>,
373375
default: Option<P<ast::Ty>>) -> ast::TyParam {
374376
ast::TyParam {
375377
ident: id,
376378
id: ast::DUMMY_NODE_ID,
377379
bounds: bounds,
378-
default: default
380+
default: default,
381+
span: span
379382
}
380383
}
381384

src/libsyntax/ext/deriving/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<'a> TraitDef<'a> {
380380
// require the current trait
381381
bounds.push(cx.typarambound(trait_path.clone()));
382382

383-
cx.typaram(ty_param.ident, OwnedSlice::from_vec(bounds), None)
383+
cx.typaram(self.span, ty_param.ident, OwnedSlice::from_vec(bounds), None)
384384
}));
385385
let trait_generics = Generics {
386386
lifetimes: lifetimes,

src/libsyntax/ext/deriving/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, bounds: &[Path],
193193
let path = b.to_path(cx, span, self_ident, self_generics);
194194
cx.typarambound(path)
195195
}).collect();
196-
cx.typaram(cx.ident_of(name), bounds, None)
196+
cx.typaram(span, cx.ident_of(name), bounds, None)
197197
}
198198

199199
fn mk_generics(lifetimes: Vec<ast::Lifetime> , ty_params: Vec<ast::TyParam> ) -> Generics {

src/libsyntax/fold.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ pub fn fold_ty_param<T: Folder>(tp: &TyParam, fld: &mut T) -> TyParam {
448448
ident: tp.ident,
449449
id: id,
450450
bounds: tp.bounds.map(|x| fold_ty_param_bound(x, fld)),
451-
default: tp.default.map(|x| fld.fold_ty(x))
451+
default: tp.default.map(|x| fld.fold_ty(x)),
452+
span: tp.span
452453
}
453454
}
454455

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3393,6 +3393,7 @@ impl<'a> Parser<'a> {
33933393
// matches typaram = IDENT optbounds ( EQ ty )?
33943394
fn parse_ty_param(&mut self) -> TyParam {
33953395
let ident = self.parse_ident();
3396+
let span = self.span;
33963397
let (_, opt_bounds) = self.parse_optional_ty_param_bounds(false);
33973398
// For typarams we don't care about the difference b/w "<T>" and "<T:>".
33983399
let bounds = opt_bounds.unwrap_or_default();
@@ -3407,7 +3408,8 @@ impl<'a> Parser<'a> {
34073408
ident: ident,
34083409
id: ast::DUMMY_NODE_ID,
34093410
bounds: bounds,
3410-
default: default
3411+
default: default,
3412+
span: span,
34113413
}
34123414
}
34133415

0 commit comments

Comments
 (0)