Rename Binder::no_late_bound_regions to Binder::no_bound_vars

This commit is contained in:
scalexm 2018-10-24 22:30:34 +02:00
parent 45be1ac0fc
commit d99195ad8f
18 changed files with 34 additions and 32 deletions

View File

@ -323,7 +323,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
predicates predicates
.into_iter() .into_iter()
.filter_map(|p| p.as_ref().to_opt_type_outlives()) .filter_map(|p| p.as_ref().to_opt_type_outlives())
.filter_map(|p| p.no_late_bound_regions()) .filter_map(|p| p.no_bound_vars())
.filter(move |p| compare_ty(p.0)) .filter(move |p| compare_ty(p.0))
} }
} }

View File

@ -683,8 +683,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
} }
&ty::Predicate::TypeOutlives(ref binder) => { &ty::Predicate::TypeOutlives(ref binder) => {
match ( match (
binder.no_late_bound_regions(), binder.no_bound_vars(),
binder.map_bound_ref(|pred| pred.0).no_late_bound_regions(), binder.map_bound_ref(|pred| pred.0).no_bound_vars(),
) { ) {
(None, Some(t_a)) => { (None, Some(t_a)) => {
select.infcx().register_region_obligation_with_cause( select.infcx().register_region_obligation_with_cause(

View File

@ -349,15 +349,15 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
} }
ty::Predicate::TypeOutlives(ref binder) => { ty::Predicate::TypeOutlives(ref binder) => {
// Check if there are higher-ranked regions. // Check if there are higher-ranked vars.
match binder.no_late_bound_regions() { match binder.no_bound_vars() {
// If there are, inspect the underlying type further. // If there are, inspect the underlying type further.
None => { None => {
// Convert from `Binder<OutlivesPredicate<Ty, Region>>` to `Binder<Ty>`. // Convert from `Binder<OutlivesPredicate<Ty, Region>>` to `Binder<Ty>`.
let binder = binder.map_bound_ref(|pred| pred.0); let binder = binder.map_bound_ref(|pred| pred.0);
// Check if the type has any bound regions. // Check if the type has any bound vars.
match binder.no_late_bound_regions() { match binder.no_bound_vars() {
// If so, this obligation is an error (for now). Eventually we should be // If so, this obligation is an error (for now). Eventually we should be
// able to support additional cases here, like `for<'a> &'a str: 'a`. // able to support additional cases here, like `for<'a> &'a str: 'a`.
// NOTE: this is duplicate-implemented between here and fulfillment. // NOTE: this is duplicate-implemented between here and fulfillment.

View File

@ -352,7 +352,7 @@ impl<'tcx> GoalKind<'tcx> {
domain_goal: PolyDomainGoal<'tcx>, domain_goal: PolyDomainGoal<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>,
) -> GoalKind<'tcx> { ) -> GoalKind<'tcx> {
match domain_goal.no_late_bound_regions() { match domain_goal.no_bound_vars() {
Some(p) => p.into_goal(), Some(p) => p.into_goal(),
None => GoalKind::Quantified( None => GoalKind::Quantified(
QuantifierKind::Universal, QuantifierKind::Universal,

View File

@ -1619,7 +1619,7 @@ impl<'cx, 'gcx, 'tcx> ProjectionCacheKey<'tcx> {
let infcx = selcx.infcx(); let infcx = selcx.infcx();
// We don't do cross-snapshot caching of obligations with escaping regions, // We don't do cross-snapshot caching of obligations with escaping regions,
// so there's no cache key to use // so there's no cache key to use
predicate.no_late_bound_regions() predicate.no_bound_vars()
.map(|predicate| ProjectionCacheKey { .map(|predicate| ProjectionCacheKey {
// We don't attempt to match up with a specific type-variable state // We don't attempt to match up with a specific type-variable state
// from a specific call to `opt_normalize_projection_type` - if // from a specific call to `opt_normalize_projection_type` - if

View File

@ -164,7 +164,7 @@ pub fn explicit_outlives_bounds<'tcx>(
ty::Predicate::ClosureKind(..) | ty::Predicate::ClosureKind(..) |
ty::Predicate::TypeOutlives(..) | ty::Predicate::TypeOutlives(..) |
ty::Predicate::ConstEvaluatable(..) => None, ty::Predicate::ConstEvaluatable(..) => None,
ty::Predicate::RegionOutlives(ref data) => data.no_late_bound_regions().map( ty::Predicate::RegionOutlives(ref data) => data.no_bound_vars().map(
|ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a), |ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a),
), ),
}) })

View File

@ -2168,7 +2168,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// T: Trait // T: Trait
// so it seems ok if we (conservatively) fail to accept that `Unsize` // so it seems ok if we (conservatively) fail to accept that `Unsize`
// obligation above. Should be possible to extend this in the future. // obligation above. Should be possible to extend this in the future.
let source = match obligation.self_ty().no_late_bound_regions() { let source = match obligation.self_ty().no_bound_vars() {
Some(t) => t, Some(t) => t,
None => { None => {
// Don't add any candidates if there are bound regions. // Don't add any candidates if there are bound regions.
@ -3235,7 +3235,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// assemble_candidates_for_unsizing should ensure there are no late bound // assemble_candidates_for_unsizing should ensure there are no late bound
// regions here. See the comment there for more details. // regions here. See the comment there for more details.
let source = self.infcx let source = self.infcx
.shallow_resolve(obligation.self_ty().no_late_bound_regions().unwrap()); .shallow_resolve(obligation.self_ty().no_bound_vars().unwrap());
let target = obligation let target = obligation
.predicate .predicate
.skip_binder() .skip_binder()

View File

@ -799,10 +799,10 @@ impl<T> Binder<T> {
/// Skips the binder and returns the "bound" value. This is a /// Skips the binder and returns the "bound" value. This is a
/// risky thing to do because it's easy to get confused about /// risky thing to do because it's easy to get confused about
/// debruijn indices and the like. It is usually better to /// debruijn indices and the like. It is usually better to
/// discharge the binder using `no_late_bound_regions` or /// discharge the binder using `no_bound_vars` or
/// `replace_late_bound_regions` or something like /// `replace_late_bound_regions` or something like
/// that. `skip_binder` is only valid when you are either /// that. `skip_binder` is only valid when you are either
/// extracting data that has nothing to do with bound regions, you /// extracting data that has nothing to do with bound vars, you
/// are doing some sort of test that does not involve bound /// are doing some sort of test that does not involve bound
/// regions, or you are being very careful about your depth /// regions, or you are being very careful about your depth
/// accounting. /// accounting.
@ -811,7 +811,7 @@ impl<T> Binder<T> {
/// ///
/// - extracting the def-id from a PolyTraitRef; /// - extracting the def-id from a PolyTraitRef;
/// - comparing the self type of a PolyTraitRef to see if it is equal to /// - comparing the self type of a PolyTraitRef to see if it is equal to
/// a type parameter `X`, since the type `X` does not reference any regions /// a type parameter `X`, since the type `X` does not reference any regions
pub fn skip_binder(&self) -> &T { pub fn skip_binder(&self) -> &T {
&self.0 &self.0
} }
@ -833,17 +833,17 @@ impl<T> Binder<T> {
} }
/// Unwraps and returns the value within, but only if it contains /// Unwraps and returns the value within, but only if it contains
/// no bound regions at all. (In other words, if this binder -- /// no bound vars at all. (In other words, if this binder --
/// and indeed any enclosing binder -- doesn't bind anything at /// and indeed any enclosing binder -- doesn't bind anything at
/// all.) Otherwise, returns `None`. /// all.) Otherwise, returns `None`.
/// ///
/// (One could imagine having a method that just unwraps a single /// (One could imagine having a method that just unwraps a single
/// binder, but permits late-bound regions bound by enclosing /// binder, but permits late-bound vars bound by enclosing
/// binders, but that would require adjusting the debruijn /// binders, but that would require adjusting the debruijn
/// indices, and given the shallow binding structure we often use, /// indices, and given the shallow binding structure we often use,
/// would not be that useful.) /// would not be that useful.)
pub fn no_late_bound_regions<'tcx>(self) -> Option<T> pub fn no_bound_vars<'tcx>(self) -> Option<T>
where T : TypeFoldable<'tcx> where T: TypeFoldable<'tcx>
{ {
if self.skip_binder().has_escaping_bound_vars() { if self.skip_binder().has_escaping_bound_vars() {
None None

View File

@ -557,7 +557,7 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {
// regions must appear in the argument // regions must appear in the argument
// listing. // listing.
let main_ret_ty = cx.tcx.erase_regions( let main_ret_ty = cx.tcx.erase_regions(
&main_ret_ty.no_late_bound_regions().unwrap(), &main_ret_ty.no_bound_vars().unwrap(),
); );
if declare::get_defined_value(cx, "main").is_some() { if declare::get_defined_value(cx, "main").is_some() {

View File

@ -82,9 +82,9 @@ impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> {
// when we move to universes, we will, and this assertion // when we move to universes, we will, and this assertion
// will start to fail. // will start to fail.
let ty::OutlivesPredicate(k1, r2) = let ty::OutlivesPredicate(k1, r2) =
query_constraint.no_late_bound_regions().unwrap_or_else(|| { query_constraint.no_bound_vars().unwrap_or_else(|| {
bug!( bug!(
"query_constraint {:?} contained bound regions", "query_constraint {:?} contained bound vars",
query_constraint, query_constraint,
); );
}); });

View File

@ -2214,8 +2214,8 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
.enumerate() .enumerate()
.filter_map(|(idx, constraint)| { .filter_map(|(idx, constraint)| {
let ty::OutlivesPredicate(k1, r2) = let ty::OutlivesPredicate(k1, r2) =
constraint.no_late_bound_regions().unwrap_or_else(|| { constraint.no_bound_vars().unwrap_or_else(|| {
bug!("query_constraint {:?} contained bound regions", constraint,); bug!("query_constraint {:?} contained bound vars", constraint,);
}); });
match k1.unpack() { match k1.unpack() {

View File

@ -1082,7 +1082,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
// regions must appear in the argument // regions must appear in the argument
// listing. // listing.
let main_ret_ty = self.tcx.erase_regions( let main_ret_ty = self.tcx.erase_regions(
&main_ret_ty.no_late_bound_regions().unwrap(), &main_ret_ty.no_bound_vars().unwrap(),
); );
let start_instance = Instance::resolve( let start_instance = Instance::resolve(

View File

@ -844,7 +844,9 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
let param_env = gcx.param_env(def_id); let param_env = gcx.param_env(def_id);
// Normalize the sig. // Normalize the sig.
let sig = gcx.fn_sig(def_id).no_late_bound_regions().expect("LBR in ADT constructor signature"); let sig = gcx.fn_sig(def_id)
.no_bound_vars()
.expect("LBR in ADT constructor signature");
let sig = gcx.normalize_erasing_regions(param_env, sig); let sig = gcx.normalize_erasing_regions(param_env, sig);
let (adt_def, substs) = match sig.output().sty { let (adt_def, substs) = match sig.output().sty {

View File

@ -143,7 +143,7 @@ fn check_lang_item_type<'a, 'tcx, D>(
{ {
let did = tcx.require_lang_item(lang_item); let did = tcx.require_lang_item(lang_item);
let poly_sig = tcx.fn_sig(did); let poly_sig = tcx.fn_sig(did);
let sig = poly_sig.no_late_bound_regions().unwrap(); let sig = poly_sig.no_bound_vars().unwrap();
let lhs_ty = lhs.ty(local_decls, tcx); let lhs_ty = lhs.ty(local_decls, tcx);
let rhs_ty = rhs.ty(local_decls, tcx); let rhs_ty = rhs.ty(local_decls, tcx);
let place_ty = place.ty(local_decls, tcx).to_ty(tcx); let place_ty = place.ty(local_decls, tcx).to_ty(tcx);

View File

@ -122,14 +122,14 @@ fn compute_implied_outlives_bounds<'tcx>(
vec![] vec![]
} }
ty::Predicate::RegionOutlives(ref data) => match data.no_late_bound_regions() { ty::Predicate::RegionOutlives(ref data) => match data.no_bound_vars() {
None => vec![], None => vec![],
Some(ty::OutlivesPredicate(r_a, r_b)) => { Some(ty::OutlivesPredicate(r_a, r_b)) => {
vec![OutlivesBound::RegionSubRegion(r_b, r_a)] vec![OutlivesBound::RegionSubRegion(r_b, r_a)]
} }
}, },
ty::Predicate::TypeOutlives(ref data) => match data.no_late_bound_regions() { ty::Predicate::TypeOutlives(ref data) => match data.no_bound_vars() {
None => vec![], None => vec![],
Some(ty::OutlivesPredicate(ty_a, r_b)) => { Some(ty::OutlivesPredicate(ty_a, r_b)) => {
let ty_a = infcx.resolve_type_vars_if_possible(&ty_a); let ty_a = infcx.resolve_type_vars_if_possible(&ty_a);

View File

@ -816,7 +816,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
} }
// Replace constructor type with constructed type for tuple struct patterns. // Replace constructor type with constructed type for tuple struct patterns.
let pat_ty = pat_ty.fn_sig(tcx).output(); let pat_ty = pat_ty.fn_sig(tcx).output();
let pat_ty = pat_ty.no_late_bound_regions().expect("expected fn type"); let pat_ty = pat_ty.no_bound_vars().expect("expected fn type");
self.demand_eqtype(pat.span, expected, pat_ty); self.demand_eqtype(pat.span, expected, pat_ty);

View File

@ -419,7 +419,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let mut structural_to_nomimal = FxHashMap::default(); let mut structural_to_nomimal = FxHashMap::default();
let sig = tcx.fn_sig(def_id); let sig = tcx.fn_sig(def_id);
let sig = sig.no_late_bound_regions().unwrap(); let sig = sig.no_bound_vars().unwrap();
if intr.inputs.len() != sig.inputs().len() { if intr.inputs.len() != sig.inputs().len() {
span_err!(tcx.sess, it.span, E0444, span_err!(tcx.sess, it.span, E0444,
"platform-specific intrinsic has invalid number of \ "platform-specific intrinsic has invalid number of \

View File

@ -208,7 +208,7 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
item_def_id: DefId, item_def_id: DefId,
poly_trait_ref: ty::PolyTraitRef<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
if let Some(trait_ref) = poly_trait_ref.no_late_bound_regions() { if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
self.tcx().mk_projection(item_def_id, trait_ref.substs) self.tcx().mk_projection(item_def_id, trait_ref.substs)
} else { } else {
// no late-bound regions, we can just ignore the binder // no late-bound regions, we can just ignore the binder