Skip to content

Commit

Permalink
Add Span to ast::WhereClause
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Jul 28, 2017
1 parent 4a42ff4 commit 6375b77
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ impl Default for Generics {
where_clause: WhereClause {
id: DUMMY_NODE_ID,
predicates: Vec::new(),
span: DUMMY_SP,
},
span: DUMMY_SP,
}
Expand All @@ -332,6 +333,7 @@ impl Default for Generics {
pub struct WhereClause {
pub id: NodeId,
pub predicates: Vec<WherePredicate>,
pub span: Span,
}

/// A single predicate in a `where` clause
Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
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,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ mod tests {
where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID,
predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
},
span: syntax_pos::DUMMY_SP,
},
Expand Down
4 changes: 4 additions & 0 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4373,6 +4373,7 @@ impl<'a> Parser<'a> {
where_clause: WhereClause {
id: ast::DUMMY_NODE_ID,
predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
},
span: span_lo.to(self.prev_span),
})
Expand Down Expand Up @@ -4440,11 +4441,13 @@ impl<'a> Parser<'a> {
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.
//
Expand Down Expand Up @@ -4522,6 +4525,7 @@ impl<'a> Parser<'a> {
}
}

where_clause.span = lo.to(self.prev_span);
Ok(where_clause)
}

Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ impl<'a> State<'a> {
where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID,
predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
},
span: syntax_pos::DUMMY_SP,
};
Expand Down Expand Up @@ -2983,6 +2984,7 @@ impl<'a> State<'a> {
where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID,
predicates: Vec::new(),
span: syntax_pos::DUMMY_SP,
},
span: syntax_pos::DUMMY_SP,
};
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/deriving/generic/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>, s
where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID,
predicates: Vec::new(),
span: span,
},
span: span,
}
Expand Down

0 comments on commit 6375b77

Please sign in to comment.