Skip to content

Commit f04b8fe

Browse files
committed
rename needs_infer to has_infer
1 parent e3ccd4b commit f04b8fe

File tree

34 files changed

+59
-58
lines changed

34 files changed

+59
-58
lines changed

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub(crate) fn get_function_sig<'tcx>(
7070
default_call_conv: CallConv,
7171
inst: Instance<'tcx>,
7272
) -> Signature {
73-
assert!(!inst.substs.needs_infer());
73+
assert!(!inst.substs.has_infer());
7474
clif_sig_from_fn_abi(
7575
tcx,
7676
default_call_conv,

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn codegen_fn<'tcx>(
2828
module: &mut dyn Module,
2929
instance: Instance<'tcx>,
3030
) -> CodegenedFunction {
31-
debug_assert!(!instance.substs.needs_infer());
31+
debug_assert!(!instance.substs.has_infer());
3232

3333
let symbol_name = tcx.symbol_name(instance).name.to_string();
3434
let _timer = tcx.prof.generic_activity_with_arg("codegen fn", &*symbol_name);

compiler/rustc_codegen_gcc/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::context::CodegenCx;
1717
pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>) -> Function<'gcc> {
1818
let tcx = cx.tcx();
1919

20-
assert!(!instance.substs.needs_infer());
20+
assert!(!instance.substs.has_infer());
2121
assert!(!instance.substs.has_escaping_bound_vars());
2222

2323
let sym = tcx.symbol_name(instance).name;

compiler/rustc_codegen_gcc/src/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'gcc, 'tcx> PreDefineMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
3131

3232
#[cfg_attr(not(feature="master"), allow(unused_variables))]
3333
fn predefine_fn(&self, instance: Instance<'tcx>, linkage: Linkage, visibility: Visibility, symbol_name: &str) {
34-
assert!(!instance.substs.needs_infer());
34+
assert!(!instance.substs.has_infer());
3535

3636
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
3737
self.linkage.set(base::linkage_to_gcc(linkage));

compiler/rustc_codegen_llvm/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) ->
2727

2828
debug!("get_fn(instance={:?})", instance);
2929

30-
assert!(!instance.substs.needs_infer());
30+
assert!(!instance.substs.has_infer());
3131
assert!(!instance.substs.has_escaping_bound_vars());
3232

3333
if let Some(&llfn) = cx.instances.borrow().get(&instance) {

compiler/rustc_codegen_llvm/src/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> {
4848
visibility: Visibility,
4949
symbol_name: &str,
5050
) {
51-
assert!(!instance.substs.needs_infer());
51+
assert!(!instance.substs.has_infer());
5252

5353
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
5454
let lldecl = self.declare_fn(symbol_name, fn_abi);

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
152152
cx: &'a Bx::CodegenCx,
153153
instance: Instance<'tcx>,
154154
) {
155-
assert!(!instance.substs.needs_infer());
155+
assert!(!instance.substs.has_infer());
156156

157157
let llfn = cx.get_fn(instance);
158158

compiler/rustc_hir_analysis/src/astconv/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23182318
let infcx = match self.infcx() {
23192319
Some(infcx) => infcx,
23202320
None => {
2321-
assert!(!self_ty.needs_infer());
2321+
assert!(!self_ty.has_infer());
23222322
infcx_ = tcx.infer_ctxt().ignoring_regions().build();
23232323
&infcx_
23242324
}
@@ -2489,7 +2489,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24892489
let infcx = if let Some(infcx) = self.infcx() {
24902490
infcx
24912491
} else {
2492-
assert!(!qself_ty.needs_infer());
2492+
assert!(!qself_ty.has_infer());
24932493
infcx_ = tcx.infer_ctxt().build();
24942494
&infcx_
24952495
};

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b
10271027
packed && {
10281028
let ty = tcx.type_of(variant.fields.raw.last().unwrap().did).subst_identity();
10291029
let ty = tcx.erase_regions(ty);
1030-
if ty.needs_infer() {
1030+
if ty.has_infer() {
10311031
tcx.sess
10321032
.delay_span_bug(item.span, &format!("inference variables in {:?}", ty));
10331033
// Just treat unresolved type expression as if it needs drop.

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ fn check_predicates<'tcx>(
366366
wf::obligations(infcx, tcx.param_env(impl1_def_id), impl1_def_id, 0, arg, span)
367367
.unwrap();
368368

369-
assert!(!obligations.needs_infer());
369+
assert!(!obligations.has_infer());
370370
impl2_predicates
371371
.extend(traits::elaborate(tcx, obligations).map(|obligation| obligation.predicate))
372372
}

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
168168
ocx.normalize(&ObligationCause::dummy(), self.param_env, fn_sig);
169169
if ocx.select_all_or_error().is_empty() {
170170
let normalized_fn_sig = self.resolve_vars_if_possible(normalized_fn_sig);
171-
if !normalized_fn_sig.needs_infer() {
171+
if !normalized_fn_sig.has_infer() {
172172
return normalized_fn_sig;
173173
}
174174
}

compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
202202
// If the type being assigned needs dropped, then the mutation counts as a borrow
203203
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
204204
let ty = self.tcx.erase_regions(assignee_place.place.base_ty);
205-
if ty.needs_infer() {
205+
if ty.has_infer() {
206206
self.tcx.sess.delay_span_bug(
207207
self.tcx.hir().span(assignee_place.hir_id),
208208
&format!("inference variables in {ty}"),

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
460460
// Avoid ICEs in needs_drop.
461461
let ty = self.fcx.resolve_vars_if_possible(ty);
462462
let ty = self.fcx.tcx.erase_regions(ty);
463-
if ty.needs_infer() {
463+
if ty.has_infer() {
464464
self.fcx
465465
.tcx
466466
.sess

compiler/rustc_hir_typeck/src/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ impl<'tcx> Candidate<'tcx> {
20322032
// means they are safe to put into the
20332033
// `WhereClausePick`.
20342034
assert!(
2035-
!trait_ref.skip_binder().substs.needs_infer()
2035+
!trait_ref.skip_binder().substs.has_infer()
20362036
&& !trait_ref.skip_binder().substs.has_placeholders()
20372037
);
20382038

compiler/rustc_hir_typeck/src/writeback.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
133133

134134
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
135135
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
136-
assert!(!ty.needs_infer() && !ty.has_placeholders() && !ty.has_free_regions());
136+
assert!(!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions());
137137
self.typeck_results.node_types_mut().insert(hir_id, ty);
138138
}
139139

@@ -508,7 +508,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
508508
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
509509
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
510510

511-
if cfg!(debug_assertions) && c_ty.needs_infer() {
511+
if cfg!(debug_assertions) && c_ty.has_infer() {
512512
span_bug!(
513513
hir_id.to_span(self.fcx.tcx),
514514
"writeback: `{:?}` has inference variables",
@@ -527,7 +527,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
527527

528528
self.typeck_results.user_provided_sigs.extend(
529529
fcx_typeck_results.user_provided_sigs.items().map(|(&def_id, c_sig)| {
530-
if cfg!(debug_assertions) && c_sig.needs_infer() {
530+
if cfg!(debug_assertions) && c_sig.has_infer() {
531531
span_bug!(
532532
self.fcx.tcx.def_span(def_id),
533533
"writeback: `{:?}` has inference variables",
@@ -618,7 +618,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
618618
if let Some(substs) = self.fcx.typeck_results.borrow().node_substs_opt(hir_id) {
619619
let substs = self.resolve(substs, &span);
620620
debug!("write_substs_to_tcx({:?}, {:?})", hir_id, substs);
621-
assert!(!substs.needs_infer() && !substs.has_placeholders());
621+
assert!(!substs.has_infer() && !substs.has_placeholders());
622622
self.typeck_results.node_substs_mut().insert(hir_id, substs);
623623
}
624624
}
@@ -693,7 +693,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
693693
{
694694
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
695695

696-
if cfg!(debug_assertions) && container.needs_infer() {
696+
if cfg!(debug_assertions) && container.has_infer() {
697697
span_bug!(
698698
hir_id.to_span(self.fcx.tcx),
699699
"writeback: `{:?}` has inference variables",
@@ -711,7 +711,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
711711
{
712712
let mut resolver = Resolver::new(self.fcx, span, self.body);
713713
let x = x.fold_with(&mut resolver);
714-
if cfg!(debug_assertions) && x.needs_infer() {
714+
if cfg!(debug_assertions) && x.has_infer() {
715715
span_bug!(span.to_span(self.fcx.tcx), "writeback: `{:?}` has inference variables", x);
716716
}
717717

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,12 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
564564
let _inside_canonical_ctxt_guard = infcx.set_canonicalization_ctxt();
565565

566566
let needs_canonical_flags = if canonicalize_region_mode.any() {
567-
TypeFlags::NEEDS_INFER |
567+
TypeFlags::HAS_INFER |
568568
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
569569
TypeFlags::HAS_TY_PLACEHOLDER |
570570
TypeFlags::HAS_CT_PLACEHOLDER
571571
} else {
572-
TypeFlags::NEEDS_INFER
572+
TypeFlags::HAS_INFER
573573
| TypeFlags::HAS_RE_PLACEHOLDER
574574
| TypeFlags::HAS_TY_PLACEHOLDER
575575
| TypeFlags::HAS_CT_PLACEHOLDER
@@ -600,7 +600,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
600600
// Once we have canonicalized `out_value`, it should not
601601
// contain anything that ties it to this inference context
602602
// anymore.
603-
debug_assert!(!out_value.needs_infer() && !out_value.has_placeholders());
603+
debug_assert!(!out_value.has_infer() && !out_value.has_placeholders());
604604

605605
let canonical_variables =
606606
tcx.mk_canonical_var_infos(&canonicalizer.universe_canonicalized_variables());

compiler/rustc_infer/src/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
127127

128128
#[inline]
129129
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
130-
if !t.needs_infer() && !t.has_erasable_regions() {
130+
if !t.has_infer() && !t.has_erasable_regions() {
131131
t
132132
} else {
133133
match *t.kind() {

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ impl<'tcx> InferCtxt<'tcx> {
13271327
where
13281328
T: TypeFoldable<TyCtxt<'tcx>>,
13291329
{
1330-
if !value.needs_infer() {
1330+
if !value.has_infer() {
13311331
return value; // Avoid duplicated subst-folding.
13321332
}
13331333
let mut r = InferenceLiteralEraser { tcx: self.tcx };
@@ -1365,7 +1365,7 @@ impl<'tcx> InferCtxt<'tcx> {
13651365
pub fn fully_resolve<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> FixupResult<'tcx, T> {
13661366
let value = resolve::fully_resolve(self, value);
13671367
assert!(
1368-
value.as_ref().map_or(true, |value| !value.needs_infer()),
1368+
value.as_ref().map_or(true, |value| !value.has_infer()),
13691369
"`{value:?}` is not fully resolved"
13701370
);
13711371
value

compiler/rustc_infer/src/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ where
347347
let is_opaque = alias_ty.kind(self.tcx) == ty::Opaque;
348348
if approx_env_bounds.is_empty()
349349
&& trait_bounds.is_empty()
350-
&& (alias_ty.needs_infer() || is_opaque)
350+
&& (alias_ty.has_infer() || is_opaque)
351351
{
352352
debug!("no declared bounds");
353353
let opt_variances = is_opaque.then(|| self.tcx.variances_of(alias_ty.def_id));

compiler/rustc_infer/src/infer/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
213213
}
214214

215215
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
216-
if !t.needs_infer() {
216+
if !t.has_infer() {
217217
Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects...
218218
} else {
219219
let t = self.infcx.shallow_resolve(t);
@@ -243,7 +243,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
243243
}
244244

245245
fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
246-
if !c.needs_infer() {
246+
if !c.has_infer() {
247247
Ok(c) // micro-optimize -- if there is nothing in this const that this fold affects...
248248
} else {
249249
let c = self.infcx.shallow_resolve(c);

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'tcx> CtxtInterners<'tcx> {
215215
) -> Fingerprint {
216216
// It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
217217
// Without incremental, we rarely stable-hash types, so let's not do it proactively.
218-
if flags.flags.intersects(TypeFlags::NEEDS_INFER) || sess.opts.incremental.is_none() {
218+
if flags.flags.intersects(TypeFlags::HAS_INFER) || sess.opts.incremental.is_none() {
219219
Fingerprint::ZERO
220220
} else {
221221
let mut hasher = StableHasher::new();

compiler/rustc_middle/src/ty/erase_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
4040
}
4141

4242
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
43-
if ty.needs_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
43+
if ty.has_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
4444
}
4545

4646
fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T>

compiler/rustc_middle/src/ty/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ impl<'tcx> Ty<'tcx> {
11511151
// context, or *something* like that, but for now just avoid passing inference
11521152
// variables to queries that can't cope with them. Instead, conservatively
11531153
// return "true" (may change drop order).
1154-
if query_ty.needs_infer() {
1154+
if query_ty.has_infer() {
11551155
return true;
11561156
}
11571157

compiler/rustc_middle/src/ty/visit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
7979
self.has_type_flags(TypeFlags::HAS_TY_INFER)
8080
}
8181
fn has_non_region_infer(&self) -> bool {
82-
self.has_type_flags(TypeFlags::NEEDS_INFER - TypeFlags::HAS_RE_INFER)
82+
self.has_type_flags(TypeFlags::HAS_INFER - TypeFlags::HAS_RE_INFER)
8383
}
84-
fn needs_infer(&self) -> bool {
85-
self.has_type_flags(TypeFlags::NEEDS_INFER)
84+
fn has_infer(&self) -> bool {
85+
self.has_type_flags(TypeFlags::HAS_INFER)
8686
}
8787
fn has_placeholders(&self) -> bool {
8888
self.has_type_flags(

compiler/rustc_trait_selection/src/infer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
4141
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
4242
let ty = self.resolve_vars_if_possible(ty);
4343

44-
if !(param_env, ty).needs_infer() {
44+
if !(param_env, ty).has_infer() {
4545
return ty.is_copy_modulo_regions(self.tcx, param_env);
4646
}
4747

compiler/rustc_trait_selection/src/solve/canonicalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'a, 'tcx> Canonicalizer<'a, 'tcx> {
6969
};
7070

7171
let value = value.fold_with(&mut canonicalizer);
72-
assert!(!value.needs_infer());
72+
assert!(!value.has_infer());
7373
assert!(!value.has_placeholders());
7474

7575
let (max_universe, variables) = canonicalizer.finalize();

compiler/rustc_trait_selection/src/traits/coherence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ fn orphan_check_trait_ref<'tcx>(
582582
trait_ref: ty::TraitRef<'tcx>,
583583
in_crate: InCrate,
584584
) -> Result<(), OrphanCheckErr<'tcx>> {
585-
if trait_ref.needs_infer() && trait_ref.needs_subst() {
585+
if trait_ref.has_infer() && trait_ref.needs_subst() {
586586
bug!(
587587
"can't orphan check a trait ref with both params and inference variables {:?}",
588588
trait_ref

compiler/rustc_trait_selection/src/traits/outlives_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
6060
// We may however encounter unconstrained lifetime variables in invalid
6161
// code. See #110161 for context.
6262
assert!(!ty.has_non_region_infer());
63-
if ty.needs_infer() {
63+
if ty.has_infer() {
6464
self.tcx.sess.delay_span_bug(
6565
self.tcx.def_span(body_id),
6666
"skipped implied_outlives_bounds due to unconstrained lifetimes",

0 commit comments

Comments
 (0)