about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-06-17 09:26:48 -0400
committerNiko Matsakis <niko@alum.mit.edu>2019-07-02 12:25:21 -0400
commitadba6a8f902d967d762855b565677ee1d16608f6 (patch)
treea58dec73b673a6bf4147cada191f01d2d94dab5d
parent0b15a66a806a8f46af6ae24f640814f3a69eddfb (diff)
downloadrust-adba6a8f902d967d762855b565677ee1d16608f6.tar.gz
rust-adba6a8f902d967d762855b565677ee1d16608f6.zip
address nits by mattewjasper
-rw-r--r--src/librustc/infer/lexical_region_resolve/mod.rs32
-rw-r--r--src/librustc/infer/mod.rs2
-rw-r--r--src/librustc/infer/opaque_types/mod.rs7
-rw-r--r--src/librustc_data_structures/graph/vec_graph/mod.rs1
-rw-r--r--src/librustc_data_structures/graph/vec_graph/test.rs2
-rw-r--r--src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original.stderr22
-rw-r--r--src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-other.stderr11
7 files changed, 13 insertions, 64 deletions
diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs
index ac8db3c4336..2779845a17a 100644
--- a/src/librustc/infer/lexical_region_resolve/mod.rs
+++ b/src/librustc/infer/lexical_region_resolve/mod.rs
@@ -197,26 +197,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
         }
     }
 
-    /// Enforce constraints of the form:
-    ///
-    /// ```
-    /// 'r0 in ['o1...'oN]
-    /// ```
-    ///
-    /// such a constraint simply means that `'r0` must be equal to one
-    /// of the regions `'o1...'oN`. This is an annoying constraint to
-    /// integrate into our inference, which generally works by
-    /// iteratively growing regions until we find a match -- that's
-    /// not an option here.
-    ///
-    /// What we currently do:
-    ///
-    /// - Search forward in the graph from `'r0` to find each region `'b`
-    ///   where `'r0 <= 'b` must hold.
-    ///   - Try to rule out some of the `'o1..'oN` options:
-    ///     - if `'o[i] <= 'b` is false, then `'o[i]` is not an option
-    ///
-    /// Hopefully this narrows it down to just one option.
+    /// Enforce all pick constraints and return true if anything
+    /// changed. See `enforce_pick_constraint` for more details.
     fn enforce_pick_constraints(
         &self,
         graph: &RegionGraph<'tcx>,
@@ -237,15 +219,17 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
     /// pick 'r from ['o...]
     /// ```
     ///
-    /// We look to see if there is a unique option `'o` from the list of options
-    /// that:
+    /// We look for all option regions from the list `'o...` that:
     ///
-    /// (a) is greater than the current value of `'r` (which is a lower bound)
+    /// (a) are greater than the current value of `'r` (which is a lower bound)
     ///
     /// and
     ///
-    /// (b) is compatible with the upper bounds of `'r` that we can
+    /// (b) are compatible with the upper bounds of `'r` that we can
     /// find by traversing the graph.
+    ///
+    /// From that list, we look for a *minimal* option `'o_min`. If we
+    /// find one, then we can enforce that `'r: 'o_min`.
     fn enforce_pick_constraint(
         &self,
         graph: &RegionGraph<'tcx>,
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index 6f13cd81629..95f224f546b 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -915,7 +915,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         region: ty::Region<'tcx>,
         in_regions: &Rc<Vec<ty::Region<'tcx>>>,
     ) {
-        debug!("sub_regions({:?} <: {:?})", region, in_regions);
+        debug!("pick_constraint({:?} <: {:?})", region, in_regions);
         self.borrow_region_constraints()
             .pick_constraint(opaque_type_def_id, definition_span, hidden_ty, region, in_regions);
     }
diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs
index 9a339db047d..8b5a0420f84 100644
--- a/src/librustc/infer/opaque_types/mod.rs
+++ b/src/librustc/infer/opaque_types/mod.rs
@@ -271,8 +271,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     /// is an inference variable). If we generated a constraint that
     /// `Tc: 'a`, then this would incorrectly require that `T: 'a` --
     /// but this is not necessary, because the existential type we
-    /// create will be allowed to reference `T`. So instead we just
-    /// generate a constraint that `'0: 'a`.
+    /// create will be allowed to reference `T`. So we only generate a
+    /// constraint that `'0: 'a`.
     ///
     /// # The `free_region_relations` parameter
     ///
@@ -563,8 +563,7 @@ pub fn unexpected_hidden_region_diagnostic(
         // ```
         //
         // Here the captured lifetime is the intersection of `'a` and
-        // `'b`, which we can't quite express. This prticulararticular
-        // is kind of an unfortunate error anyway.
+        // `'b`, which we can't quite express.
 
         if let Some(region_scope_tree) = region_scope_tree {
             // If the `region_scope_tree` is available, this is being
diff --git a/src/librustc_data_structures/graph/vec_graph/mod.rs b/src/librustc_data_structures/graph/vec_graph/mod.rs
index 7078a5a9c9b..c425502f219 100644
--- a/src/librustc_data_structures/graph/vec_graph/mod.rs
+++ b/src/librustc_data_structures/graph/vec_graph/mod.rs
@@ -1,6 +1,7 @@
 use crate::indexed_vec::{Idx, IndexVec};
 use crate::graph::{DirectedGraph, WithNumNodes, WithNumEdges, WithSuccessors, GraphSuccessors};
 
+#[cfg(test)]
 mod test;
 
 pub struct VecGraph<N: Idx> {
diff --git a/src/librustc_data_structures/graph/vec_graph/test.rs b/src/librustc_data_structures/graph/vec_graph/test.rs
index c54a72264f6..97a9bd2ad0b 100644
--- a/src/librustc_data_structures/graph/vec_graph/test.rs
+++ b/src/librustc_data_structures/graph/vec_graph/test.rs
@@ -1,5 +1,3 @@
-#![cfg(test)]
-
 use super::*;
 
 fn create_graph() -> VecGraph<usize> {
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original.stderr b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original.stderr
deleted file mode 100644
index f55bba987ec..00000000000
--- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original.stderr
+++ /dev/null
@@ -1,22 +0,0 @@
-warning[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
-  --> $DIR/ordinary-bounds-pick-original.rs:10:50
-   |
-LL | fn upper_bounds<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
-   |                                                  ^^^^^^^^^^^^^^^^^^
-   |
-   = note: hidden type `(&u8, &u8)` captures lifetime '_#6r
-   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
-   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
-   = note: for more information, try `rustc --explain E0729`
-
-warning[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
-  --> $DIR/ordinary-bounds-pick-original.rs:10:50
-   |
-LL | fn upper_bounds<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
-   |                                                  ^^^^^^^^^^^^^^^^^^
-   |
-   = note: hidden type `(&u8, &u8)` captures lifetime '_#7r
-   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
-   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
-   = note: for more information, try `rustc --explain E0729`
-
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-other.stderr b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-other.stderr
deleted file mode 100644
index a9b56210b0f..00000000000
--- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-other.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
-  --> $DIR/ordinary-bounds-pick-other.rs:17:74
-   |
-LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e>
-   |                                                                          ^^^^^^^^^^^^^^^^^^
-   |
-   = note: hidden type `Ordinary<'_>` captures lifetime '_#8r
-   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
-   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
-   = note: for more information, try `rustc --explain E0729`
-