Skip to content

Commit 4d1d4d5

Browse files
authored
Unrolled build for rust-lang#123464
Rollup merge of rust-lang#123464 - fmease:rn-has-proj-to-has-aliases, r=compiler-errors Cleanup: Rename `HAS_PROJECTIONS` to `HAS_ALIASES` etc. The name of the bitflag `HAS_PROJECTIONS` and of its corresponding method `has_projections` is quite historical dating back to a time when projections were the only kind of alias type. I think it's time to update it to clear up any potential confusion for newcomers and to reduce unnecessary friction during contributor onboarding. r? types
2 parents 9cbaa01 + 6f17b7f commit 4d1d4d5

File tree

12 files changed

+21
-17
lines changed

12 files changed

+21
-17
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
461461
where
462462
T: TypeVisitable<TyCtxt<'tcx>>,
463463
{
464-
t.has_free_regions() || t.has_projections() || t.has_infer_types()
464+
t.has_free_regions() || t.has_aliases() || t.has_infer_types()
465465
}
466466

467467
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> TyCtxt<'tcx> {
4949
let value = self.erase_regions(value);
5050
debug!(?value);
5151

52-
if !value.has_projections() {
52+
if !value.has_aliases() {
5353
value
5454
} else {
5555
value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
@@ -81,7 +81,7 @@ impl<'tcx> TyCtxt<'tcx> {
8181
let value = self.erase_regions(value);
8282
debug!(?value);
8383

84-
if !value.has_projections() {
84+
if !value.has_aliases() {
8585
Ok(value)
8686
} else {
8787
let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, param_env);

compiler/rustc_mir_transform/src/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ fn try_instance_mir<'tcx>(
10771077
let fields = def.all_fields();
10781078
for field in fields {
10791079
let field_ty = field.ty(tcx, args);
1080-
if field_ty.has_param() && field_ty.has_projections() {
1080+
if field_ty.has_param() && field_ty.has_aliases() {
10811081
return Err("cannot build drop shim for polymorphic type");
10821082
}
10831083
}

compiler/rustc_trait_selection/src/solve/normalize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
177177
fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
178178
let infcx = self.at.infcx;
179179
debug_assert_eq!(ty, infcx.shallow_resolve(ty));
180-
if !ty.has_projections() {
180+
if !ty.has_aliases() {
181181
return Ok(ty);
182182
}
183183

@@ -204,7 +204,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
204204
fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
205205
let infcx = self.at.infcx;
206206
debug_assert_eq!(ct, infcx.shallow_resolve(ct));
207-
if !ct.has_projections() {
207+
if !ct.has_aliases() {
208208
return Ok(ct);
209209
}
210210

compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
311311

312312
let infcx = self.selcx.infcx;
313313

314-
if obligation.predicate.has_projections() {
314+
if obligation.predicate.has_aliases() {
315315
let mut obligations = Vec::new();
316316
let predicate = normalize_with_depth_to(
317317
&mut self.selcx,

compiler/rustc_trait_selection/src/traits/normalize.rs

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ pub(super) fn needs_normalization<'tcx, T: TypeVisitable<TyCtxt<'tcx>>>(
101101
value: &T,
102102
reveal: Reveal,
103103
) -> bool {
104+
// This mirrors `ty::TypeFlags::HAS_ALIASES` except that we take `Reveal` into account.
105+
104106
let mut flags = ty::TypeFlags::HAS_TY_PROJECTION
105107
| ty::TypeFlags::HAS_TY_WEAK
106108
| ty::TypeFlags::HAS_TY_INHERENT

compiler/rustc_trait_selection/src/traits/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub(super) fn opt_normalize_projection_type<'a, 'b, 'tcx>(
431431

432432
let projected_term = selcx.infcx.resolve_vars_if_possible(projected_term);
433433

434-
let mut result = if projected_term.has_projections() {
434+
let mut result = if projected_term.has_aliases() {
435435
let normalized_ty = normalize_with_depth_to(
436436
selcx,
437437
param_env,
@@ -595,7 +595,7 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>(
595595
let ty = tcx.type_of(alias_ty.def_id).instantiate(tcx, args);
596596

597597
let mut ty = selcx.infcx.resolve_vars_if_possible(ty);
598-
if ty.has_projections() {
598+
if ty.has_aliases() {
599599
ty = normalize_with_depth_to(selcx, param_env, cause.clone(), depth + 1, ty, obligations);
600600
}
601601

compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ where
1515
type QueryResponse = T;
1616

1717
fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
18-
if !key.value.value.has_projections() { Some(key.value.value) } else { None }
18+
if !key.value.value.has_aliases() { Some(key.value.value) } else { None }
1919
}
2020

2121
fn perform_query(

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10601060
// so we will try to normalize the obligation and evaluate again.
10611061
// we will replace it with new solver in the future.
10621062
if EvaluationResult::EvaluatedToErr == result
1063-
&& fresh_trait_pred.has_projections()
1063+
&& fresh_trait_pred.has_aliases()
10641064
&& fresh_trait_pred.is_global()
10651065
{
10661066
let mut nested_obligations = Vec::new();

compiler/rustc_ty_utils/src/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ fn layout_of_uncached<'tcx>(
241241

242242
// Arrays and slices.
243243
ty::Array(element, mut count) => {
244-
if count.has_projections() {
244+
if count.has_aliases() {
245245
count = tcx.normalize_erasing_regions(param_env, count);
246-
if count.has_projections() {
246+
if count.has_aliases() {
247247
return Err(error(cx, LayoutError::Unknown(ty)));
248248
}
249249
}

compiler/rustc_type_ir/src/flags.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ bitflags! {
7878
/// Does this have `ConstKind::Unevaluated`?
7979
const HAS_CT_PROJECTION = 1 << 14;
8080

81-
/// Could this type be normalized further?
82-
const HAS_PROJECTION = TypeFlags::HAS_TY_PROJECTION.bits()
81+
/// Does this have `Alias` or `ConstKind::Unevaluated`?
82+
///
83+
/// Rephrased, could this term be normalized further?
84+
const HAS_ALIASES = TypeFlags::HAS_TY_PROJECTION.bits()
8385
| TypeFlags::HAS_TY_WEAK.bits()
8486
| TypeFlags::HAS_TY_OPAQUE.bits()
8587
| TypeFlags::HAS_TY_INHERENT.bits()

compiler/rustc_type_ir/src/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
223223
self.has_vars_bound_at_or_above(ty::INNERMOST)
224224
}
225225

226-
fn has_projections(&self) -> bool {
227-
self.has_type_flags(TypeFlags::HAS_PROJECTION)
226+
fn has_aliases(&self) -> bool {
227+
self.has_type_flags(TypeFlags::HAS_ALIASES)
228228
}
229229

230230
fn has_inherent_projections(&self) -> bool {

0 commit comments

Comments
 (0)