Remove the HirId/NodeId from where clauses
Also give them a span in the HIR
This commit is contained in:
parent
04a3dd8a87
commit
63edd2c358
@ -773,7 +773,6 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
|
||||
|
||||
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
|
||||
walk_list!(visitor, visit_generic_param, &generics.params);
|
||||
visitor.visit_id(generics.where_clause.hir_id);
|
||||
walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates);
|
||||
}
|
||||
|
||||
|
@ -1727,8 +1727,8 @@ impl<'a> LoweringContext<'a> {
|
||||
generics: hir::Generics {
|
||||
params: lifetime_defs,
|
||||
where_clause: hir::WhereClause {
|
||||
hir_id: lctx.next_id(),
|
||||
predicates: hir_vec![],
|
||||
span,
|
||||
},
|
||||
span,
|
||||
},
|
||||
@ -2619,8 +2619,8 @@ impl<'a> LoweringContext<'a> {
|
||||
generics: hir::Generics {
|
||||
params: generic_params,
|
||||
where_clause: hir::WhereClause {
|
||||
hir_id: this.next_id(),
|
||||
predicates: hir_vec![],
|
||||
span,
|
||||
},
|
||||
span,
|
||||
},
|
||||
@ -2973,11 +2973,11 @@ impl<'a> LoweringContext<'a> {
|
||||
AnonymousLifetimeMode::ReportError,
|
||||
|this| {
|
||||
hir::WhereClause {
|
||||
hir_id: this.lower_node_id(wc.id),
|
||||
predicates: wc.predicates
|
||||
.iter()
|
||||
.map(|predicate| this.lower_where_predicate(predicate))
|
||||
.collect(),
|
||||
span: wc.span,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -592,8 +592,8 @@ impl Generics {
|
||||
Generics {
|
||||
params: HirVec::new(),
|
||||
where_clause: WhereClause {
|
||||
hir_id: DUMMY_HIR_ID,
|
||||
predicates: HirVec::new(),
|
||||
span: DUMMY_SP,
|
||||
},
|
||||
span: DUMMY_SP,
|
||||
}
|
||||
@ -644,19 +644,18 @@ pub enum SyntheticTyParamKind {
|
||||
/// A where-clause in a definition.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||
pub struct WhereClause {
|
||||
pub hir_id: HirId,
|
||||
pub predicates: HirVec<WherePredicate>,
|
||||
// Only valid if predicates isn't empty.
|
||||
span: Span,
|
||||
}
|
||||
|
||||
impl WhereClause {
|
||||
pub fn span(&self) -> Option<Span> {
|
||||
self.predicates.iter().map(|predicate| predicate.span())
|
||||
.fold(None, |acc, i| match (acc, i) {
|
||||
(None, i) => Some(i),
|
||||
(Some(acc), i) => {
|
||||
Some(acc.to(i))
|
||||
}
|
||||
})
|
||||
if self.predicates.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.span)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2202,8 +2202,8 @@ impl<'a> State<'a> {
|
||||
let generics = hir::Generics {
|
||||
params: hir::HirVec::new(),
|
||||
where_clause: hir::WhereClause {
|
||||
hir_id: hir::DUMMY_HIR_ID,
|
||||
predicates: hir::HirVec::new(),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
},
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
};
|
||||
|
@ -362,7 +362,6 @@ impl Default for Generics {
|
||||
Generics {
|
||||
params: Vec::new(),
|
||||
where_clause: WhereClause {
|
||||
id: DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
span: DUMMY_SP,
|
||||
},
|
||||
@ -374,7 +373,6 @@ impl Default for Generics {
|
||||
/// A where-clause in a definition.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct WhereClause {
|
||||
pub id: NodeId,
|
||||
pub predicates: Vec<WherePredicate>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
@ -750,8 +750,7 @@ pub fn noop_visit_generics<T: MutVisitor>(generics: &mut Generics, vis: &mut T)
|
||||
}
|
||||
|
||||
pub fn noop_visit_where_clause<T: MutVisitor>(wc: &mut WhereClause, vis: &mut T) {
|
||||
let WhereClause { id, predicates, span } = wc;
|
||||
vis.visit_id(id);
|
||||
let WhereClause { predicates, span } = wc;
|
||||
visit_vec(predicates, |predicate| vis.visit_where_predicate(predicate));
|
||||
vis.visit_span(span);
|
||||
}
|
||||
|
@ -5075,7 +5075,6 @@ impl<'a> Parser<'a> {
|
||||
Ok(ast::Generics {
|
||||
params,
|
||||
where_clause: WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
span: DUMMY_SP,
|
||||
},
|
||||
@ -5334,7 +5333,6 @@ impl<'a> Parser<'a> {
|
||||
/// ```
|
||||
fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> {
|
||||
let mut where_clause = WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
span: self.prev_span.to(self.prev_span),
|
||||
};
|
||||
|
@ -3042,7 +3042,6 @@ impl<'a> State<'a> {
|
||||
let generics = ast::Generics {
|
||||
params: Vec::new(),
|
||||
where_clause: ast::WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
},
|
||||
|
@ -223,7 +223,6 @@ fn mk_generics(params: Vec<ast::GenericParam>, span: Span) -> Generics {
|
||||
Generics {
|
||||
params,
|
||||
where_clause: ast::WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
span,
|
||||
},
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0646]: `main` function is not allowed to have a `where` clause
|
||||
--> $DIR/E0646.rs:1:17
|
||||
--> $DIR/E0646.rs:1:11
|
||||
|
|
||||
LL | fn main() where (): Copy {}
|
||||
| ^^^^^^^^ `main` cannot have a `where` clause
|
||||
| ^^^^^^^^^^^^^^ `main` cannot have a `where` clause
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0647]: start function is not allowed to have a `where` clause
|
||||
--> $DIR/E0647.rs:7:56
|
||||
--> $DIR/E0647.rs:7:50
|
||||
|
|
||||
LL | fn start(_: isize, _: *const *const u8) -> isize where (): Copy {
|
||||
| ^^^^^^^^ start function cannot have a `where` clause
|
||||
| ^^^^^^^^^^^^^^ start function cannot have a `where` clause
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0647]: start function is not allowed to have a `where` clause
|
||||
--> $DIR/issue-50714-1.rs:9:56
|
||||
--> $DIR/issue-50714-1.rs:9:50
|
||||
|
|
||||
LL | fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq {
|
||||
| ^^^^^^^^^^^ start function cannot have a `where` clause
|
||||
| ^^^^^^^^^^^^^^^^^ start function cannot have a `where` clause
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0646]: `main` function is not allowed to have a `where` clause
|
||||
--> $DIR/issue-50714.rs:3:17
|
||||
--> $DIR/issue-50714.rs:3:11
|
||||
|
|
||||
LL | fn main() where fn(&()): Eq {}
|
||||
| ^^^^^^^^^^^ `main` cannot have a `where` clause
|
||||
| ^^^^^^^^^^^^^^^^^ `main` cannot have a `where` clause
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user