about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-05-25 10:11:48 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2019-06-18 22:54:51 +0100
commit63edd2c35892c81fe3f071e7e259437de9557845 (patch)
tree2a16eeabd1bd81be950d602b3726029940284d12 /src/librustc
parent04a3dd8a872633ca1e4c217d11f741cc35cb19a5 (diff)
Remove the HirId/NodeId from where clauses
Also give them a span in the HIR
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/hir/intravisit.rs1
-rw-r--r--src/librustc/hir/lowering.rs6
-rw-r--r--src/librustc/hir/mod.rs17
-rw-r--r--src/librustc/hir/print.rs2
4 files changed, 12 insertions, 14 deletions
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,
         };