1
Fork 0

move RegionResolutionError into lexical_region_resolve

This commit is contained in:
Niko Matsakis 2017-11-05 05:28:22 -05:00
parent 8e9e15446f
commit b76978530c
5 changed files with 42 additions and 34 deletions

View file

@ -13,8 +13,8 @@
use hir;
use infer::InferCtxt;
use ty::{self, Region};
use infer::region_inference::RegionResolutionError::*;
use infer::region_inference::RegionResolutionError;
use infer::lexical_region_resolve::RegionResolutionError::*;
use infer::lexical_region_resolve::RegionResolutionError;
use hir::map as hir_map;
use middle::resolve_lifetime as rl;
use hir::intravisit::{self, Visitor, NestedVisitorMap};

View file

@ -57,7 +57,8 @@
use infer;
use super::{InferCtxt, TypeTrace, SubregionOrigin, RegionVariableOrigin, ValuePairs};
use super::region_inference::{RegionResolutionError, GenericKind};
use super::region_inference::GenericKind;
use super::lexical_region_resolve::RegionResolutionError;
use std::fmt;
use hir;

View file

@ -11,8 +11,8 @@
//! Error Reporting for Anonymous Region Lifetime Errors
//! where one region is named and the other is anonymous.
use infer::InferCtxt;
use infer::region_inference::RegionResolutionError::*;
use infer::region_inference::RegionResolutionError;
use infer::lexical_region_resolve::RegionResolutionError::*;
use infer::lexical_region_resolve::RegionResolutionError;
use ty;
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {

View file

@ -11,9 +11,10 @@
//! The code to do lexical region resolution.
use infer::SubregionOrigin;
use infer::RegionVariableOrigin;
use infer::region_inference::Constraint;
use infer::region_inference::GenericKind;
use infer::region_inference::RegionVarBindings;
use infer::region_inference::RegionResolutionError;
use infer::region_inference::VarValue;
use infer::region_inference::VerifyBound;
use middle::free_region::RegionRelations;
@ -23,11 +24,38 @@ use std::fmt;
use std::u32;
use ty::{self, TyCtxt};
use ty::{Region, RegionVid};
use ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound, ReErased};
use ty::{ReLateBound, ReScope, ReVar, ReSkolemized};
use ty::{ReEarlyBound, ReEmpty, ReErased, ReFree, ReStatic};
use ty::{ReLateBound, ReScope, ReSkolemized, ReVar};
mod graphviz;
#[derive(Clone, Debug)]
pub enum RegionResolutionError<'tcx> {
/// `ConcreteFailure(o, a, b)`:
///
/// `o` requires that `a <= b`, but this does not hold
ConcreteFailure(SubregionOrigin<'tcx>, Region<'tcx>, Region<'tcx>),
/// `GenericBoundFailure(p, s, a)
///
/// The parameter/associated-type `p` must be known to outlive the lifetime
/// `a` (but none of the known bounds are sufficient).
GenericBoundFailure(SubregionOrigin<'tcx>, GenericKind<'tcx>, Region<'tcx>),
/// `SubSupConflict(v, sub_origin, sub_r, sup_origin, sup_r)`:
///
/// Could not infer a value for `v` because `sub_r <= v` (due to
/// `sub_origin`) but `v <= sup_r` (due to `sup_origin`) and
/// `sub_r <= sup_r` does not hold.
SubSupConflict(
RegionVariableOrigin,
SubregionOrigin<'tcx>,
Region<'tcx>,
SubregionOrigin<'tcx>,
Region<'tcx>,
),
}
struct RegionAndOrigin<'tcx> {
region: Region<'tcx>,
origin: SubregionOrigin<'tcx>,
@ -327,7 +355,11 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
sup
);
errors.push(RegionResolutionError::ConcreteFailure((*origin).clone(), sub, sup));
errors.push(RegionResolutionError::ConcreteFailure(
(*origin).clone(),
sub,
sup,
));
}
Constraint::VarSubReg(a_vid, b_region) => {

View file

@ -142,31 +142,6 @@ enum CombineMapType {
Glb,
}
#[derive(Clone, Debug)]
pub enum RegionResolutionError<'tcx> {
/// `ConcreteFailure(o, a, b)`:
///
/// `o` requires that `a <= b`, but this does not hold
ConcreteFailure(SubregionOrigin<'tcx>, Region<'tcx>, Region<'tcx>),
/// `GenericBoundFailure(p, s, a)
///
/// The parameter/associated-type `p` must be known to outlive the lifetime
/// `a` (but none of the known bounds are sufficient).
GenericBoundFailure(SubregionOrigin<'tcx>, GenericKind<'tcx>, Region<'tcx>),
/// `SubSupConflict(v, sub_origin, sub_r, sup_origin, sup_r)`:
///
/// Could not infer a value for `v` because `sub_r <= v` (due to
/// `sub_origin`) but `v <= sup_r` (due to `sup_origin`) and
/// `sub_r <= sup_r` does not hold.
SubSupConflict(RegionVariableOrigin,
SubregionOrigin<'tcx>,
Region<'tcx>,
SubregionOrigin<'tcx>,
Region<'tcx>),
}
#[derive(Copy, Clone, Debug)]
pub enum VarValue<'tcx> {
Value(Region<'tcx>),