//! ported to this system, and which relies on string concatenation at the
//! time of error detection.
-use infer;
+use infer::{self, UnlessNll};
use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs};
use super::region_constraints::GenericKind;
use super::lexical_region_resolve::RegionResolutionError;
&self,
region_scope_tree: ®ion::ScopeTree,
errors: &Vec<RegionResolutionError<'tcx>>,
- will_later_be_reported_by_nll: bool,
+ unless_nll: UnlessNll,
) {
debug!("report_region_errors(): {} errors to start", errors.len());
// If the errors will later be reported by NLL, choose wether to display them or not based
// on the borrowck mode
- if will_later_be_reported_by_nll {
+ if unless_nll.0 {
match self.tcx.borrowck_mode() {
// If we're on AST or Migrate mode, report AST region errors
BorrowckMode::Ast | BorrowckMode::Migrate => {},
pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result"
pub type FixupResult<T> = Result<T, FixupError>; // "fixup result"
+/// A flag that is given when running region resolution: if true, it
+/// indicates that we should not report the region errors to the user
+/// if NLL is enabled, since NLL will also detect them (and do a
+/// better job of it).
+///
+/// Currently, NLL only runs on HIR bodies, so you should use `false`
+/// unless you are region-checking a `hir::Body` (basically, a fn or
+/// expression).
+pub struct UnlessNll(pub bool);
+
pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
region_context: DefId,
region_map: ®ion::ScopeTree,
outlives_env: &OutlivesEnvironment<'tcx>,
- ) {
- self.resolve_regions_and_report_errors_inner(
- region_context,
- region_map,
- outlives_env,
- false,
- )
- }
-
- /// Like `resolve_regions_and_report_errors`, but skips error
- /// reporting if NLL is enabled. This is used for fn bodies where
- /// the same error may later be reported by the NLL-based
- /// inference.
- pub fn resolve_regions_and_report_errors_unless_nll(
- &self,
- region_context: DefId,
- region_map: ®ion::ScopeTree,
- outlives_env: &OutlivesEnvironment<'tcx>,
- ) {
- self.resolve_regions_and_report_errors_inner(region_context, region_map, outlives_env, true)
- }
-
- fn resolve_regions_and_report_errors_inner(
- &self,
- region_context: DefId,
- region_map: ®ion::ScopeTree,
- outlives_env: &OutlivesEnvironment<'tcx>,
- will_later_be_reported_by_nll: bool,
+ unless_nll: UnlessNll,
) {
assert!(
self.is_tainted_by_errors() || self.region_obligations.borrow().is_empty(),
// this infcx was in use. This is totally hokey but
// otherwise we have a hard time separating legit region
// errors from silly ones.
- self.report_region_errors(region_map, &errors, will_later_be_reported_by_nll);
+ self.report_region_errors(region_map, &errors, unless_nll);
}
}
use chalk_engine;
use hir;
use hir::def_id::DefId;
+use infer::UnlessNll;
use infer::outlives::env::OutlivesEnvironment;
use middle::region;
use mir::interpret::ConstEvalErr;
// cares about declarations like `'a: 'b`.
let outlives_env = OutlivesEnvironment::new(elaborated_env);
- infcx.resolve_regions_and_report_errors(region_context, ®ion_scope_tree, &outlives_env);
+ infcx.resolve_regions_and_report_errors(
+ region_context,
+ ®ion_scope_tree,
+ &outlives_env,
+ UnlessNll(false),
+ );
let predicates = match infcx.fully_resolve(&predicates) {
Ok(predicates) => predicates,
use check::regionck::RegionCtxt;
use hir::def_id::DefId;
-use rustc::infer::{self, InferOk};
+use rustc::infer::{self, InferOk, UnlessNll};
use rustc::infer::outlives::env::OutlivesEnvironment;
use rustc::middle::region;
use rustc::ty::subst::{Subst, Substs, UnpackedKind};
// conservative. -nmatsakis
let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty());
- infcx.resolve_regions_and_report_errors(drop_impl_did, ®ion_scope_tree, &outlives_env);
+ infcx.resolve_regions_and_report_errors(drop_impl_did, ®ion_scope_tree, &outlives_env, UnlessNll(false));
Ok(())
})
}
use middle::mem_categorization::Categorization;
use middle::region;
use rustc::hir::def_id::DefId;
-use rustc::infer;
+use rustc::infer::{self, UnlessNll};
use rustc::infer::outlives::env::OutlivesEnvironment;
use rustc::ty::adjustment;
use rustc::ty::subst::Substs;
rcx.visit_body(body);
rcx.visit_region_obligations(id);
}
- rcx.resolve_regions_and_report_errors_unless_nll();
+ rcx.resolve_regions_and_report_errors(UnlessNll(true));
assert!(self.tables.borrow().free_region_map.is_empty());
self.tables.borrow_mut().free_region_map = rcx.outlives_environment.into_free_region_map();
.add_implied_bounds(self, wf_tys, item_id, span);
rcx.outlives_environment.save_implied_bounds(item_id);
rcx.visit_region_obligations(item_id);
- rcx.resolve_regions_and_report_errors();
+ rcx.resolve_regions_and_report_errors(UnlessNll(false));
}
/// Region check a function body. Not invoked on closures, but
rcx.visit_fn_body(fn_id, body, self.tcx.hir.span(fn_id));
}
- rcx.resolve_regions_and_report_errors_unless_nll();
+ rcx.resolve_regions_and_report_errors(UnlessNll(true));
// In this mode, we also copy the free-region-map into the
// tables of the enclosing fcx. In the other regionck modes
);
}
- fn resolve_regions_and_report_errors(&self) {
+ fn resolve_regions_and_report_errors(&self, unless_nll: UnlessNll) {
self.fcx.resolve_regions_and_report_errors(
self.subject_def_id,
&self.region_scope_tree,
&self.outlives_environment,
- );
- }
-
- fn resolve_regions_and_report_errors_unless_nll(&self) {
- self.fcx.resolve_regions_and_report_errors_unless_nll(
- self.subject_def_id,
- &self.region_scope_tree,
- &self.outlives_environment,
+ unless_nll,
);
}
//! Check properties that are required by built-in traits and set
//! up data structures required by type-checking/codegen.
+use rustc::infer::UnlessNll;
use rustc::infer::outlives::env::OutlivesEnvironment;
use rustc::middle::region;
use rustc::middle::lang_items::UnsizeTraitLangItem;
impl_did,
®ion_scope_tree,
&outlives_env,
+ UnlessNll(false),
);
CoerceUnsizedInfo {