提交 6375b77e 编写于 作者: T topecongiro

Add Span to ast::WhereClause

上级 4a42ff48
...@@ -321,6 +321,7 @@ fn default() -> Generics { ...@@ -321,6 +321,7 @@ fn default() -> Generics {
where_clause: WhereClause { where_clause: WhereClause {
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: DUMMY_SP,
}, },
span: DUMMY_SP, span: DUMMY_SP,
} }
...@@ -332,6 +333,7 @@ fn default() -> Generics { ...@@ -332,6 +333,7 @@ fn default() -> Generics {
pub struct WhereClause { pub struct WhereClause {
pub id: NodeId, pub id: NodeId,
pub predicates: Vec<WherePredicate>, pub predicates: Vec<WherePredicate>,
pub span: Span,
} }
/// A single predicate in a `where` clause /// A single predicate in a `where` clause
......
...@@ -736,14 +736,15 @@ pub fn noop_fold_generics<T: Folder>(Generics {ty_params, lifetimes, where_claus ...@@ -736,14 +736,15 @@ pub fn noop_fold_generics<T: Folder>(Generics {ty_params, lifetimes, where_claus
} }
pub fn noop_fold_where_clause<T: Folder>( pub fn noop_fold_where_clause<T: Folder>(
WhereClause {id, predicates}: WhereClause, WhereClause {id, predicates, span}: WhereClause,
fld: &mut T) fld: &mut T)
-> WhereClause { -> WhereClause {
WhereClause { WhereClause {
id: fld.new_id(id), id: fld.new_id(id),
predicates: predicates.move_map(|predicate| { predicates: predicates.move_map(|predicate| {
fld.fold_where_predicate(predicate) fld.fold_where_predicate(predicate)
}) }),
span: span,
} }
} }
......
...@@ -885,6 +885,7 @@ fn parser_done(p: Parser){ ...@@ -885,6 +885,7 @@ fn parser_done(p: Parser){
where_clause: ast::WhereClause { where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
}, },
span: syntax_pos::DUMMY_SP, span: syntax_pos::DUMMY_SP,
}, },
......
...@@ -4373,6 +4373,7 @@ pub fn parse_generics(&mut self) -> PResult<'a, ast::Generics> { ...@@ -4373,6 +4373,7 @@ pub fn parse_generics(&mut self) -> PResult<'a, ast::Generics> {
where_clause: WhereClause { where_clause: WhereClause {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
}, },
span: span_lo.to(self.prev_span), span: span_lo.to(self.prev_span),
}) })
...@@ -4440,11 +4441,13 @@ pub fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> { ...@@ -4440,11 +4441,13 @@ pub fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> {
let mut where_clause = WhereClause { let mut where_clause = WhereClause {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
}; };
if !self.eat_keyword(keywords::Where) { if !self.eat_keyword(keywords::Where) {
return Ok(where_clause); return Ok(where_clause);
} }
let lo = self.prev_span;
// This is a temporary future proofing. // This is a temporary future proofing.
// //
...@@ -4522,6 +4525,7 @@ pub fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> { ...@@ -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) Ok(where_clause)
} }
......
...@@ -1041,6 +1041,7 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> { ...@@ -1041,6 +1041,7 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
where_clause: ast::WhereClause { where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
}, },
span: syntax_pos::DUMMY_SP, span: syntax_pos::DUMMY_SP,
}; };
...@@ -2983,6 +2984,7 @@ pub fn print_ty_fn(&mut self, ...@@ -2983,6 +2984,7 @@ pub fn print_ty_fn(&mut self,
where_clause: ast::WhereClause { where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
}, },
span: syntax_pos::DUMMY_SP, span: syntax_pos::DUMMY_SP,
}; };
......
...@@ -216,6 +216,7 @@ fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>, s ...@@ -216,6 +216,7 @@ fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>, s
where_clause: ast::WhereClause { where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
predicates: Vec::new(), predicates: Vec::new(),
span: span,
}, },
span: span, span: span,
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册