]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #61387 - JohnTitor:remove-unused, r=matthewjasper
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 1 Jun 2019 04:50:06 +0000 (06:50 +0200)
committerGitHub <noreply@github.com>
Sat, 1 Jun 2019 04:50:06 +0000 (06:50 +0200)
Remove ty::BrFresh and RegionConstraintCollector::new_bound

Fixes #60957

r? @matthewjasper

src/librustc/ich/impls_ty.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/region_constraints/mod.rs
src/librustc/ty/print/pretty.rs
src/librustc/ty/structural_impls.rs
src/librustc/ty/sty.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
src/librustc_typeck/astconv.rs

index ec1b0da68107439f0b436c1280ad35854edc4963..563948a63514b300eb4c01a23398aa988ffb452c 100644 (file)
@@ -100,7 +100,6 @@ fn hash_stable<W: StableHasherResult>(&self,
             ty::ReClosureBound(vid) => {
                 vid.hash_stable(hcx, hasher);
             }
-            ty::ReLateBound(..) |
             ty::ReVar(..) |
             ty::RePlaceholder(..) => {
                 bug!("StableHasher: unexpected region {:?}", *self)
index f87c6977f33d0261ea99cd3339b5184aa5c4a1ad..b1eba7d5934f91fed1f45662b46200870ac28307 100644 (file)
@@ -218,10 +218,6 @@ fn msg_span_from_early_bound_and_free_regions(
                     format!("the anonymous lifetime #{} defined on", idx + 1),
                     self.hir().span_by_hir_id(node),
                 ),
-                ty::BrFresh(_) => (
-                    "an anonymous lifetime defined on".to_owned(),
-                    self.hir().span_by_hir_id(node),
-                ),
                 _ => (
                     format!("the lifetime {} as defined on", region),
                     cm.def_span(self.hir().span_by_hir_id(node)),
index 6a20d95cc3ad349bb687d73f4a57ebf316fc6507..ca766ea724f3db02379a4a398aeccf8c3496157d 100644 (file)
 use rustc_data_structures::unify as ut;
 use crate::ty::ReStatic;
 use crate::ty::{self, Ty, TyCtxt};
-use crate::ty::{BrFresh, ReLateBound, ReVar};
+use crate::ty::{ReLateBound, ReVar};
 use crate::ty::{Region, RegionVid};
 
 use std::collections::BTreeMap;
-use std::{cmp, fmt, mem, u32};
+use std::{cmp, fmt, mem};
 use std::ops::Range;
 
 mod leak_check;
@@ -37,10 +37,6 @@ pub struct RegionConstraintCollector<'tcx> {
     /// exist). This prevents us from making many such regions.
     glbs: CombineMap<'tcx>,
 
-    /// Global counter used during the GLB algorithm to create unique
-    /// names for fresh bound regions
-    bound_count: u32,
-
     /// The undo log records actions that might later be undone.
     ///
     /// Note: `num_open_snapshots` is used to track if we are actively
@@ -392,7 +388,6 @@ pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx> {
             data,
             lubs,
             glbs,
-            bound_count: _,
             undo_log: _,
             num_open_snapshots: _,
             unification_table,
@@ -579,39 +574,6 @@ fn kill_constraint<'tcx>(
         }
     }
 
-    pub fn new_bound(
-        &mut self,
-        tcx: TyCtxt<'_, '_, 'tcx>,
-        debruijn: ty::DebruijnIndex,
-    ) -> Region<'tcx> {
-        // Creates a fresh bound variable for use in GLB computations.
-        // See discussion of GLB computation in the large comment at
-        // the top of this file for more details.
-        //
-        // This computation is potentially wrong in the face of
-        // rollover.  It's conceivable, if unlikely, that one might
-        // wind up with accidental capture for nested functions in
-        // that case, if the outer function had bound regions created
-        // a very long time before and the inner function somehow
-        // wound up rolling over such that supposedly fresh
-        // identifiers were in fact shadowed. For now, we just assert
-        // that there is no rollover -- eventually we should try to be
-        // robust against this possibility, either by checking the set
-        // of bound identifiers that appear in a given expression and
-        // ensure that we generate one that is distinct, or by
-        // changing the representation of bound regions in a fn
-        // declaration
-
-        let sc = self.bound_count;
-        self.bound_count = sc + 1;
-
-        if sc >= self.bound_count {
-            bug!("rollover in RegionInference new_bound()");
-        }
-
-        tcx.mk_region(ReLateBound(debruijn, BrFresh(sc)))
-    }
-
     fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
         // cannot add constraints once regions are resolved
         debug!(
index a246d9652f2f045ef3b1c9667b736c191e0d2d62..300ea9bb49785177baf8a763cd64aa5e23b0cb4c 100644 (file)
@@ -1441,7 +1441,6 @@ fn name_by_region_index(index: usize) -> InternedString {
                     br
                 }
                 ty::BrAnon(_) |
-                ty::BrFresh(_) |
                 ty::BrEnv => {
                     let name = loop {
                         let name = name_by_region_index(region_index);
index 0daa567052d5662ec881cad2b4c366f30b6c5ca4..56d47a7f849cf6eec7c8888087bb29abb881ee67 100644 (file)
@@ -94,7 +94,6 @@ impl fmt::Debug for ty::BoundRegion {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
             ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
-            ty::BrFresh(n) => write!(f, "BrFresh({:?})", n),
             ty::BrNamed(did, name) => {
                 write!(f, "BrNamed({:?}:{:?}, {})",
                         did.krate, did.index, name)
index 0a673dd380b5254416da4ea452c86d6f1e7dbc60..ddc4bd3f9f6c3c057cd918147a6eef1937be875e 100644 (file)
@@ -56,9 +56,6 @@ pub enum BoundRegion {
     /// the event of shadowing.
     BrNamed(DefId, InternedString),
 
-    /// Fresh bound identifiers created during GLB computations.
-    BrFresh(u32),
-
     /// Anonymous region for the implicit env pointer parameter
     /// to a closure
     BrEnv,
index 25415039fc80a7b29f731dd2b2b9918f235b6b35..0d452c99ea16853776aa04db9b3b9e42ebd16ca2 100644 (file)
@@ -274,7 +274,7 @@ fn give_name_from_error_region(
                     }
                 }
 
-                ty::BoundRegion::BrAnon(_) | ty::BoundRegion::BrFresh(_) => None,
+                ty::BoundRegion::BrAnon(_) => None,
             },
 
             ty::ReLateBound(..)
index cd53bdc6ed0a04c9a144e3fcd189ac7d6541dddf..cc054adee7bea80ebe5b72923b5357f755f78027 100644 (file)
@@ -2049,7 +2049,7 @@ pub fn ty_of_fn(&self,
         for br in late_bound_in_ret.difference(&late_bound_in_args) {
             let lifetime_name = match *br {
                 ty::BrNamed(_, name) => format!("lifetime `{}`,", name),
-                ty::BrAnon(_) | ty::BrFresh(_) | ty::BrEnv => "an anonymous lifetime".to_string(),
+                ty::BrAnon(_) | ty::BrEnv => "an anonymous lifetime".to_string(),
             };
             let mut err = struct_span_err!(tcx.sess,
                                            decl.output.span(),