mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
update type flags
- `HAS_RE_LATE_BOUND` -> `HAS_RE_BOUND` - `HAS_TY_LATE_BOUND` -> `HAS_TY_BOUND` - `HAS_CT_LATE_BOUND` -> `HAS_CT_BOUND` - `HAS_LATE_BOUND` -> `HAS_BOUND_VARS` - `fn has_late_bound_regions` -> `fn has_bound_regions` - `fnhas_non_region_late_bound` -> `fn has_non_region_bound_vars` - `fn has_late_bound_vars` -> `fn has_bound_vars`
This commit is contained in:
parent
dd0739aabe
commit
8935a1be01
@ -801,7 +801,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
// a `&self` method will wind up with an argument type like `&dyn Trait`.
|
||||
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
|
||||
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
|
||||
if new_trait_ref.has_non_region_late_bound() {
|
||||
if new_trait_ref.has_non_region_bound_vars() {
|
||||
this.tcx.sess.delay_span_bug(
|
||||
this.span,
|
||||
"tried to select method from HRTB with non-lifetime bound vars",
|
||||
|
@ -137,7 +137,7 @@ impl FlagComputation {
|
||||
|
||||
&ty::Bound(debruijn, _) => {
|
||||
self.add_bound_var(debruijn);
|
||||
self.add_flags(TypeFlags::HAS_TY_LATE_BOUND);
|
||||
self.add_flags(TypeFlags::HAS_TY_BOUND);
|
||||
}
|
||||
|
||||
&ty::Placeholder(..) => {
|
||||
@ -317,7 +317,7 @@ impl FlagComputation {
|
||||
}
|
||||
ty::ConstKind::Bound(debruijn, _) => {
|
||||
self.add_bound_var(debruijn);
|
||||
self.add_flags(TypeFlags::HAS_CT_LATE_BOUND);
|
||||
self.add_flags(TypeFlags::HAS_CT_BOUND);
|
||||
}
|
||||
ty::ConstKind::Param(_) => {
|
||||
self.add_flags(TypeFlags::HAS_CT_PARAM);
|
||||
|
@ -1815,7 +1815,7 @@ impl<'tcx> Region<'tcx> {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
}
|
||||
ty::ReBound(..) => {
|
||||
flags = flags | TypeFlags::HAS_RE_LATE_BOUND;
|
||||
flags = flags | TypeFlags::HAS_RE_BOUND;
|
||||
}
|
||||
ty::ReErased => {
|
||||
flags = flags | TypeFlags::HAS_RE_ERASED;
|
||||
|
@ -111,16 +111,16 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
|
||||
}
|
||||
|
||||
/// True if there are any late-bound regions
|
||||
fn has_late_bound_regions(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND)
|
||||
fn has_bound_regions(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_RE_BOUND)
|
||||
}
|
||||
/// True if there are any late-bound non-region variables
|
||||
fn has_non_region_late_bound(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_LATE_BOUND - TypeFlags::HAS_RE_LATE_BOUND)
|
||||
fn has_non_region_bound_vars(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_BOUND_VARS - TypeFlags::HAS_RE_BOUND)
|
||||
}
|
||||
/// True if there are any late-bound variables
|
||||
fn has_late_bound_vars(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_LATE_BOUND)
|
||||
/// True if there are any bound variables
|
||||
fn has_bound_vars(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_BOUND_VARS)
|
||||
}
|
||||
|
||||
/// Indicates whether this value still has parameters/placeholders/inference variables
|
||||
|
@ -91,7 +91,7 @@ pub(in crate::solve) fn replace_erased_lifetimes_with_bound_vars<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> ty::Binder<'tcx, Ty<'tcx>> {
|
||||
debug_assert!(!ty.has_late_bound_regions());
|
||||
debug_assert!(!ty.has_bound_regions());
|
||||
let mut counter = 0;
|
||||
let ty = tcx.fold_regions(ty, |r, current_depth| match r.kind() {
|
||||
ty::ReErased => {
|
||||
|
@ -329,7 +329,7 @@ fn super_predicates_have_non_lifetime_binders(
|
||||
tcx.super_predicates_of(trait_def_id)
|
||||
.predicates
|
||||
.iter()
|
||||
.filter_map(|(pred, span)| pred.has_non_region_late_bound().then_some(*span))
|
||||
.filter_map(|(pred, span)| pred.has_non_region_bound_vars().then_some(*span))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
@ -1277,7 +1277,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let tcx = self.tcx();
|
||||
stack.extend(tcx.coroutine_hidden_types(def_id).map(|bty| {
|
||||
let ty = bty.instantiate(tcx, args);
|
||||
debug_assert!(!ty.has_late_bound_regions());
|
||||
debug_assert!(!ty.has_bound_regions());
|
||||
ty
|
||||
}))
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// A global type with no free lifetimes or generic parameters
|
||||
// outlives anything.
|
||||
if pred.0.has_free_regions()
|
||||
|| pred.0.has_late_bound_regions()
|
||||
|| pred.0.has_bound_regions()
|
||||
|| pred.0.has_non_region_infer()
|
||||
|| pred.0.has_non_region_infer()
|
||||
{
|
||||
@ -1841,7 +1841,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
// the param_env so that it can be given the lowest priority. See
|
||||
// #50825 for the motivation for this.
|
||||
let is_global =
|
||||
|cand: &ty::PolyTraitPredicate<'tcx>| cand.is_global() && !cand.has_late_bound_vars();
|
||||
|cand: &ty::PolyTraitPredicate<'tcx>| cand.is_global() && !cand.has_bound_vars();
|
||||
|
||||
// (*) Prefer `BuiltinCandidate { has_nested: false }`, `PointeeCandidate`,
|
||||
// `DiscriminantKindCandidate`, `ConstDestructCandidate`
|
||||
|
@ -89,16 +89,16 @@ bitflags! {
|
||||
const HAS_FREE_REGIONS = 1 << 15;
|
||||
|
||||
/// Does this have any `ReBound` regions?
|
||||
const HAS_RE_LATE_BOUND = 1 << 16;
|
||||
const HAS_RE_BOUND = 1 << 16;
|
||||
/// Does this have any `Bound` types?
|
||||
const HAS_TY_LATE_BOUND = 1 << 17;
|
||||
const HAS_TY_BOUND = 1 << 17;
|
||||
/// Does this have any `ConstKind::Bound` consts?
|
||||
const HAS_CT_LATE_BOUND = 1 << 18;
|
||||
const HAS_CT_BOUND = 1 << 18;
|
||||
/// Does this have any bound variables?
|
||||
/// Used to check if a global bound is safe to evaluate.
|
||||
const HAS_LATE_BOUND = TypeFlags::HAS_RE_LATE_BOUND.bits
|
||||
| TypeFlags::HAS_TY_LATE_BOUND.bits
|
||||
| TypeFlags::HAS_CT_LATE_BOUND.bits;
|
||||
const HAS_BOUND_VARS = TypeFlags::HAS_RE_BOUND.bits
|
||||
| TypeFlags::HAS_TY_BOUND.bits
|
||||
| TypeFlags::HAS_CT_BOUND.bits;
|
||||
|
||||
/// Does this have any `ReErased` regions?
|
||||
const HAS_RE_ERASED = 1 << 19;
|
||||
|
@ -290,7 +290,7 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
|
||||
.zip(to_tys)
|
||||
.any(|(from_ty, to_ty)| check_ty(from_ty, to_ty))
|
||||
},
|
||||
_ => from_ty.has_late_bound_regions(),
|
||||
_ => from_ty.has_bound_regions(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1160,7 @@ pub fn make_normalized_projection<'tcx>(
|
||||
) -> Option<Ty<'tcx>> {
|
||||
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
||||
#[cfg(debug_assertions)]
|
||||
if let Some((i, arg)) = ty.args.iter().enumerate().find(|(_, arg)| arg.has_late_bound_regions()) {
|
||||
if let Some((i, arg)) = ty.args.iter().enumerate().find(|(_, arg)| arg.has_bound_regions()) {
|
||||
debug_assert!(
|
||||
false,
|
||||
"args contain late-bound region at index `{i}` which can't be normalized.\n\
|
||||
@ -1233,7 +1233,7 @@ pub fn make_normalized_projection_with_regions<'tcx>(
|
||||
) -> Option<Ty<'tcx>> {
|
||||
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
|
||||
#[cfg(debug_assertions)]
|
||||
if let Some((i, arg)) = ty.args.iter().enumerate().find(|(_, arg)| arg.has_late_bound_regions()) {
|
||||
if let Some((i, arg)) = ty.args.iter().enumerate().find(|(_, arg)| arg.has_bound_regions()) {
|
||||
debug_assert!(
|
||||
false,
|
||||
"args contain late-bound region at index `{i}` which can't be normalized.\n\
|
||||
|
Loading…
Reference in New Issue
Block a user