Skip to content

Commit 8424197

Browse files
committed
rename needs_subst to has_param
1 parent f04b8fe commit 8424197

File tree

18 files changed

+28
-28
lines changed

18 files changed

+28
-28
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
515515
ty::Adt(def, ..) if !def.is_box() => {
516516
// Again, only create type information if full debuginfo is enabled
517517
if cx.sess().opts.debuginfo == DebugInfo::Full
518-
&& !impl_self_ty.needs_subst()
518+
&& !impl_self_ty.has_param()
519519
{
520520
Some(type_di_node(cx, impl_self_ty))
521521
} else {

compiler/rustc_const_eval/src/interpret/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ where
1414
T: TypeVisitable<TyCtxt<'tcx>>,
1515
{
1616
debug!("ensure_monomorphic_enough: ty={:?}", ty);
17-
if !ty.needs_subst() {
17+
if !ty.has_param() {
1818
return Ok(());
1919
}
2020

@@ -27,7 +27,7 @@ where
2727
type BreakTy = FoundParam;
2828

2929
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
30-
if !ty.needs_subst() {
30+
if !ty.has_param() {
3131
return ControlFlow::Continue(());
3232
}
3333

@@ -46,7 +46,7 @@ where
4646
// are used and require substitution.
4747
// Just in case there are closures or generators within this subst,
4848
// recurse.
49-
if unused_params.is_used(index) && subst.needs_subst() {
49+
if unused_params.is_used(index) && subst.has_param() {
5050
return subst.visit_with(self);
5151
}
5252
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3039,7 +3039,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
30393039
// the anon const, which is empty. This is why the
30403040
// `AlwaysApplicable` impl needs a `T: ?Sized` bound for
30413041
// this to compile if we were to normalize here.
3042-
if forbid_generic && ty.needs_subst() {
3042+
if forbid_generic && ty.has_param() {
30433043
let mut err = tcx.sess.struct_span_err(
30443044
path.span,
30453045
"generic `Self` types are currently not permitted in anonymous constants",

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
12921292
// Ignore dependent defaults -- that is, where the default of one type
12931293
// parameter includes another (e.g., `<T, U = T>`). In those cases, we can't
12941294
// be sure if it will error or not as user might always specify the other.
1295-
if !ty.needs_subst() {
1295+
if !ty.has_param() {
12961296
wfcx.register_wf_obligation(
12971297
tcx.def_span(param.def_id),
12981298
Some(WellFormedLoc::Ty(param.def_id.expect_local())),
@@ -1308,7 +1308,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
13081308
// for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>`
13091309
// we should eagerly error.
13101310
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
1311-
if !default_ct.needs_subst() {
1311+
if !default_ct.has_param() {
13121312
wfcx.register_wf_obligation(
13131313
tcx.def_span(param.def_id),
13141314
None,
@@ -1342,7 +1342,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
13421342
if is_our_default(param) {
13431343
let default_ty = tcx.type_of(param.def_id).subst_identity();
13441344
// ... and it's not a dependent default, ...
1345-
if !default_ty.needs_subst() {
1345+
if !default_ty.has_param() {
13461346
// ... then substitute it with the default.
13471347
return default_ty.into();
13481348
}
@@ -1355,7 +1355,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
13551355
if is_our_default(param) {
13561356
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
13571357
// ... and it's not a dependent default, ...
1358-
if !default_ct.needs_subst() {
1358+
if !default_ct.has_param() {
13591359
// ... then substitute it with the default.
13601360
return default_ct.into();
13611361
}

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ fn emit_newtype_suggestion_for_raw_ptr(
457457
ptr_ty: &ty::TypeAndMut<'_>,
458458
diag: &mut Diagnostic,
459459
) {
460-
if !self_ty.needs_subst() {
460+
if !self_ty.has_param() {
461461
let mut_key = ptr_ty.mutbl.prefix_str();
462462
let msg_sugg = "consider introducing a new wrapper type".to_owned();
463463
let sugg = vec![

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13841384
}
13851385
let item_ty = self.tcx.type_of(item.def_id).subst_identity();
13861386
// FIXME(compiler-errors): This check is *so* rudimentary
1387-
if item_ty.needs_subst() {
1387+
if item_ty.has_param() {
13881388
return false;
13891389
}
13901390
if self.can_coerce(item_ty, expected_ty) {

compiler/rustc_lint/src/enum_intrinsics_non_enums.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare_lint_pass!(EnumIntrinsicsNonEnums => [ENUM_INTRINSICS_NON_ENUMS]);
4242
/// Returns `true` if we know for sure that the given type is not an enum. Note that for cases where
4343
/// the type is generic, we can't be certain if it will be an enum so we have to assume that it is.
4444
fn is_non_enum(t: Ty<'_>) -> bool {
45-
!t.is_enum() && !t.needs_subst()
45+
!t.is_enum() && !t.has_param()
4646
}
4747

4848
fn enforce_mem_discriminant(

compiler/rustc_middle/src/ty/subst.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl<'tcx, T: TypeFoldable<TyCtxt<'tcx>>> ty::EarlyBinder<T> {
761761

762762
/// Returns the inner value, but only if it contains no bound vars.
763763
pub fn no_bound_vars(self) -> Option<T> {
764-
if !self.0.needs_subst() { Some(self.0) } else { None }
764+
if !self.0.has_param() { Some(self.0) } else { None }
765765
}
766766
}
767767

@@ -840,7 +840,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for SubstFolder<'a, 'tcx> {
840840
}
841841

842842
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
843-
if !t.needs_subst() {
843+
if !t.has_param() {
844844
return t;
845845
}
846846

compiler/rustc_middle/src/ty/visit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
7070
}
7171
}
7272
fn has_non_region_param(&self) -> bool {
73-
self.has_type_flags(TypeFlags::NEEDS_SUBST - TypeFlags::HAS_RE_PARAM)
73+
self.has_type_flags(TypeFlags::HAS_PARAM - TypeFlags::HAS_RE_PARAM)
7474
}
7575
fn has_infer_regions(&self) -> bool {
7676
self.has_type_flags(TypeFlags::HAS_RE_INFER)
@@ -94,8 +94,8 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
9494
fn has_non_region_placeholders(&self) -> bool {
9595
self.has_type_flags(TypeFlags::HAS_TY_PLACEHOLDER | TypeFlags::HAS_CT_PLACEHOLDER)
9696
}
97-
fn needs_subst(&self) -> bool {
98-
self.has_type_flags(TypeFlags::NEEDS_SUBST)
97+
fn has_param(&self) -> bool {
98+
self.has_type_flags(TypeFlags::HAS_PARAM)
9999
}
100100
/// "Free" regions in this context means that it has any region
101101
/// that is not (a) erased or (b) late-bound.

compiler/rustc_mir_transform/src/const_prop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
428428
/// Returns the value, if any, of evaluating `c`.
429429
fn eval_constant(&mut self, c: &Constant<'tcx>) -> Option<OpTy<'tcx>> {
430430
// FIXME we need to revisit this for #67176
431-
if c.needs_subst() {
431+
if c.has_param() {
432432
return None;
433433
}
434434

@@ -527,7 +527,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
527527
}
528528

529529
// FIXME we need to revisit this for #67176
530-
if rvalue.needs_subst() {
530+
if rvalue.has_param() {
531531
return None;
532532
}
533533
if !rvalue

compiler/rustc_mir_transform/src/const_prop_lint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
281281
/// Returns the value, if any, of evaluating `c`.
282282
fn eval_constant(&mut self, c: &Constant<'tcx>, location: Location) -> Option<OpTy<'tcx>> {
283283
// FIXME we need to revisit this for #67176
284-
if c.needs_subst() {
284+
if c.has_param() {
285285
return None;
286286
}
287287

@@ -474,7 +474,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
474474
}
475475

476476
// FIXME we need to revisit this for #67176
477-
if rvalue.needs_subst() {
477+
if rvalue.has_param() {
478478
return None;
479479
}
480480
if !rvalue.ty(self.local_decls(), self.tcx).is_sized(self.tcx, self.param_env) {

compiler/rustc_mir_transform/src/inline/cycle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
9292
// FIXME: A not fully substituted drop shim can cause ICEs if one attempts to
9393
// have its MIR built. Likely oli-obk just screwed up the `ParamEnv`s, so this
9494
// needs some more analysis.
95-
if callee.needs_subst() {
95+
if callee.has_param() {
9696
continue;
9797
}
9898
}

compiler/rustc_monomorphize/src/partitioning/default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
305305

306306
// When polymorphization is enabled, methods which do not depend on their generic
307307
// parameters, but the self-type of their impl block do will fail to normalize.
308-
if !tcx.sess.opts.unstable_opts.polymorphize || !instance.needs_subst() {
308+
if !tcx.sess.opts.unstable_opts.polymorphize || !instance.has_param() {
309309
// This is a method within an impl, find out what the self-type is:
310310
let impl_self_ty = tcx.subst_and_normalize_erasing_regions(
311311
instance.substs,

compiler/rustc_symbol_mangling/src/legacy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn get_symbol_hash<'tcx>(
108108
tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
109109

110110
// Include the main item-type. Note that, in this case, the
111-
// assertions about `needs_subst` may not hold, but this item-type
111+
// assertions about `has_param` may not hold, but this item-type
112112
// ought to be the same for every reference anyway.
113113
assert!(!item_type.has_erasable_regions());
114114
hcx.while_hashing_spans(false, |hcx| {

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.has_infer() && trait_ref.needs_subst() {
585+
if trait_ref.has_infer() && trait_ref.has_param() {
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/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ fn subst_and_check_impossible_predicates<'tcx>(
414414
predicates.push(ty::Binder::dummy(trait_ref).to_predicate(tcx));
415415
}
416416

417-
predicates.retain(|predicate| !predicate.needs_subst());
417+
predicates.retain(|predicate| !predicate.has_param());
418418
let result = impossible_predicates(tcx, predicates);
419419

420420
debug!("subst_and_check_impossible_predicates(key={:?}) = {:?}", key, result);

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10001000
) -> Result<EvaluationResult, OverflowError> {
10011001
if !self.is_intercrate()
10021002
&& obligation.is_global()
1003-
&& obligation.param_env.caller_bounds().iter().all(|bound| bound.needs_subst())
1003+
&& obligation.param_env.caller_bounds().iter().all(|bound| bound.has_param())
10041004
{
10051005
// If a param env has no global bounds, global obligations do not
10061006
// depend on its particular value in order to work, so we can clear

compiler/rustc_type_ir/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ bitflags! {
179179
/// Does this have `ConstKind::Param`?
180180
const HAS_CT_PARAM = 1 << 2;
181181

182-
const NEEDS_SUBST = TypeFlags::HAS_TY_PARAM.bits
182+
const HAS_PARAM = TypeFlags::HAS_TY_PARAM.bits
183183
| TypeFlags::HAS_RE_PARAM.bits
184184
| TypeFlags::HAS_CT_PARAM.bits;
185185

0 commit comments

Comments
 (0)