about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-02-20 12:47:19 +0000
committervarkor <github@varkor.com>2019-03-05 22:20:17 +0000
commit0da0457593c5c1cb09f6197782ca73617860e897 (patch)
tree01f224f57a9069aa60c823e874d87113456f6307 /src/librustc
parent162405f2221439fc9410ecb60f3e5939c2f2fac8 (diff)
downloadrust-0da0457593c5c1cb09f6197782ca73617860e897.tar.gz
rust-0da0457593c5c1cb09f6197782ca73617860e897.zip
Clean up some generic substs handling
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/infer/opaque_types/mod.rs11
-rw-r--r--src/librustc/infer/outlives/obligations.rs20
2 files changed, 21 insertions, 10 deletions
diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs
index 159bc1ceae2..1b7ecc7c3a6 100644
--- a/src/librustc/infer/opaque_types/mod.rs
+++ b/src/librustc/infer/opaque_types/mod.rs
@@ -381,10 +381,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                         substs,
                         item_def_id: _,
                     }) => {
-                        for r in substs.regions() {
-                            bound_region(r);
+                        for k in substs {
+                            match k.unpack() {
+                                UnpackedKind::Lifetime(lt) => bound_region(lt),
+                                UnpackedKind::Type(ty) => types.push(ty),
+                                UnpackedKind::Const(_) => {
+                                    // Const parameters don't impose constraints.
+                                }
+                            }
                         }
-                        types.extend(substs.types());
                     }
 
                     Component::EscapingProjection(more_components) => {
diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs
index bbda3d2fdbf..ee660328485 100644
--- a/src/librustc/infer/outlives/obligations.rs
+++ b/src/librustc/infer/outlives/obligations.rs
@@ -67,6 +67,7 @@ use crate::hir;
 use crate::traits::ObligationCause;
 use crate::ty::outlives::Component;
 use crate::ty::{self, Region, Ty, TyCtxt, TypeFoldable};
+use crate::ty::subst::UnpackedKind;
 
 impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
     /// Registers that the given region obligation must be resolved
@@ -430,13 +431,18 @@ where
         if approx_env_bounds.is_empty() && trait_bounds.is_empty() && needs_infer {
             debug!("projection_must_outlive: no declared bounds");
 
-            for component_ty in projection_ty.substs.types() {
-                self.type_must_outlive(origin.clone(), component_ty, region);
-            }
-
-            for r in projection_ty.substs.regions() {
-                self.delegate
-                    .push_sub_region_constraint(origin.clone(), region, r);
+            for k in projection_ty.substs {
+                match k.unpack() {
+                    UnpackedKind::Lifetime(lt) => {
+                        self.delegate.push_sub_region_constraint(origin.clone(), region, lt);
+                    }
+                    UnpackedKind::Type(ty) => {
+                        self.type_must_outlive(origin.clone(), ty, region);
+                    }
+                    UnpackedKind::Const(_) => {
+                        // Const parameters don't impose constraints.
+                    }
+                }
             }
 
             return;