From 6375b77ebb640001e9d076eec8601d926d2543f7 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 27 Jul 2017 13:37:35 +0900 Subject: [PATCH] Add Span to ast::WhereClause --- src/libsyntax/ast.rs | 2 ++ src/libsyntax/fold.rs | 5 +++-- src/libsyntax/parse/mod.rs | 1 + src/libsyntax/parse/parser.rs | 4 ++++ src/libsyntax/print/pprust.rs | 2 ++ src/libsyntax_ext/deriving/generic/ty.rs | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f7d9d532062..ff9266fb0cb 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -321,6 +321,7 @@ fn default() -> Generics { where_clause: WhereClause { id: DUMMY_NODE_ID, predicates: Vec::new(), + span: DUMMY_SP, }, span: DUMMY_SP, } @@ -332,6 +333,7 @@ fn default() -> Generics { pub struct WhereClause { pub id: NodeId, pub predicates: Vec, + pub span: Span, } /// A single predicate in a `where` clause diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index eaec1eef172..714f02969ec 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -736,14 +736,15 @@ pub fn noop_fold_generics(Generics {ty_params, lifetimes, where_claus } pub fn noop_fold_where_clause( - WhereClause {id, predicates}: WhereClause, + WhereClause {id, predicates, span}: WhereClause, fld: &mut T) -> WhereClause { WhereClause { id: fld.new_id(id), predicates: predicates.move_map(|predicate| { fld.fold_where_predicate(predicate) - }) + }), + span: span, } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index bd9a621c00c..3c44ca7f332 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -885,6 +885,7 @@ fn parser_done(p: Parser){ where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), + span: syntax_pos::DUMMY_SP, }, span: syntax_pos::DUMMY_SP, }, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2cd84d202ff..9fb4f4813e9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4373,6 +4373,7 @@ pub fn parse_generics(&mut self) -> PResult<'a, ast::Generics> { where_clause: WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), + span: syntax_pos::DUMMY_SP, }, span: span_lo.to(self.prev_span), }) @@ -4440,11 +4441,13 @@ pub fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> { let mut where_clause = WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), + span: syntax_pos::DUMMY_SP, }; if !self.eat_keyword(keywords::Where) { return Ok(where_clause); } + let lo = self.prev_span; // This is a temporary future proofing. // @@ -4522,6 +4525,7 @@ pub fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> { } } + where_clause.span = lo.to(self.prev_span); Ok(where_clause) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b052b2cdbbb..e9d11e73837 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1041,6 +1041,7 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> { where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), + span: syntax_pos::DUMMY_SP, }, span: syntax_pos::DUMMY_SP, }; @@ -2983,6 +2984,7 @@ pub fn print_ty_fn(&mut self, where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), + span: syntax_pos::DUMMY_SP, }, span: syntax_pos::DUMMY_SP, }; diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 9c89f99cbb5..f5ac1743920 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -216,6 +216,7 @@ fn mk_generics(lifetimes: Vec, ty_params: Vec, s where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), + span: span, }, span: span, }