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.
This commit is contained in:
parent
56e5eb5fd4
commit
15a2dfa324
6 changed files with 48 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -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>,
|
|
@ -1 +1,2 @@
|
|||
pub mod env;
|
||||
mod obligations;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 () })
|
||||
|
|
Loading…
Reference in a new issue