diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index e29a373ec3b..96fa8fe1f26 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -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); } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 153397f11b5..b764d107929 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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, } }, ) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 0884a726a27..2cb0e2fd8ce 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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) + } } } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 7b0a499fa5c..54ac5abd321 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -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, }; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 54cd4035a7b..b1a62ac81d0 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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, } diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 02e2c96868d..5a5b633e315 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -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); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 78eeb512206..fa697e06d26 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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), }; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 4cbe590d44b..0aac4f83658 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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, }, diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 362ea9ed229..90d826429da 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -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, }, diff --git a/src/test/ui/error-codes/E0646.stderr b/src/test/ui/error-codes/E0646.stderr index 976cdd45f57..069401b3f18 100644 --- a/src/test/ui/error-codes/E0646.stderr +++ b/src/test/ui/error-codes/E0646.stderr @@ -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 diff --git a/src/test/ui/error-codes/E0647.stderr b/src/test/ui/error-codes/E0647.stderr index 465cc7702ee..08cedfaef04 100644 --- a/src/test/ui/error-codes/E0647.stderr +++ b/src/test/ui/error-codes/E0647.stderr @@ -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 diff --git a/src/test/ui/issues/issue-50714-1.stderr b/src/test/ui/issues/issue-50714-1.stderr index 427b200adf4..28469bee017 100644 --- a/src/test/ui/issues/issue-50714-1.stderr +++ b/src/test/ui/issues/issue-50714-1.stderr @@ -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 diff --git a/src/test/ui/issues/issue-50714.stderr b/src/test/ui/issues/issue-50714.stderr index e048f39260c..a11aceb6211 100644 --- a/src/test/ui/issues/issue-50714.stderr +++ b/src/test/ui/issues/issue-50714.stderr @@ -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