Auto merge of #110882 - BoxyUwU:rename-some-ty-flags, r=compiler-errors
rename `NEEDS_SUBST` and `NEEDS_INFER` implements rust-lang/compiler-team#617
This commit is contained in:
commit
6ce22733b9
46 changed files with 86 additions and 85 deletions
|
@ -70,7 +70,7 @@ pub(crate) fn get_function_sig<'tcx>(
|
||||||
default_call_conv: CallConv,
|
default_call_conv: CallConv,
|
||||||
inst: Instance<'tcx>,
|
inst: Instance<'tcx>,
|
||||||
) -> Signature {
|
) -> Signature {
|
||||||
assert!(!inst.substs.needs_infer());
|
assert!(!inst.substs.has_infer());
|
||||||
clif_sig_from_fn_abi(
|
clif_sig_from_fn_abi(
|
||||||
tcx,
|
tcx,
|
||||||
default_call_conv,
|
default_call_conv,
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||||
module: &mut dyn Module,
|
module: &mut dyn Module,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) -> CodegenedFunction {
|
) -> CodegenedFunction {
|
||||||
debug_assert!(!instance.substs.needs_infer());
|
debug_assert!(!instance.substs.has_infer());
|
||||||
|
|
||||||
let symbol_name = tcx.symbol_name(instance).name.to_string();
|
let symbol_name = tcx.symbol_name(instance).name.to_string();
|
||||||
let _timer = tcx.prof.generic_activity_with_arg("codegen fn", &*symbol_name);
|
let _timer = tcx.prof.generic_activity_with_arg("codegen fn", &*symbol_name);
|
||||||
|
|
|
@ -17,7 +17,7 @@ use crate::context::CodegenCx;
|
||||||
pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>) -> Function<'gcc> {
|
pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>) -> Function<'gcc> {
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
|
|
||||||
assert!(!instance.substs.needs_infer());
|
assert!(!instance.substs.has_infer());
|
||||||
assert!(!instance.substs.has_escaping_bound_vars());
|
assert!(!instance.substs.has_escaping_bound_vars());
|
||||||
|
|
||||||
let sym = tcx.symbol_name(instance).name;
|
let sym = tcx.symbol_name(instance).name;
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl<'gcc, 'tcx> PreDefineMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||||
|
|
||||||
#[cfg_attr(not(feature="master"), allow(unused_variables))]
|
#[cfg_attr(not(feature="master"), allow(unused_variables))]
|
||||||
fn predefine_fn(&self, instance: Instance<'tcx>, linkage: Linkage, visibility: Visibility, symbol_name: &str) {
|
fn predefine_fn(&self, instance: Instance<'tcx>, linkage: Linkage, visibility: Visibility, symbol_name: &str) {
|
||||||
assert!(!instance.substs.needs_infer());
|
assert!(!instance.substs.has_infer());
|
||||||
|
|
||||||
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
|
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
|
||||||
self.linkage.set(base::linkage_to_gcc(linkage));
|
self.linkage.set(base::linkage_to_gcc(linkage));
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) ->
|
||||||
|
|
||||||
debug!("get_fn(instance={:?})", instance);
|
debug!("get_fn(instance={:?})", instance);
|
||||||
|
|
||||||
assert!(!instance.substs.needs_infer());
|
assert!(!instance.substs.has_infer());
|
||||||
assert!(!instance.substs.has_escaping_bound_vars());
|
assert!(!instance.substs.has_escaping_bound_vars());
|
||||||
|
|
||||||
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
|
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
|
||||||
|
|
|
@ -515,7 +515,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'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 {
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> {
|
||||||
visibility: Visibility,
|
visibility: Visibility,
|
||||||
symbol_name: &str,
|
symbol_name: &str,
|
||||||
) {
|
) {
|
||||||
assert!(!instance.substs.needs_infer());
|
assert!(!instance.substs.has_infer());
|
||||||
|
|
||||||
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
|
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
|
||||||
let lldecl = self.declare_fn(symbol_name, fn_abi);
|
let lldecl = self.declare_fn(symbol_name, fn_abi);
|
||||||
|
|
|
@ -152,7 +152,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
cx: &'a Bx::CodegenCx,
|
cx: &'a Bx::CodegenCx,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) {
|
) {
|
||||||
assert!(!instance.substs.needs_infer());
|
assert!(!instance.substs.has_infer());
|
||||||
|
|
||||||
let llfn = cx.get_fn(instance);
|
let llfn = cx.get_fn(instance);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ where
|
||||||
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 @@ where
|
||||||
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 @@ where
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2318,7 +2318,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let infcx = match self.infcx() {
|
let infcx = match self.infcx() {
|
||||||
Some(infcx) => infcx,
|
Some(infcx) => infcx,
|
||||||
None => {
|
None => {
|
||||||
assert!(!self_ty.needs_infer());
|
assert!(!self_ty.has_infer());
|
||||||
infcx_ = tcx.infer_ctxt().ignoring_regions().build();
|
infcx_ = tcx.infer_ctxt().ignoring_regions().build();
|
||||||
&infcx_
|
&infcx_
|
||||||
}
|
}
|
||||||
|
@ -2489,7 +2489,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let infcx = if let Some(infcx) = self.infcx() {
|
let infcx = if let Some(infcx) = self.infcx() {
|
||||||
infcx
|
infcx
|
||||||
} else {
|
} else {
|
||||||
assert!(!qself_ty.needs_infer());
|
assert!(!qself_ty.has_infer());
|
||||||
infcx_ = tcx.infer_ctxt().build();
|
infcx_ = tcx.infer_ctxt().build();
|
||||||
&infcx_
|
&infcx_
|
||||||
};
|
};
|
||||||
|
@ -3039,7 +3039,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
// 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",
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b
|
||||||
packed && {
|
packed && {
|
||||||
let ty = tcx.type_of(variant.fields.raw.last().unwrap().did).subst_identity();
|
let ty = tcx.type_of(variant.fields.raw.last().unwrap().did).subst_identity();
|
||||||
let ty = tcx.erase_regions(ty);
|
let ty = tcx.erase_regions(ty);
|
||||||
if ty.needs_infer() {
|
if ty.has_infer() {
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.delay_span_bug(item.span, &format!("inference variables in {:?}", ty));
|
.delay_span_bug(item.span, &format!("inference variables in {:?}", ty));
|
||||||
// Just treat unresolved type expression as if it needs drop.
|
// Just treat unresolved type expression as if it needs drop.
|
||||||
|
@ -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![
|
||||||
|
|
|
@ -366,7 +366,7 @@ fn check_predicates<'tcx>(
|
||||||
wf::obligations(infcx, tcx.param_env(impl1_def_id), impl1_def_id, 0, arg, span)
|
wf::obligations(infcx, tcx.param_env(impl1_def_id), impl1_def_id, 0, arg, span)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(!obligations.needs_infer());
|
assert!(!obligations.has_infer());
|
||||||
impl2_predicates
|
impl2_predicates
|
||||||
.extend(traits::elaborate(tcx, obligations).map(|obligation| obligation.predicate))
|
.extend(traits::elaborate(tcx, obligations).map(|obligation| obligation.predicate))
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ocx.normalize(&ObligationCause::dummy(), self.param_env, fn_sig);
|
ocx.normalize(&ObligationCause::dummy(), self.param_env, fn_sig);
|
||||||
if ocx.select_all_or_error().is_empty() {
|
if ocx.select_all_or_error().is_empty() {
|
||||||
let normalized_fn_sig = self.resolve_vars_if_possible(normalized_fn_sig);
|
let normalized_fn_sig = self.resolve_vars_if_possible(normalized_fn_sig);
|
||||||
if !normalized_fn_sig.needs_infer() {
|
if !normalized_fn_sig.has_infer() {
|
||||||
return normalized_fn_sig;
|
return normalized_fn_sig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1384,7 +1384,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
|
||||||
// If the type being assigned needs dropped, then the mutation counts as a borrow
|
// If the type being assigned needs dropped, then the mutation counts as a borrow
|
||||||
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
|
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
|
||||||
let ty = self.tcx.erase_regions(assignee_place.place.base_ty);
|
let ty = self.tcx.erase_regions(assignee_place.place.base_ty);
|
||||||
if ty.needs_infer() {
|
if ty.has_infer() {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.delay_span_bug(
|
||||||
self.tcx.hir().span(assignee_place.hir_id),
|
self.tcx.hir().span(assignee_place.hir_id),
|
||||||
&format!("inference variables in {ty}"),
|
&format!("inference variables in {ty}"),
|
||||||
|
|
|
@ -460,7 +460,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
||||||
// Avoid ICEs in needs_drop.
|
// Avoid ICEs in needs_drop.
|
||||||
let ty = self.fcx.resolve_vars_if_possible(ty);
|
let ty = self.fcx.resolve_vars_if_possible(ty);
|
||||||
let ty = self.fcx.tcx.erase_regions(ty);
|
let ty = self.fcx.tcx.erase_regions(ty);
|
||||||
if ty.needs_infer() {
|
if ty.has_infer() {
|
||||||
self.fcx
|
self.fcx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
|
|
|
@ -2032,7 +2032,7 @@ impl<'tcx> Candidate<'tcx> {
|
||||||
// means they are safe to put into the
|
// means they are safe to put into the
|
||||||
// `WhereClausePick`.
|
// `WhereClausePick`.
|
||||||
assert!(
|
assert!(
|
||||||
!trait_ref.skip_binder().substs.needs_infer()
|
!trait_ref.skip_binder().substs.has_infer()
|
||||||
&& !trait_ref.skip_binder().substs.has_placeholders()
|
&& !trait_ref.skip_binder().substs.has_placeholders()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
|
|
||||||
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
||||||
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
|
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
|
||||||
assert!(!ty.needs_infer() && !ty.has_placeholders() && !ty.has_free_regions());
|
assert!(!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions());
|
||||||
self.typeck_results.node_types_mut().insert(hir_id, ty);
|
self.typeck_results.node_types_mut().insert(hir_id, ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
|
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
|
||||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||||
|
|
||||||
if cfg!(debug_assertions) && c_ty.needs_infer() {
|
if cfg!(debug_assertions) && c_ty.has_infer() {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
hir_id.to_span(self.fcx.tcx),
|
hir_id.to_span(self.fcx.tcx),
|
||||||
"writeback: `{:?}` has inference variables",
|
"writeback: `{:?}` has inference variables",
|
||||||
|
@ -527,7 +527,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
|
|
||||||
self.typeck_results.user_provided_sigs.extend(
|
self.typeck_results.user_provided_sigs.extend(
|
||||||
fcx_typeck_results.user_provided_sigs.items().map(|(&def_id, c_sig)| {
|
fcx_typeck_results.user_provided_sigs.items().map(|(&def_id, c_sig)| {
|
||||||
if cfg!(debug_assertions) && c_sig.needs_infer() {
|
if cfg!(debug_assertions) && c_sig.has_infer() {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
self.fcx.tcx.def_span(def_id),
|
self.fcx.tcx.def_span(def_id),
|
||||||
"writeback: `{:?}` has inference variables",
|
"writeback: `{:?}` has inference variables",
|
||||||
|
@ -618,7 +618,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
if let Some(substs) = self.fcx.typeck_results.borrow().node_substs_opt(hir_id) {
|
if let Some(substs) = self.fcx.typeck_results.borrow().node_substs_opt(hir_id) {
|
||||||
let substs = self.resolve(substs, &span);
|
let substs = self.resolve(substs, &span);
|
||||||
debug!("write_substs_to_tcx({:?}, {:?})", hir_id, substs);
|
debug!("write_substs_to_tcx({:?}, {:?})", hir_id, substs);
|
||||||
assert!(!substs.needs_infer() && !substs.has_placeholders());
|
assert!(!substs.has_infer() && !substs.has_placeholders());
|
||||||
self.typeck_results.node_substs_mut().insert(hir_id, substs);
|
self.typeck_results.node_substs_mut().insert(hir_id, substs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -693,7 +693,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
{
|
{
|
||||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||||
|
|
||||||
if cfg!(debug_assertions) && container.needs_infer() {
|
if cfg!(debug_assertions) && container.has_infer() {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
hir_id.to_span(self.fcx.tcx),
|
hir_id.to_span(self.fcx.tcx),
|
||||||
"writeback: `{:?}` has inference variables",
|
"writeback: `{:?}` has inference variables",
|
||||||
|
@ -711,7 +711,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
{
|
{
|
||||||
let mut resolver = Resolver::new(self.fcx, span, self.body);
|
let mut resolver = Resolver::new(self.fcx, span, self.body);
|
||||||
let x = x.fold_with(&mut resolver);
|
let x = x.fold_with(&mut resolver);
|
||||||
if cfg!(debug_assertions) && x.needs_infer() {
|
if cfg!(debug_assertions) && x.has_infer() {
|
||||||
span_bug!(span.to_span(self.fcx.tcx), "writeback: `{:?}` has inference variables", x);
|
span_bug!(span.to_span(self.fcx.tcx), "writeback: `{:?}` has inference variables", x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -564,12 +564,12 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
||||||
let _inside_canonical_ctxt_guard = infcx.set_canonicalization_ctxt();
|
let _inside_canonical_ctxt_guard = infcx.set_canonicalization_ctxt();
|
||||||
|
|
||||||
let needs_canonical_flags = if canonicalize_region_mode.any() {
|
let needs_canonical_flags = if canonicalize_region_mode.any() {
|
||||||
TypeFlags::NEEDS_INFER |
|
TypeFlags::HAS_INFER |
|
||||||
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
|
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
|
||||||
TypeFlags::HAS_TY_PLACEHOLDER |
|
TypeFlags::HAS_TY_PLACEHOLDER |
|
||||||
TypeFlags::HAS_CT_PLACEHOLDER
|
TypeFlags::HAS_CT_PLACEHOLDER
|
||||||
} else {
|
} else {
|
||||||
TypeFlags::NEEDS_INFER
|
TypeFlags::HAS_INFER
|
||||||
| TypeFlags::HAS_RE_PLACEHOLDER
|
| TypeFlags::HAS_RE_PLACEHOLDER
|
||||||
| TypeFlags::HAS_TY_PLACEHOLDER
|
| TypeFlags::HAS_TY_PLACEHOLDER
|
||||||
| TypeFlags::HAS_CT_PLACEHOLDER
|
| TypeFlags::HAS_CT_PLACEHOLDER
|
||||||
|
@ -600,7 +600,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
||||||
// Once we have canonicalized `out_value`, it should not
|
// Once we have canonicalized `out_value`, it should not
|
||||||
// contain anything that ties it to this inference context
|
// contain anything that ties it to this inference context
|
||||||
// anymore.
|
// anymore.
|
||||||
debug_assert!(!out_value.needs_infer() && !out_value.has_placeholders());
|
debug_assert!(!out_value.has_infer() && !out_value.has_placeholders());
|
||||||
|
|
||||||
let canonical_variables =
|
let canonical_variables =
|
||||||
tcx.mk_canonical_var_infos(&canonicalizer.universe_canonicalized_variables());
|
tcx.mk_canonical_var_infos(&canonicalizer.universe_canonicalized_variables());
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if !t.needs_infer() && !t.has_erasable_regions() {
|
if !t.has_infer() && !t.has_erasable_regions() {
|
||||||
t
|
t
|
||||||
} else {
|
} else {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
|
|
|
@ -1327,7 +1327,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
if !value.needs_infer() {
|
if !value.has_infer() {
|
||||||
return value; // Avoid duplicated subst-folding.
|
return value; // Avoid duplicated subst-folding.
|
||||||
}
|
}
|
||||||
let mut r = InferenceLiteralEraser { tcx: self.tcx };
|
let mut r = InferenceLiteralEraser { tcx: self.tcx };
|
||||||
|
@ -1365,7 +1365,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
pub fn fully_resolve<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> FixupResult<'tcx, T> {
|
pub fn fully_resolve<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> FixupResult<'tcx, T> {
|
||||||
let value = resolve::fully_resolve(self, value);
|
let value = resolve::fully_resolve(self, value);
|
||||||
assert!(
|
assert!(
|
||||||
value.as_ref().map_or(true, |value| !value.needs_infer()),
|
value.as_ref().map_or(true, |value| !value.has_infer()),
|
||||||
"`{value:?}` is not fully resolved"
|
"`{value:?}` is not fully resolved"
|
||||||
);
|
);
|
||||||
value
|
value
|
||||||
|
|
|
@ -347,7 +347,7 @@ where
|
||||||
let is_opaque = alias_ty.kind(self.tcx) == ty::Opaque;
|
let is_opaque = alias_ty.kind(self.tcx) == ty::Opaque;
|
||||||
if approx_env_bounds.is_empty()
|
if approx_env_bounds.is_empty()
|
||||||
&& trait_bounds.is_empty()
|
&& trait_bounds.is_empty()
|
||||||
&& (alias_ty.needs_infer() || is_opaque)
|
&& (alias_ty.has_infer() || is_opaque)
|
||||||
{
|
{
|
||||||
debug!("no declared bounds");
|
debug!("no declared bounds");
|
||||||
let opt_variances = is_opaque.then(|| self.tcx.variances_of(alias_ty.def_id));
|
let opt_variances = is_opaque.then(|| self.tcx.variances_of(alias_ty.def_id));
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
||||||
if !t.needs_infer() {
|
if !t.has_infer() {
|
||||||
Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects...
|
Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects...
|
||||||
} else {
|
} else {
|
||||||
let t = self.infcx.shallow_resolve(t);
|
let t = self.infcx.shallow_resolve(t);
|
||||||
|
@ -243,7 +243,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
||||||
if !c.needs_infer() {
|
if !c.has_infer() {
|
||||||
Ok(c) // micro-optimize -- if there is nothing in this const that this fold affects...
|
Ok(c) // micro-optimize -- if there is nothing in this const that this fold affects...
|
||||||
} else {
|
} else {
|
||||||
let c = self.infcx.shallow_resolve(c);
|
let c = self.infcx.shallow_resolve(c);
|
||||||
|
|
|
@ -42,7 +42,7 @@ declare_lint_pass!(EnumIntrinsicsNonEnums => [ENUM_INTRINSICS_NON_ENUMS]);
|
||||||
/// 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(
|
||||||
|
|
|
@ -215,7 +215,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||||
) -> Fingerprint {
|
) -> Fingerprint {
|
||||||
// It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
|
// It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
|
||||||
// Without incremental, we rarely stable-hash types, so let's not do it proactively.
|
// Without incremental, we rarely stable-hash types, so let's not do it proactively.
|
||||||
if flags.flags.intersects(TypeFlags::NEEDS_INFER) || sess.opts.incremental.is_none() {
|
if flags.flags.intersects(TypeFlags::HAS_INFER) || sess.opts.incremental.is_none() {
|
||||||
Fingerprint::ZERO
|
Fingerprint::ZERO
|
||||||
} else {
|
} else {
|
||||||
let mut hasher = StableHasher::new();
|
let mut hasher = StableHasher::new();
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if ty.needs_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
|
if ty.has_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T>
|
fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T>
|
||||||
|
|
|
@ -761,7 +761,7 @@ impl<'tcx, T: TypeFoldable<TyCtxt<'tcx>>> ty::EarlyBinder<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 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for SubstFolder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1151,7 +1151,7 @@ impl<'tcx> Ty<'tcx> {
|
||||||
// context, or *something* like that, but for now just avoid passing inference
|
// context, or *something* like that, but for now just avoid passing inference
|
||||||
// variables to queries that can't cope with them. Instead, conservatively
|
// variables to queries that can't cope with them. Instead, conservatively
|
||||||
// return "true" (may change drop order).
|
// return "true" (may change drop order).
|
||||||
if query_ty.needs_infer() {
|
if query_ty.has_infer() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
||||||
|
@ -79,10 +79,10 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
|
||||||
self.has_type_flags(TypeFlags::HAS_TY_INFER)
|
self.has_type_flags(TypeFlags::HAS_TY_INFER)
|
||||||
}
|
}
|
||||||
fn has_non_region_infer(&self) -> bool {
|
fn has_non_region_infer(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::NEEDS_INFER - TypeFlags::HAS_RE_INFER)
|
self.has_type_flags(TypeFlags::HAS_INFER - TypeFlags::HAS_RE_INFER)
|
||||||
}
|
}
|
||||||
fn needs_infer(&self) -> bool {
|
fn has_infer(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::NEEDS_INFER)
|
self.has_type_flags(TypeFlags::HAS_INFER)
|
||||||
}
|
}
|
||||||
fn has_placeholders(&self) -> bool {
|
fn has_placeholders(&self) -> bool {
|
||||||
self.has_type_flags(
|
self.has_type_flags(
|
||||||
|
@ -94,8 +94,8 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
|
||||||
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.
|
||||||
|
|
|
@ -391,7 +391,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
/// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
/// 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 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 @@ pub(crate) fn mir_callgraph_reachable<'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| {
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
|
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
let ty = self.resolve_vars_if_possible(ty);
|
let ty = self.resolve_vars_if_possible(ty);
|
||||||
|
|
||||||
if !(param_env, ty).needs_infer() {
|
if !(param_env, ty).has_infer() {
|
||||||
return ty.is_copy_modulo_regions(self.tcx, param_env);
|
return ty.is_copy_modulo_regions(self.tcx, param_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl<'a, 'tcx> Canonicalizer<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let value = value.fold_with(&mut canonicalizer);
|
let value = value.fold_with(&mut canonicalizer);
|
||||||
assert!(!value.needs_infer());
|
assert!(!value.has_infer());
|
||||||
assert!(!value.has_placeholders());
|
assert!(!value.has_placeholders());
|
||||||
|
|
||||||
let (max_universe, variables) = canonicalizer.finalize();
|
let (max_universe, variables) = canonicalizer.finalize();
|
||||||
|
|
|
@ -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.needs_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);
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
|
||||||
// We may however encounter unconstrained lifetime variables in invalid
|
// We may however encounter unconstrained lifetime variables in invalid
|
||||||
// code. See #110161 for context.
|
// code. See #110161 for context.
|
||||||
assert!(!ty.has_non_region_infer());
|
assert!(!ty.has_non_region_infer());
|
||||||
if ty.needs_infer() {
|
if ty.has_infer() {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.delay_span_bug(
|
||||||
self.tcx.def_span(body_id),
|
self.tcx.def_span(body_id),
|
||||||
"skipped implied_outlives_bounds due to unconstrained lifetimes",
|
"skipped implied_outlives_bounds due to unconstrained lifetimes",
|
||||||
|
|
|
@ -449,7 +449,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
|
|
||||||
debug!(?stack, ?candidates, "winnowed to {} candidates", candidates.len());
|
debug!(?stack, ?candidates, "winnowed to {} candidates", candidates.len());
|
||||||
|
|
||||||
let needs_infer = stack.obligation.predicate.has_non_region_infer();
|
let has_non_region_infer = stack.obligation.predicate.has_non_region_infer();
|
||||||
|
|
||||||
// If there are STILL multiple candidates, we can further
|
// If there are STILL multiple candidates, we can further
|
||||||
// reduce the list by dropping duplicates -- including
|
// reduce the list by dropping duplicates -- including
|
||||||
|
@ -461,7 +461,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
self.candidate_should_be_dropped_in_favor_of(
|
self.candidate_should_be_dropped_in_favor_of(
|
||||||
&candidates[i],
|
&candidates[i],
|
||||||
&candidates[j],
|
&candidates[j],
|
||||||
needs_infer,
|
has_non_region_infer,
|
||||||
) == DropVictim::Yes
|
) == DropVictim::Yes
|
||||||
});
|
});
|
||||||
if should_drop_i {
|
if should_drop_i {
|
||||||
|
@ -1000,7 +1000,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
) -> 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
|
||||||
|
@ -1330,7 +1330,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.can_use_global_caches(param_env) {
|
if self.can_use_global_caches(param_env) {
|
||||||
if !trait_pred.needs_infer() {
|
if !trait_pred.has_infer() {
|
||||||
debug!(?trait_pred, ?result, "insert_evaluation_cache global");
|
debug!(?trait_pred, ?result, "insert_evaluation_cache global");
|
||||||
// This may overwrite the cache with the same value
|
// This may overwrite the cache with the same value
|
||||||
// FIXME: Due to #50507 this overwrites the different values
|
// FIXME: Due to #50507 this overwrites the different values
|
||||||
|
@ -1516,7 +1516,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
// If there are any inference variables in the `ParamEnv`, then we
|
// If there are any inference variables in the `ParamEnv`, then we
|
||||||
// always use a cache local to this particular scope. Otherwise, we
|
// always use a cache local to this particular scope. Otherwise, we
|
||||||
// switch to a global cache.
|
// switch to a global cache.
|
||||||
if param_env.needs_infer() {
|
if param_env.has_infer() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1587,7 +1587,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
match result {
|
match result {
|
||||||
Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.needs_infer(),
|
Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_infer(),
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1613,8 +1613,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
if self.can_use_global_caches(param_env) {
|
if self.can_use_global_caches(param_env) {
|
||||||
if let Err(Overflow(OverflowError::Canonical)) = candidate {
|
if let Err(Overflow(OverflowError::Canonical)) = candidate {
|
||||||
// Don't cache overflow globally; we only produce this in certain modes.
|
// Don't cache overflow globally; we only produce this in certain modes.
|
||||||
} else if !pred.needs_infer() {
|
} else if !pred.has_infer() {
|
||||||
if !candidate.needs_infer() {
|
if !candidate.has_infer() {
|
||||||
debug!(?pred, ?candidate, "insert_candidate_cache global");
|
debug!(?pred, ?candidate, "insert_candidate_cache global");
|
||||||
// This may overwrite the cache with the same value.
|
// This may overwrite the cache with the same value.
|
||||||
tcx.selection_cache.insert((param_env, pred), dep_node, candidate);
|
tcx.selection_cache.insert((param_env, pred), dep_node, candidate);
|
||||||
|
@ -1724,7 +1724,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
.map(|InferOk { obligations: _, value: () }| {
|
.map(|InferOk { obligations: _, value: () }| {
|
||||||
// This method is called within a probe, so we can't have
|
// This method is called within a probe, so we can't have
|
||||||
// inference variables and placeholders escape.
|
// inference variables and placeholders escape.
|
||||||
if !trait_bound.needs_infer() && !trait_bound.has_placeholders() {
|
if !trait_bound.has_infer() && !trait_bound.has_placeholders() {
|
||||||
Some(trait_bound)
|
Some(trait_bound)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -1840,7 +1840,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
victim: &EvaluatedCandidate<'tcx>,
|
victim: &EvaluatedCandidate<'tcx>,
|
||||||
other: &EvaluatedCandidate<'tcx>,
|
other: &EvaluatedCandidate<'tcx>,
|
||||||
needs_infer: bool,
|
has_non_region_infer: bool,
|
||||||
) -> DropVictim {
|
) -> DropVictim {
|
||||||
if victim.candidate == other.candidate {
|
if victim.candidate == other.candidate {
|
||||||
return DropVictim::Yes;
|
return DropVictim::Yes;
|
||||||
|
@ -1956,7 +1956,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||||
| (ObjectCandidate(i), ObjectCandidate(j)) => {
|
| (ObjectCandidate(i), ObjectCandidate(j)) => {
|
||||||
// Arbitrarily pick the lower numbered candidate for backwards
|
// Arbitrarily pick the lower numbered candidate for backwards
|
||||||
// compatibility reasons. Don't let this affect inference.
|
// compatibility reasons. Don't let this affect inference.
|
||||||
DropVictim::drop_if(i < j && !needs_infer)
|
DropVictim::drop_if(i < j && !has_non_region_infer)
|
||||||
}
|
}
|
||||||
(ObjectCandidate(_), ProjectionCandidate(..))
|
(ObjectCandidate(_), ProjectionCandidate(..))
|
||||||
| (ProjectionCandidate(..), ObjectCandidate(_)) => {
|
| (ProjectionCandidate(..), ObjectCandidate(_)) => {
|
||||||
|
@ -2062,7 +2062,8 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||||
// existence of multiple marker trait impls tells us nothing
|
// existence of multiple marker trait impls tells us nothing
|
||||||
// about which one should actually apply.
|
// about which one should actually apply.
|
||||||
DropVictim::drop_if(
|
DropVictim::drop_if(
|
||||||
!needs_infer && other.evaluation.must_apply_considering_regions(),
|
!has_non_region_infer
|
||||||
|
&& other.evaluation.must_apply_considering_regions(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
None => DropVictim::No,
|
None => DropVictim::No,
|
||||||
|
|
|
@ -353,8 +353,8 @@ pub(crate) fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
|
||||||
),
|
),
|
||||||
) -> Option<usize> {
|
) -> Option<usize> {
|
||||||
let (source, target) = key;
|
let (source, target) = key;
|
||||||
assert!(matches!(&source.kind(), &ty::Dynamic(..)) && !source.needs_infer());
|
assert!(matches!(&source.kind(), &ty::Dynamic(..)) && !source.has_infer());
|
||||||
assert!(matches!(&target.kind(), &ty::Dynamic(..)) && !target.needs_infer());
|
assert!(matches!(&target.kind(), &ty::Dynamic(..)) && !target.has_infer());
|
||||||
|
|
||||||
// this has been typecked-before, so diagnostics is not really needed.
|
// this has been typecked-before, so diagnostics is not really needed.
|
||||||
let unsize_trait_did = tcx.require_lang_item(LangItem::Unsize, None);
|
let unsize_trait_did = tcx.require_lang_item(LangItem::Unsize, None);
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<TyCtxt<'tcx>> + Par
|
||||||
// us a test case.
|
// us a test case.
|
||||||
debug_assert_eq!(normalized_value, resolved_value);
|
debug_assert_eq!(normalized_value, resolved_value);
|
||||||
let erased = infcx.tcx.erase_regions(resolved_value);
|
let erased = infcx.tcx.erase_regions(resolved_value);
|
||||||
debug_assert!(!erased.needs_infer(), "{erased:?}");
|
debug_assert!(!erased.has_infer(), "{erased:?}");
|
||||||
Ok(erased)
|
Ok(erased)
|
||||||
}
|
}
|
||||||
Err(NoSolution) => Err(NoSolution),
|
Err(NoSolution) => Err(NoSolution),
|
||||||
|
|
|
@ -104,8 +104,8 @@ fn resolve_associated_item<'tcx>(
|
||||||
"resolving ImplSource::UserDefined: {:?}, {:?}, {:?}, {:?}",
|
"resolving ImplSource::UserDefined: {:?}, {:?}, {:?}, {:?}",
|
||||||
param_env, trait_item_id, rcvr_substs, impl_data
|
param_env, trait_item_id, rcvr_substs, impl_data
|
||||||
);
|
);
|
||||||
assert!(!rcvr_substs.needs_infer());
|
assert!(!rcvr_substs.has_infer());
|
||||||
assert!(!trait_ref.needs_infer());
|
assert!(!trait_ref.has_infer());
|
||||||
|
|
||||||
let trait_def_id = tcx.trait_id_of_impl(impl_data.impl_def_id).unwrap();
|
let trait_def_id = tcx.trait_id_of_impl(impl_data.impl_def_id).unwrap();
|
||||||
let trait_def = tcx.trait_def(trait_def_id);
|
let trait_def = tcx.trait_def(trait_def_id);
|
||||||
|
|
|
@ -179,7 +179,7 @@ bitflags! {
|
||||||
/// 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;
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ bitflags! {
|
||||||
|
|
||||||
/// Does this have inference variables? Used to determine whether
|
/// Does this have inference variables? Used to determine whether
|
||||||
/// inference is required.
|
/// inference is required.
|
||||||
const NEEDS_INFER = TypeFlags::HAS_TY_INFER.bits
|
const HAS_INFER = TypeFlags::HAS_TY_INFER.bits
|
||||||
| TypeFlags::HAS_RE_INFER.bits
|
| TypeFlags::HAS_RE_INFER.bits
|
||||||
| TypeFlags::HAS_CT_INFER.bits;
|
| TypeFlags::HAS_CT_INFER.bits;
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ pub fn implements_trait_with_env<'tcx>(
|
||||||
ty_params: impl IntoIterator<Item = Option<GenericArg<'tcx>>>,
|
ty_params: impl IntoIterator<Item = Option<GenericArg<'tcx>>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// Clippy shouldn't have infer types
|
// Clippy shouldn't have infer types
|
||||||
assert!(!ty.needs_infer());
|
assert!(!ty.has_infer());
|
||||||
|
|
||||||
let ty = tcx.erase_regions(ty);
|
let ty = tcx.erase_regions(ty);
|
||||||
if ty.has_escaping_bound_vars() {
|
if ty.has_escaping_bound_vars() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue