about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-11-04 07:36:00 -0400
committerNiko Matsakis <niko@alum.mit.edu>2017-11-15 16:49:22 -0500
commit15a2dfa324d6c10f6dfae0f874d050a009ab8f3d (patch)
tree836de9f7c961fb6f8fc363e995bf38f79cf1689f
parent56e5eb5fd4c3977fb6abdb867af4a85076045d59 (diff)
downloadrust-15a2dfa324d6c10f6dfae0f874d050a009ab8f3d.tar.gz
rust-15a2dfa324d6c10f6dfae0f874d050a009ab8f3d.zip
move the `OutlivesEnvironment` into `infer` so that `nll` can use it
Unquestionably there is more cleanup to be done, but I'm not sure what
it should look like yet, so leaving it roughly as is.
-rw-r--r--src/librustc/infer/mod.rs2
-rw-r--r--src/librustc/infer/outlives/env.rs (renamed from src/librustc_typeck/check/regionck_implied_bounds.rs)39
-rw-r--r--src/librustc/infer/outlives/mod.rs1
-rw-r--r--src/librustc/infer/outlives/obligations.rs10
-rw-r--r--src/librustc_typeck/check/mod.rs1
-rw-r--r--src/librustc_typeck/check/regionck.rs4
6 files changed, 48 insertions, 9 deletions
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index e3db08c0adf..e73d74c22ba 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -62,6 +62,8 @@ mod sub;
 pub mod type_variable;
 pub mod unify_key;
 
+pub use self::outlives::env::OutlivesEnvironment;
+
 #[must_use]
 pub struct InferOk<'tcx, T> {
     pub value: T,
diff --git a/src/librustc_typeck/check/regionck_implied_bounds.rs b/src/librustc/infer/outlives/env.rs
index f84e0dd880f..ef09479f751 100644
--- a/src/librustc_typeck/check/regionck_implied_bounds.rs
+++ b/src/librustc/infer/outlives/env.rs
@@ -1,13 +1,42 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
 use middle::free_region::FreeRegionMap;
-use rustc::ty::{self, Ty, TypeFoldable};
-use rustc::infer::{InferCtxt, GenericKind};
-use rustc::traits::FulfillmentContext;
-use rustc::ty::outlives::Component;
-use rustc::ty::wf;
+use infer::{InferCtxt, GenericKind};
+use traits::FulfillmentContext;
+use ty::{self, Ty, TypeFoldable};
+use ty::outlives::Component;
+use ty::wf;
 
 use syntax::ast;
 use syntax_pos::Span;
 
+/// The `OutlivesEnvironment` collects information about what outlives
+/// what in a given type-checking setting. For example, if we have a
+/// where-clause like `where T: 'a` in scope, then the
+/// `OutlivesEnvironment` would record that (in its
+/// `region_bound_pairs` field). Similarly, it contains methods for
+/// processing and adding implied bounds into the outlives
+/// environment.
+///
+/// Other code at present does not typically take a
+/// `&OutlivesEnvironment`, but rather takes some of its fields (e.g.,
+/// `process_registered_region_obligations` wants the
+/// region-bound-pairs). There is no mistaking it: the current setup
+/// of tracking region information is quite scattered! The
+/// `OutlivesEnvironment`, for example, needs to sometimes be combined
+/// with the `middle::RegionRelations`, to yield a full picture of how
+/// (lexical) lifetimes interact. However, I'm reluctant to do more
+/// refactoring here, since the setup with NLL is quite different.
+/// For example, NLL has no need of `RegionRelations`, and is solely
+/// interested in the `OutlivesEnvironment`. -nmatsakis
 #[derive(Clone)]
 pub struct OutlivesEnvironment<'tcx> {
     param_env: ty::ParamEnv<'tcx>,
diff --git a/src/librustc/infer/outlives/mod.rs b/src/librustc/infer/outlives/mod.rs
index 321c4b87fb3..ae2fb5e2580 100644
--- a/src/librustc/infer/outlives/mod.rs
+++ b/src/librustc/infer/outlives/mod.rs
@@ -1 +1,2 @@
+pub mod env;
 mod obligations;
diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs
index 05e14daa281..2fb085bc1d8 100644
--- a/src/librustc/infer/outlives/obligations.rs
+++ b/src/librustc/infer/outlives/obligations.rs
@@ -1,3 +1,13 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
 //! Code that handles "type-outlives" constraints like `T: 'a`. This
 //! is based on the `outlives_components` function defined on the tcx,
 //! but it adds a bit of heuristics on top, in particular to deal with
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 7d98a1c9246..c8b2032a498 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -137,7 +137,6 @@ pub mod dropck;
 pub mod _match;
 pub mod writeback;
 mod regionck;
-mod regionck_implied_bounds;
 pub mod coercion;
 pub mod demand;
 pub mod method;
diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs
index 5954a0f2ecd..932cb12e81d 100644
--- a/src/librustc_typeck/check/regionck.rs
+++ b/src/librustc_typeck/check/regionck.rs
@@ -90,7 +90,7 @@ use middle::region;
 use rustc::hir::def_id::DefId;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty};
-use rustc::infer;
+use rustc::infer::{self, OutlivesEnvironment};
 use rustc::ty::adjustment;
 
 use std::mem;
@@ -101,8 +101,6 @@ use syntax_pos::Span;
 use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
 use rustc::hir::{self, PatKind};
 
-use super::regionck_implied_bounds::OutlivesEnvironment;
-
 // a variation on try that just returns unit
 macro_rules! ignore_err {
     ($e:expr) => (match $e { Ok(e) => e, Err(_) => return () })