use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::Node;
-use rustc_middle::middle::region;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{
self,
pub(super) fn note_and_explain_region(
tcx: TyCtxt<'tcx>,
- region_scope_tree: ®ion::ScopeTree,
err: &mut DiagnosticBuilder<'_>,
prefix: &str,
region: ty::Region<'tcx>,
pub fn unexpected_hidden_region_diagnostic(
tcx: TyCtxt<'tcx>,
- region_scope_tree: Option<®ion::ScopeTree>,
span: Span,
hidden_ty: Ty<'tcx>,
hidden_region: ty::Region<'tcx>,
err.span_note(span, &message);
}
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReStatic | ty::ReEmpty(_) => {
- // Assuming regionck succeeded (*), we ought to always be
- // capturing *some* region from the fn header, and hence it
- // ought to be free. So under normal circumstances, we will go
- // down this path which gives a decent human readable
- // explanation.
- //
- // (*) if not, the `tainted_by_errors` field would be set to
- // `Some(ErrorReported)` in any case, so we wouldn't be here at all.
- note_and_explain_free_region(
- tcx,
- &mut err,
- &format!("hidden type `{}` captures ", hidden_ty),
- hidden_region,
- "",
- );
+ // Assuming regionck succeeded (*), we ought to always be
+ // capturing *some* region from the fn header, and hence it
+ // ought to be free. So under normal circumstances, we will go
+ // down this path which gives a decent human readable
+ // explanation.
+ //
+ // (*) if not, the `tainted_by_errors` field would be set to
+ // `Some(ErrorReported)` in any case, so we wouldn't be here at all.
+ note_and_explain_free_region(
+ tcx,
+ &mut err,
+ &format!("hidden type `{}` captures ", hidden_ty),
+ hidden_region,
+ "",
+ );
}
_ => {
- // Ugh. This is a painful case: the hidden region is not one
- // that we can easily summarize or explain. This can happen
- // in a case like
- // `src/test/ui/multiple-lifetimes/ordinary-bounds-unsuited.rs`:
- //
- // ```
- // fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> {
- // if condition() { a } else { b }
- // }
- // ```
- //
- // Here the captured lifetime is the intersection of `'a` and
- // `'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
- // invoked from the "region inferencer error". We can at
- // least report a really cryptic error for now.
+ // Ugh. This is a painful case: the hidden region is not one
+ // that we can easily summarize or explain. This can happen
+ // in a case like
+ // `src/test/ui/multiple-lifetimes/ordinary-bounds-unsuited.rs`:
+ //
+ // ```
+ // fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> {
+ // if condition() { a } else { b }
+ // }
+ // ```
+ //
+ // Here the captured lifetime is the intersection of `'a` and
+ // `'b`, which we can't quite express.
+
+ // We can at least report a really cryptic error for now.
note_and_explain_region(
tcx,
- region_scope_tree,
&mut err,
&format!("hidden type `{}` captures ", hidden_ty),
hidden_region,
"",
);
- } else {
- // If the `region_scope_tree` is *unavailable*, this is
- // being invoked by the code that comes *after* region
- // inferencing. This is a bug, as the region inferencer
- // ought to have noticed the failed constraint and invoked
- // error reporting, which in turn should have prevented us
- // from getting trying to infer the hidden type
- // completely.
- tcx.sess.delay_span_bug(
- span,
- &format!(
- "hidden type captures unexpected lifetime `{:?}` \
- but no region inference failure",
- hidden_region,
- ),
- );
}
}
- }
err
}
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
- pub fn report_region_errors(
- &self,
- region_scope_tree: ®ion::ScopeTree,
- errors: &Vec<RegionResolutionError<'tcx>>,
- ) {
+ pub fn report_region_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>) {
debug!("report_region_errors(): {} errors to start", errors.len());
// try to pre-process the errors, which will group some of them
// general bit of code that displays the error information
RegionResolutionError::ConcreteFailure(origin, sub, sup) => {
if sub.is_placeholder() || sup.is_placeholder() {
- self.report_placeholder_failure(region_scope_tree, origin, sub, sup)
- .emit();
+ self.report_placeholder_failure(origin, sub, sup).emit();
} else {
- self.report_concrete_failure(region_scope_tree, origin, sub, sup)
- .emit();
+ self.report_concrete_failure(origin, sub, sup).emit();
}
}
RegionResolutionError::GenericBoundFailure(origin, param_ty, sub) => {
self.report_generic_bound_failure(
- region_scope_tree,
origin.span(),
Some(origin),
param_ty,
sup_r,
) => {
if sub_r.is_placeholder() {
- self.report_placeholder_failure(
- region_scope_tree,
- sub_origin,
- sub_r,
- sup_r,
- )
- .emit();
+ self.report_placeholder_failure(sub_origin, sub_r, sup_r).emit();
} else if sup_r.is_placeholder() {
- self.report_placeholder_failure(
- region_scope_tree,
- sup_origin,
- sub_r,
- sup_r,
- )
- .emit();
+ self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit();
} else {
self.report_sub_sup_conflict(
- region_scope_tree,
- var_origin,
- sub_origin,
- sub_r,
- sup_origin,
- sup_r,
+ var_origin, sub_origin, sub_r, sup_origin, sup_r,
);
}
}
// value.
let sub_r = self.tcx.mk_region(ty::ReEmpty(var_universe));
- self.report_placeholder_failure(
- region_scope_tree,
- sup_origin,
- sub_r,
- sup_r,
- )
- .emit();
+ self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit();
}
RegionResolutionError::MemberConstraintFailure {
let hidden_ty = self.resolve_vars_if_possible(&hidden_ty);
unexpected_hidden_region_diagnostic(
self.tcx,
- Some(region_scope_tree),
span,
hidden_ty,
member_region,
pub fn report_generic_bound_failure(
&self,
- region_scope_tree: ®ion::ScopeTree,
span: Span,
origin: Option<SubregionOrigin<'tcx>>,
bound_kind: GenericKind<'tcx>,
sub: Region<'tcx>,
) {
- self.construct_generic_bound_failure(region_scope_tree, span, origin, bound_kind, sub)
- .emit();
+ self.construct_generic_bound_failure(span, origin, bound_kind, sub).emit();
}
pub fn construct_generic_bound_failure(
&self,
- region_scope_tree: ®ion::ScopeTree,
span: Span,
origin: Option<SubregionOrigin<'tcx>>,
bound_kind: GenericKind<'tcx>,
));
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
&format!("{} must be valid for ", labeled_user_string),
sub,
fn report_sub_sup_conflict(
&self,
- region_scope_tree: ®ion::ScopeTree,
var_origin: RegionVariableOrigin,
sub_origin: SubregionOrigin<'tcx>,
sub_region: Region<'tcx>,
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"first, the lifetime cannot outlive ",
sup_region,
if sub_expected == sup_expected && sub_found == sup_found {
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"...but the lifetime must also be valid for ",
sub_region,
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"but, the lifetime must be valid for ",
sub_region,
use crate::infer::error_reporting::{note_and_explain_region, ObligationCauseExt};
use crate::infer::{self, InferCtxt, SubregionOrigin};
use rustc_errors::{struct_span_err, DiagnosticBuilder};
-use rustc_middle::middle::region;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{self, Region};
pub(super) fn report_concrete_failure(
&self,
- region_scope_tree: ®ion::ScopeTree,
origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>,
infer::Subtype(box trace) => {
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
let mut err = self.report_and_explain_type_error(trace, &terr);
- note_and_explain_region(self.tcx, region_scope_tree, &mut err, "", sup, "...");
+ note_and_explain_region(self.tcx, &mut err, "", sup, "...");
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"...does not necessarily outlive ",
sub,
);
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"...the reference is valid for ",
sub,
);
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"...but the borrowed content is only valid for ",
sup,
);
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"...the borrowed pointer is valid for ",
sub,
);
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
&format!("...but `{}` is only valid for ", var_name),
sup,
"lifetime of the source pointer does not outlive \
lifetime bound of the object type"
);
+ note_and_explain_region(self.tcx, &mut err, "object type is valid for ", sub, "");
note_and_explain_region(
self.tcx,
- region_scope_tree,
- &mut err,
- "object type is valid for ",
- sub,
- "",
- );
- note_and_explain_region(
- self.tcx,
- region_scope_tree,
&mut err,
"source pointer is only valid for ",
sup,
self.ty_to_string(ty)
);
match *sub {
- ty::ReStatic => note_and_explain_region(
- self.tcx,
- region_scope_tree,
- &mut err,
- "type must satisfy ",
- sub,
- "",
- ),
- _ => note_and_explain_region(
- self.tcx,
- region_scope_tree,
- &mut err,
- "type must outlive ",
- sub,
- "",
- ),
+ ty::ReStatic => {
+ note_and_explain_region(self.tcx, &mut err, "type must satisfy ", sub, "")
+ }
+ _ => note_and_explain_region(self.tcx, &mut err, "type must outlive ", sub, ""),
}
err
}
struct_span_err!(self.tcx.sess, span, E0478, "lifetime bound not satisfied");
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"lifetime parameter instantiated with ",
sup,
);
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"but lifetime parameter must outlive ",
sub,
);
note_and_explain_region(
self.tcx,
- region_scope_tree,
&mut err,
"the return value is only valid for ",
sup,
"a value of type `{}` is borrowed for too long",
self.ty_to_string(ty)
);
- note_and_explain_region(
- self.tcx,
- region_scope_tree,
- &mut err,
- "the type is valid for ",
- sub,
- "",
- );
- note_and_explain_region(
- self.tcx,
- region_scope_tree,
- &mut err,
- "but the borrow lasts for ",
- sup,
- "",
- );
+ note_and_explain_region(self.tcx, &mut err, "the type is valid for ", sub, "");
+ note_and_explain_region(self.tcx, &mut err, "but the borrow lasts for ", sup, "");
err
}
infer::ReferenceOutlivesReferent(ty, span) => {
"in type `{}`, reference has a longer lifetime than the data it references",
self.ty_to_string(ty)
);
+ note_and_explain_region(self.tcx, &mut err, "the pointer is valid for ", sub, "");
note_and_explain_region(
self.tcx,
- region_scope_tree,
- &mut err,
- "the pointer is valid for ",
- sub,
- "",
- );
- note_and_explain_region(
- self.tcx,
- region_scope_tree,
&mut err,
"but the referenced data is only valid for ",
sup,
pub(super) fn report_placeholder_failure(
&self,
- region_scope_tree: ®ion::ScopeTree,
placeholder_origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>,
self.report_and_explain_type_error(trace, &terr)
}
- _ => self.report_concrete_failure(region_scope_tree, placeholder_origin, sub, sup),
+ _ => self.report_concrete_failure(placeholder_origin, sub, sup),
}
}
}
use rustc_data_structures::transitive_relation::TransitiveRelation;
use rustc_hir::def_id::DefId;
-use rustc_middle::middle::region;
use rustc_middle::ty::{self, Lift, Region, TyCtxt};
/// Combines a `region::ScopeTree` (which governs relationships between
/// The context used to fetch the region maps.
pub context: DefId,
- /// The region maps for the given context.
- pub region_scope_tree: &'a region::ScopeTree,
-
/// Free-region relationships.
pub free_regions: &'a FreeRegionMap<'tcx>,
}
impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
- pub fn new(
- tcx: TyCtxt<'tcx>,
- context: DefId,
- region_scope_tree: &'a region::ScopeTree,
- free_regions: &'a FreeRegionMap<'tcx>,
- ) -> Self {
- Self { tcx, context, region_scope_tree, free_regions }
+ pub fn new(tcx: TyCtxt<'tcx>, context: DefId, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
+ Self { tcx, context, free_regions }
}
pub fn lub_free_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
-use rustc_middle::middle::region;
use rustc_middle::mir;
use rustc_middle::mir::interpret::ConstEvalResult;
use rustc_middle::traits::select;
pub fn resolve_regions_and_report_errors(
&self,
region_context: DefId,
- region_map: ®ion::ScopeTree,
outlives_env: &OutlivesEnvironment<'tcx>,
mode: RegionckMode,
) {
.into_infos_and_data()
};
- let region_rels = &RegionRelations::new(
- self.tcx,
- region_context,
- region_map,
- outlives_env.free_region_map(),
- );
+ let region_rels =
+ &RegionRelations::new(self.tcx, region_context, outlives_env.free_region_map());
let (lexical_region_resolutions, errors) =
lexical_region_resolve::resolve(region_rels, var_infos, data, mode);
// 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);
+ self.report_region_errors(&errors);
}
}
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
use crate::ich::{NodeIdHashingMode, StableHashingContext};
-use crate::ty::{self, DefIdTree, TyCtxt};
+use crate::ty::TyCtxt;
use rustc_hir as hir;
use rustc_hir::Node;
pub source: hir::YieldSource,
}
-impl<'tcx> ScopeTree {
+impl ScopeTree {
pub fn record_scope_parent(&mut self, child: Scope, parent: Option<(Scope, ScopeDepth)>) {
debug!("{:?}.parent = {:?}", child, parent);
}
}
- pub fn each_encl_scope<E>(&self, mut e: E)
- where
- E: FnMut(Scope, Scope),
- {
- for (&child, &parent) in &self.parent_map {
- e(child, parent.0)
- }
- }
-
- pub fn each_var_scope<E>(&self, mut e: E)
- where
- E: FnMut(&hir::ItemLocalId, Scope),
- {
- for (child, &parent) in self.var_map.iter() {
- e(child, parent)
- }
- }
-
pub fn opt_destruction_scope(&self, n: hir::ItemLocalId) -> Option<Scope> {
self.destruction_scopes.get(&n).cloned()
}
self.parent_map.get(&id).cloned().map(|(p, _)| p)
}
- /// Returns the narrowest scope that encloses `id`, if any.
- #[allow(dead_code)] // used in cfg
- pub fn encl_scope(&self, id: Scope) -> Scope {
- self.opt_encl_scope(id).unwrap()
- }
-
/// Returns the lifetime of the local variable `var_id`
pub fn var_scope(&self, var_id: hir::ItemLocalId) -> Scope {
self.var_map
None
}
- /// Returns the lifetime of the variable `id`.
- pub fn var_region(&self, id: hir::ItemLocalId) -> ty::RegionKind {
- let scope = ty::ReScope(self.var_scope(id));
- debug!("var_region({:?}) = {:?}", id, scope);
- scope
- }
-
- pub fn scopes_intersect(&self, scope1: Scope, scope2: Scope) -> bool {
- self.is_subscope_of(scope1, scope2) || self.is_subscope_of(scope2, scope1)
- }
-
/// Returns `true` if `subscope` is equal to or is lexically nested inside `superscope`, and
/// `false` otherwise.
pub fn is_subscope_of(&self, subscope: Scope, superscope: Scope) -> bool {
true
}
- /// Returns the ID of the innermost containing body.
- pub fn containing_body(&self, mut scope: Scope) -> Option<hir::ItemLocalId> {
- loop {
- if let ScopeData::CallSite = scope.data {
- return Some(scope.item_local_id());
- }
-
- scope = self.opt_encl_scope(scope)?;
- }
- }
-
- /// Finds the nearest common ancestor of two scopes. That is, finds the
- /// smallest scope which is greater than or equal to both `scope_a` and
- /// `scope_b`.
- pub fn nearest_common_ancestor(&self, scope_a: Scope, scope_b: Scope) -> Scope {
- if scope_a == scope_b {
- return scope_a;
- }
-
- let mut a = scope_a;
- let mut b = scope_b;
-
- // Get the depth of each scope's parent. If either scope has no parent,
- // it must be the root, which means we can stop immediately because the
- // root must be the nearest common ancestor. (In practice, this is
- // moderately common.)
- let (parent_a, parent_a_depth) = match self.parent_map.get(&a) {
- Some(pd) => *pd,
- None => return a,
- };
- let (parent_b, parent_b_depth) = match self.parent_map.get(&b) {
- Some(pd) => *pd,
- None => return b,
- };
-
- if parent_a_depth > parent_b_depth {
- // `a` is lower than `b`. Move `a` up until it's at the same depth
- // as `b`. The first move up is trivial because we already found
- // `parent_a` above; the loop does the remaining N-1 moves.
- a = parent_a;
- for _ in 0..(parent_a_depth - parent_b_depth - 1) {
- a = self.parent_map.get(&a).unwrap().0;
- }
- } else if parent_b_depth > parent_a_depth {
- // `b` is lower than `a`.
- b = parent_b;
- for _ in 0..(parent_b_depth - parent_a_depth - 1) {
- b = self.parent_map.get(&b).unwrap().0;
- }
- } else {
- // Both scopes are at the same depth, and we know they're not equal
- // because that case was tested for at the top of this function. So
- // we can trivially move them both up one level now.
- assert!(parent_a_depth != 0);
- a = parent_a;
- b = parent_b;
- }
-
- // Now both scopes are at the same level. We move upwards in lockstep
- // until they match. In practice, this loop is almost always executed
- // zero times because `a` is almost always a direct ancestor of `b` or
- // vice versa.
- while a != b {
- a = self.parent_map.get(&a).unwrap().0;
- b = self.parent_map.get(&b).unwrap().0;
- }
-
- a
- }
-
- /// Assuming that the provided region was defined within this `ScopeTree`,
- /// returns the outermost `Scope` that the region outlives.
- pub fn early_free_scope(&self, tcx: TyCtxt<'tcx>, br: &ty::EarlyBoundRegion) -> Scope {
- let param_owner = tcx.parent(br.def_id).unwrap();
-
- let param_owner_id = tcx.hir().as_local_hir_id(param_owner.expect_local());
- let scope = tcx
- .hir()
- .maybe_body_owned_by(param_owner_id)
- .map(|body_id| tcx.hir().body(body_id).value.hir_id.local_id)
- .unwrap_or_else(|| {
- // The lifetime was defined on node that doesn't own a body,
- // which in practice can only mean a trait or an impl, that
- // is the parent of a method, and that is enforced below.
- if Some(param_owner_id) != self.root_parent {
- tcx.sess.delay_span_bug(
- DUMMY_SP,
- &format!(
- "free_scope: {:?} not recognized by the \
- region scope tree for {:?} / {:?}",
- param_owner,
- self.root_parent.map(|id| tcx.hir().local_def_id(id)),
- self.root_body.map(|hir_id| hir_id.owner)
- ),
- );
- }
-
- // The trait/impl lifetime is in scope for the method's body.
- self.root_body.unwrap().local_id
- });
-
- Scope { id: scope, data: ScopeData::CallSite }
- }
-
- /// Assuming that the provided region was defined within this `ScopeTree`,
- /// returns the outermost `Scope` that the region outlives.
- pub fn free_scope(&self, tcx: TyCtxt<'tcx>, fr: &ty::FreeRegion) -> Scope {
- let param_owner = match fr.bound_region {
- ty::BoundRegion::BrNamed(def_id, _) => tcx.parent(def_id).unwrap(),
- _ => fr.scope,
- };
-
- // Ensure that the named late-bound lifetimes were defined
- // on the same function that they ended up being freed in.
- assert_eq!(param_owner, fr.scope);
-
- let param_owner_id = tcx.hir().as_local_hir_id(param_owner.expect_local());
- let body_id = tcx.hir().body_owned_by(param_owner_id);
- Scope { id: tcx.hir().body(body_id).value.hir_id.local_id, data: ScopeData::CallSite }
- }
-
/// Checks whether the given scope contains a `yield`. If so,
/// returns `Some((span, expr_count))` with the span of a yield we found and
/// the number of expressions and patterns appearing before the `yield` in the body + 1.
let type_test_span = type_test.locations.span(&self.body);
if let Some(lower_bound_region) = lower_bound_region {
- let region_scope_tree = &self.infcx.tcx.region_scope_tree(self.mir_def_id);
self.infcx
.construct_generic_bound_failure(
- region_scope_tree,
type_test_span,
None,
type_test.generic_kind,
}
RegionErrorKind::UnexpectedHiddenRegion { span, hidden_ty, member_region } => {
- let region_scope_tree = &self.infcx.tcx.region_scope_tree(self.mir_def_id);
let named_ty = self.regioncx.name_regions(self.infcx.tcx, hidden_ty);
let named_region = self.regioncx.name_regions(self.infcx.tcx, member_region);
unexpected_hidden_region_diagnostic(
self.infcx.tcx,
- Some(region_scope_tree),
span,
named_ty,
named_region,
if let Some(hidden_ty) = self.hidden_ty.take() {
unexpected_hidden_region_diagnostic(
self.tcx,
- None,
self.tcx.def_span(self.opaque_type_def_id),
hidden_ty,
r,
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
-use rustc_middle::middle::region;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
use rustc_middle::ty::{
debug!("do_normalize_predictes: normalized predicates = {:?}", predicates);
- let region_scope_tree = region::ScopeTree::default();
-
// We can use the `elaborated_env` here; the region code only
// 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,
RegionckMode::default(),
);
use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
use crate::astconv::AstConv;
-use crate::middle::region;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::{FutureTraitLangItem, GeneratorTraitLangItem};
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits::error_reporting::ArgKind;
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
-use rustc_trait_selection::traits::Obligation;
use std::cmp;
use std::iter;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{InferOk, RegionckMode, TyCtxtInferExt};
use rustc_infer::traits::TraitEngineExt as _;
-use rustc_middle::middle::region;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
use rustc_middle::ty::subst::{Subst, SubstsRef};
return Err(ErrorReported);
}
- let region_scope_tree = region::ScopeTree::default();
-
// NB. It seems a bit... suspicious to use an empty param-env
// here. The correct thing, I imagine, would be
// `OutlivesEnvironment::new(impl_param_env)`, which would
infcx.resolve_regions_and_report_errors(
drop_impl_did.to_def_id(),
- ®ion_scope_tree,
&outlives_env,
RegionckMode::default(),
);
use rustc_infer::infer;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{RegionckMode, TyCtxtInferExt};
-use rustc_middle::middle::region;
use rustc_middle::ty::adjustment::CoerceUnsizedInfo;
use rustc_middle::ty::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt};
}
// Finally, resolve all regions.
- let region_scope_tree = region::ScopeTree::default();
let outlives_env = OutlivesEnvironment::new(param_env);
infcx.resolve_regions_and_report_errors(
impl_did.to_def_id(),
- ®ion_scope_tree,
&outlives_env,
RegionckMode::default(),
);
}
// Finally, resolve all regions.
- let region_scope_tree = region::ScopeTree::default();
let outlives_env = OutlivesEnvironment::new(param_env);
- infcx.resolve_regions_and_report_errors(
- impl_did,
- ®ion_scope_tree,
- &outlives_env,
- RegionckMode::default(),
- );
+ infcx.resolve_regions_and_report_errors(impl_did, &outlives_env, RegionckMode::default());
CoerceUnsizedInfo { custom_kind: kind }
})
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{InferCtxt, RegionckMode, TyCtxtInferExt};
use rustc_infer::traits::specialization_graph::Node;
-use rustc_middle::middle::region::ScopeTree;
use rustc_middle::ty::subst::{GenericArg, InternalSubsts, SubstsRef};
use rustc_middle::ty::trait_def::TraitSpecializationKind;
use rustc_middle::ty::{self, InstantiatedPredicates, TyCtxt, TypeFoldable};
// Conservatively use an empty `ParamEnv`.
let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty());
- infcx.resolve_regions_and_report_errors(
- impl1_def_id,
- &ScopeTree::default(),
- &outlives_env,
- RegionckMode::default(),
- );
+ infcx.resolve_regions_and_report_errors(impl1_def_id, &outlives_env, RegionckMode::default());
let impl2_substs = match infcx.fully_resolve(&impl2_substs) {
Ok(s) => s,
Err(_) => {