rename needs_subst
to has_param
This commit is contained in:
parent
f04b8fe0af
commit
842419712a
@ -515,7 +515,7 @@ fn get_containing_scope<'ll, 'tcx>(
|
|||||||
ty::Adt(def, ..) if !def.is_box() => {
|
ty::Adt(def, ..) if !def.is_box() => {
|
||||||
// Again, only create type information if full debuginfo is enabled
|
// Again, only create type information if full debuginfo is enabled
|
||||||
if cx.sess().opts.debuginfo == DebugInfo::Full
|
if cx.sess().opts.debuginfo == DebugInfo::Full
|
||||||
&& !impl_self_ty.needs_subst()
|
&& !impl_self_ty.has_param()
|
||||||
{
|
{
|
||||||
Some(type_di_node(cx, impl_self_ty))
|
Some(type_di_node(cx, impl_self_ty))
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,7 +14,7 @@ pub(crate) fn ensure_monomorphic_enough<'tcx, T>(tcx: TyCtxt<'tcx>, ty: T) -> In
|
|||||||
T: TypeVisitable<TyCtxt<'tcx>>,
|
T: TypeVisitable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
debug!("ensure_monomorphic_enough: ty={:?}", ty);
|
debug!("ensure_monomorphic_enough: ty={:?}", ty);
|
||||||
if !ty.needs_subst() {
|
if !ty.has_param() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedSubstVisitor<'tcx> {
|
|||||||
type BreakTy = FoundParam;
|
type BreakTy = FoundParam;
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if !ty.needs_subst() {
|
if !ty.has_param() {
|
||||||
return ControlFlow::Continue(());
|
return ControlFlow::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
|||||||
// are used and require substitution.
|
// are used and require substitution.
|
||||||
// Just in case there are closures or generators within this subst,
|
// Just in case there are closures or generators within this subst,
|
||||||
// recurse.
|
// recurse.
|
||||||
if unused_params.is_used(index) && subst.needs_subst() {
|
if unused_params.is_used(index) && subst.has_param() {
|
||||||
return subst.visit_with(self);
|
return subst.visit_with(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3039,7 +3039,7 @@ pub fn res_to_ty(
|
|||||||
// the anon const, which is empty. This is why the
|
// the anon const, which is empty. This is why the
|
||||||
// `AlwaysApplicable` impl needs a `T: ?Sized` bound for
|
// `AlwaysApplicable` impl needs a `T: ?Sized` bound for
|
||||||
// this to compile if we were to normalize here.
|
// this to compile if we were to normalize here.
|
||||||
if forbid_generic && ty.needs_subst() {
|
if forbid_generic && ty.has_param() {
|
||||||
let mut err = tcx.sess.struct_span_err(
|
let mut err = tcx.sess.struct_span_err(
|
||||||
path.span,
|
path.span,
|
||||||
"generic `Self` types are currently not permitted in anonymous constants",
|
"generic `Self` types are currently not permitted in anonymous constants",
|
||||||
|
@ -1292,7 +1292,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||||||
// Ignore dependent defaults -- that is, where the default of one type
|
// Ignore dependent defaults -- that is, where the default of one type
|
||||||
// parameter includes another (e.g., `<T, U = T>`). In those cases, we can't
|
// parameter includes another (e.g., `<T, U = T>`). In those cases, we can't
|
||||||
// be sure if it will error or not as user might always specify the other.
|
// be sure if it will error or not as user might always specify the other.
|
||||||
if !ty.needs_subst() {
|
if !ty.has_param() {
|
||||||
wfcx.register_wf_obligation(
|
wfcx.register_wf_obligation(
|
||||||
tcx.def_span(param.def_id),
|
tcx.def_span(param.def_id),
|
||||||
Some(WellFormedLoc::Ty(param.def_id.expect_local())),
|
Some(WellFormedLoc::Ty(param.def_id.expect_local())),
|
||||||
@ -1308,7 +1308,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||||||
// for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>`
|
// for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>`
|
||||||
// we should eagerly error.
|
// we should eagerly error.
|
||||||
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
|
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
|
||||||
if !default_ct.needs_subst() {
|
if !default_ct.has_param() {
|
||||||
wfcx.register_wf_obligation(
|
wfcx.register_wf_obligation(
|
||||||
tcx.def_span(param.def_id),
|
tcx.def_span(param.def_id),
|
||||||
None,
|
None,
|
||||||
@ -1342,7 +1342,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||||||
if is_our_default(param) {
|
if is_our_default(param) {
|
||||||
let default_ty = tcx.type_of(param.def_id).subst_identity();
|
let default_ty = tcx.type_of(param.def_id).subst_identity();
|
||||||
// ... and it's not a dependent default, ...
|
// ... and it's not a dependent default, ...
|
||||||
if !default_ty.needs_subst() {
|
if !default_ty.has_param() {
|
||||||
// ... then substitute it with the default.
|
// ... then substitute it with the default.
|
||||||
return default_ty.into();
|
return default_ty.into();
|
||||||
}
|
}
|
||||||
@ -1355,7 +1355,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||||||
if is_our_default(param) {
|
if is_our_default(param) {
|
||||||
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
|
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
|
||||||
// ... and it's not a dependent default, ...
|
// ... and it's not a dependent default, ...
|
||||||
if !default_ct.needs_subst() {
|
if !default_ct.has_param() {
|
||||||
// ... then substitute it with the default.
|
// ... then substitute it with the default.
|
||||||
return default_ct.into();
|
return default_ct.into();
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ fn emit_newtype_suggestion_for_raw_ptr(
|
|||||||
ptr_ty: &ty::TypeAndMut<'_>,
|
ptr_ty: &ty::TypeAndMut<'_>,
|
||||||
diag: &mut Diagnostic,
|
diag: &mut Diagnostic,
|
||||||
) {
|
) {
|
||||||
if !self_ty.needs_subst() {
|
if !self_ty.has_param() {
|
||||||
let mut_key = ptr_ty.mutbl.prefix_str();
|
let mut_key = ptr_ty.mutbl.prefix_str();
|
||||||
let msg_sugg = "consider introducing a new wrapper type".to_owned();
|
let msg_sugg = "consider introducing a new wrapper type".to_owned();
|
||||||
let sugg = vec![
|
let sugg = vec![
|
||||||
|
@ -1384,7 +1384,7 @@ pub(crate) fn suggest_associated_const(
|
|||||||
}
|
}
|
||||||
let item_ty = self.tcx.type_of(item.def_id).subst_identity();
|
let item_ty = self.tcx.type_of(item.def_id).subst_identity();
|
||||||
// FIXME(compiler-errors): This check is *so* rudimentary
|
// FIXME(compiler-errors): This check is *so* rudimentary
|
||||||
if item_ty.needs_subst() {
|
if item_ty.has_param() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if self.can_coerce(item_ty, expected_ty) {
|
if self.can_coerce(item_ty, expected_ty) {
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
/// Returns `true` if we know for sure that the given type is not an enum. Note that for cases where
|
/// Returns `true` if we know for sure that the given type is not an enum. Note that for cases where
|
||||||
/// the type is generic, we can't be certain if it will be an enum so we have to assume that it is.
|
/// the type is generic, we can't be certain if it will be an enum so we have to assume that it is.
|
||||||
fn is_non_enum(t: Ty<'_>) -> bool {
|
fn is_non_enum(t: Ty<'_>) -> bool {
|
||||||
!t.is_enum() && !t.needs_subst()
|
!t.is_enum() && !t.has_param()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enforce_mem_discriminant(
|
fn enforce_mem_discriminant(
|
||||||
|
@ -761,7 +761,7 @@ pub fn subst_identity(self) -> T {
|
|||||||
|
|
||||||
/// Returns the inner value, but only if it contains no bound vars.
|
/// Returns the inner value, but only if it contains no bound vars.
|
||||||
pub fn no_bound_vars(self) -> Option<T> {
|
pub fn no_bound_vars(self) -> Option<T> {
|
||||||
if !self.0.needs_subst() { Some(self.0) } else { None }
|
if !self.0.has_param() { Some(self.0) } else { None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ fn region_param_invalid(data: ty::EarlyBoundRegion, other: GenericArgKind<'_>) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if !t.needs_subst() {
|
if !t.has_param() {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn has_non_region_param(&self) -> bool {
|
fn has_non_region_param(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::NEEDS_SUBST - TypeFlags::HAS_RE_PARAM)
|
self.has_type_flags(TypeFlags::HAS_PARAM - TypeFlags::HAS_RE_PARAM)
|
||||||
}
|
}
|
||||||
fn has_infer_regions(&self) -> bool {
|
fn has_infer_regions(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_RE_INFER)
|
self.has_type_flags(TypeFlags::HAS_RE_INFER)
|
||||||
@ -94,8 +94,8 @@ fn has_placeholders(&self) -> bool {
|
|||||||
fn has_non_region_placeholders(&self) -> bool {
|
fn has_non_region_placeholders(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_TY_PLACEHOLDER | TypeFlags::HAS_CT_PLACEHOLDER)
|
self.has_type_flags(TypeFlags::HAS_TY_PLACEHOLDER | TypeFlags::HAS_CT_PLACEHOLDER)
|
||||||
}
|
}
|
||||||
fn needs_subst(&self) -> bool {
|
fn has_param(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::NEEDS_SUBST)
|
self.has_type_flags(TypeFlags::HAS_PARAM)
|
||||||
}
|
}
|
||||||
/// "Free" regions in this context means that it has any region
|
/// "Free" regions in this context means that it has any region
|
||||||
/// that is not (a) erased or (b) late-bound.
|
/// that is not (a) erased or (b) late-bound.
|
||||||
|
@ -428,7 +428,7 @@ fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, lo
|
|||||||
/// Returns the value, if any, of evaluating `c`.
|
/// Returns the value, if any, of evaluating `c`.
|
||||||
fn eval_constant(&mut self, c: &Constant<'tcx>) -> Option<OpTy<'tcx>> {
|
fn eval_constant(&mut self, c: &Constant<'tcx>) -> Option<OpTy<'tcx>> {
|
||||||
// FIXME we need to revisit this for #67176
|
// FIXME we need to revisit this for #67176
|
||||||
if c.needs_subst() {
|
if c.has_param() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ fn check_rvalue(&mut self, rvalue: &Rvalue<'tcx>) -> Option<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME we need to revisit this for #67176
|
// FIXME we need to revisit this for #67176
|
||||||
if rvalue.needs_subst() {
|
if rvalue.has_param() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if !rvalue
|
if !rvalue
|
||||||
|
@ -281,7 +281,7 @@ fn use_ecx<F, T>(&mut self, location: Location, f: F) -> Option<T>
|
|||||||
/// Returns the value, if any, of evaluating `c`.
|
/// Returns the value, if any, of evaluating `c`.
|
||||||
fn eval_constant(&mut self, c: &Constant<'tcx>, location: Location) -> Option<OpTy<'tcx>> {
|
fn eval_constant(&mut self, c: &Constant<'tcx>, location: Location) -> Option<OpTy<'tcx>> {
|
||||||
// FIXME we need to revisit this for #67176
|
// FIXME we need to revisit this for #67176
|
||||||
if c.needs_subst() {
|
if c.has_param() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ fn check_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) -> Option<
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME we need to revisit this for #67176
|
// FIXME we need to revisit this for #67176
|
||||||
if rvalue.needs_subst() {
|
if rvalue.has_param() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if !rvalue.ty(self.local_decls(), self.tcx).is_sized(self.tcx, self.param_env) {
|
if !rvalue.ty(self.local_decls(), self.tcx).is_sized(self.tcx, self.param_env) {
|
||||||
|
@ -92,7 +92,7 @@ fn process<'tcx>(
|
|||||||
// FIXME: A not fully substituted drop shim can cause ICEs if one attempts to
|
// FIXME: A not fully substituted drop shim can cause ICEs if one attempts to
|
||||||
// have its MIR built. Likely oli-obk just screwed up the `ParamEnv`s, so this
|
// have its MIR built. Likely oli-obk just screwed up the `ParamEnv`s, so this
|
||||||
// needs some more analysis.
|
// needs some more analysis.
|
||||||
if callee.needs_subst() {
|
if callee.has_param() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
|
|||||||
|
|
||||||
// When polymorphization is enabled, methods which do not depend on their generic
|
// When polymorphization is enabled, methods which do not depend on their generic
|
||||||
// parameters, but the self-type of their impl block do will fail to normalize.
|
// parameters, but the self-type of their impl block do will fail to normalize.
|
||||||
if !tcx.sess.opts.unstable_opts.polymorphize || !instance.needs_subst() {
|
if !tcx.sess.opts.unstable_opts.polymorphize || !instance.has_param() {
|
||||||
// This is a method within an impl, find out what the self-type is:
|
// This is a method within an impl, find out what the self-type is:
|
||||||
let impl_self_ty = tcx.subst_and_normalize_erasing_regions(
|
let impl_self_ty = tcx.subst_and_normalize_erasing_regions(
|
||||||
instance.substs,
|
instance.substs,
|
||||||
|
@ -108,7 +108,7 @@ fn get_symbol_hash<'tcx>(
|
|||||||
tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
|
tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
|
||||||
|
|
||||||
// Include the main item-type. Note that, in this case, the
|
// Include the main item-type. Note that, in this case, the
|
||||||
// assertions about `needs_subst` may not hold, but this item-type
|
// assertions about `has_param` may not hold, but this item-type
|
||||||
// ought to be the same for every reference anyway.
|
// ought to be the same for every reference anyway.
|
||||||
assert!(!item_type.has_erasable_regions());
|
assert!(!item_type.has_erasable_regions());
|
||||||
hcx.while_hashing_spans(false, |hcx| {
|
hcx.while_hashing_spans(false, |hcx| {
|
||||||
|
@ -582,7 +582,7 @@ fn orphan_check_trait_ref<'tcx>(
|
|||||||
trait_ref: ty::TraitRef<'tcx>,
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
in_crate: InCrate,
|
in_crate: InCrate,
|
||||||
) -> Result<(), OrphanCheckErr<'tcx>> {
|
) -> Result<(), OrphanCheckErr<'tcx>> {
|
||||||
if trait_ref.has_infer() && trait_ref.needs_subst() {
|
if trait_ref.has_infer() && trait_ref.has_param() {
|
||||||
bug!(
|
bug!(
|
||||||
"can't orphan check a trait ref with both params and inference variables {:?}",
|
"can't orphan check a trait ref with both params and inference variables {:?}",
|
||||||
trait_ref
|
trait_ref
|
||||||
|
@ -414,7 +414,7 @@ fn subst_and_check_impossible_predicates<'tcx>(
|
|||||||
predicates.push(ty::Binder::dummy(trait_ref).to_predicate(tcx));
|
predicates.push(ty::Binder::dummy(trait_ref).to_predicate(tcx));
|
||||||
}
|
}
|
||||||
|
|
||||||
predicates.retain(|predicate| !predicate.needs_subst());
|
predicates.retain(|predicate| !predicate.has_param());
|
||||||
let result = impossible_predicates(tcx, predicates);
|
let result = impossible_predicates(tcx, predicates);
|
||||||
|
|
||||||
debug!("subst_and_check_impossible_predicates(key={:?}) = {:?}", key, result);
|
debug!("subst_and_check_impossible_predicates(key={:?}) = {:?}", key, result);
|
||||||
|
@ -1000,7 +1000,7 @@ fn evaluate_trait_predicate_recursively<'o>(
|
|||||||
) -> Result<EvaluationResult, OverflowError> {
|
) -> Result<EvaluationResult, OverflowError> {
|
||||||
if !self.is_intercrate()
|
if !self.is_intercrate()
|
||||||
&& obligation.is_global()
|
&& obligation.is_global()
|
||||||
&& obligation.param_env.caller_bounds().iter().all(|bound| bound.needs_subst())
|
&& obligation.param_env.caller_bounds().iter().all(|bound| bound.has_param())
|
||||||
{
|
{
|
||||||
// If a param env has no global bounds, global obligations do not
|
// If a param env has no global bounds, global obligations do not
|
||||||
// depend on its particular value in order to work, so we can clear
|
// depend on its particular value in order to work, so we can clear
|
||||||
|
@ -179,7 +179,7 @@ pub struct TypeFlags: u32 {
|
|||||||
/// Does this have `ConstKind::Param`?
|
/// Does this have `ConstKind::Param`?
|
||||||
const HAS_CT_PARAM = 1 << 2;
|
const HAS_CT_PARAM = 1 << 2;
|
||||||
|
|
||||||
const NEEDS_SUBST = TypeFlags::HAS_TY_PARAM.bits
|
const HAS_PARAM = TypeFlags::HAS_TY_PARAM.bits
|
||||||
| TypeFlags::HAS_RE_PARAM.bits
|
| TypeFlags::HAS_RE_PARAM.bits
|
||||||
| TypeFlags::HAS_CT_PARAM.bits;
|
| TypeFlags::HAS_CT_PARAM.bits;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user