Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7843686

Browse files
Rollup merge of rust-lang#140249 - BoxyUwU:remove_weak_alias_terminology, r=oli-obk
Remove `weak` alias terminology I find the "weak" alias terminology to be quite confusing. It implies the existence of "strong" aliases (which do not exist) and I'm not really sure what about weak aliases is "weak". I much prefer "free alias" as the term. I think it's much more obvious what it means as "free function" is a well defined term that already exists in rust. It's also a little confusing given "weak alias" is already a term in linker/codegen spaces which are part of the compiler too. Though I'm not particularly worried about that as it's usually very obvious if you're talking about the type system or not lol. I'm also currently trying to write documentation about aliases and it's somewhat awkward/confusing to be talking about *weak* aliases, when I'm not really sure what the basis for that as the term actually *is*. I would also be happy to just find out there's a nice meaning behind calling them "weak" aliases :-) r? `@oli-obk` maybe we want a types MCP to decide on a specific naming here? or maybe we think its just too late to go back on this naming decision ^^'
2 parents a782b54 + bdfeb8f commit 7843686

File tree

47 files changed

+106
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+106
-106
lines changed

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
5656
| ty::Coroutine(def_id, args) => self.print_def_path(def_id, args),
5757
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
5858

59-
ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"),
59+
ty::Alias(ty::Free, _) => bug!("type_name: unexpected free alias"),
6060
ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"),
6161
ty::CoroutineWitness(..) => bug!("type_name: unexpected `CoroutineWitness`"),
6262
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ fn check_variances_for_type_defn<'tcx>(
20192019
ItemKind::TyAlias(..) => {
20202020
assert!(
20212021
tcx.type_alias_is_lazy(item.owner_id),
2022-
"should not be computing variance of non-weak type alias"
2022+
"should not be computing variance of non-free type alias"
20232023
);
20242024
}
20252025
kind => span_bug!(item.span, "cannot compute the variances of {kind:?}"),
@@ -2251,7 +2251,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsProbablyCyclical<'tcx> {
22512251
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
22522252
let def_id = match ty.kind() {
22532253
ty::Adt(adt_def, _) => Some(adt_def.did()),
2254-
ty::Alias(ty::Weak, alias_ty) => Some(alias_ty.def_id),
2254+
ty::Alias(ty::Free, alias_ty) => Some(alias_ty.def_id),
22552255
_ => None,
22562256
};
22572257
if let Some(def_id) = def_id {

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'tcx> InherentCollect<'tcx> {
150150
let id = id.owner_id.def_id;
151151
let item_span = self.tcx.def_span(id);
152152
let self_ty = self.tcx.type_of(id).instantiate_identity();
153-
let mut self_ty = self.tcx.peel_off_weak_alias_tys(self_ty);
153+
let mut self_ty = self.tcx.peel_off_free_alias_tys(self_ty);
154154
// We allow impls on pattern types exactly when we allow impls on the base type.
155155
// FIXME(pattern_types): Figure out the exact coherence rules we want here.
156156
while let ty::Pat(base, _) = *self_ty.kind() {
@@ -188,7 +188,7 @@ impl<'tcx> InherentCollect<'tcx> {
188188
| ty::CoroutineClosure(..)
189189
| ty::Coroutine(..)
190190
| ty::CoroutineWitness(..)
191-
| ty::Alias(ty::Weak, _)
191+
| ty::Alias(ty::Free, _)
192192
| ty::Bound(..)
193193
| ty::Placeholder(_)
194194
| ty::Infer(_) => {

compiler/rustc_hir_analysis/src/coherence/orphan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub(crate) fn orphan_check_impl(
189189
ty::Projection => "associated type",
190190
// type Foo = (impl Sized, bool)
191191
// impl AutoTrait for Foo {}
192-
ty::Weak => "type alias",
192+
ty::Free => "type alias",
193193
// type Opaque = impl Trait;
194194
// impl AutoTrait for Opaque {}
195195
ty::Opaque => "opaque type",

compiler/rustc_hir_analysis/src/constrained_generic_params.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) fn parameters_for<'tcx>(
4949
include_nonconstraining: bool,
5050
) -> Vec<Parameter> {
5151
let mut collector = ParameterCollector { parameters: vec![], include_nonconstraining };
52-
let value = if !include_nonconstraining { tcx.expand_weak_alias_tys(value) } else { value };
52+
let value = if !include_nonconstraining { tcx.expand_free_alias_tys(value) } else { value };
5353
value.visit_with(&mut collector);
5454
collector.parameters
5555
}
@@ -68,9 +68,9 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
6868
{
6969
return;
7070
}
71-
// All weak alias types should've been expanded beforehand.
72-
ty::Alias(ty::Weak, _) if !self.include_nonconstraining => {
73-
bug!("unexpected weak alias type")
71+
// All free alias types should've been expanded beforehand.
72+
ty::Alias(ty::Free, _) if !self.include_nonconstraining => {
73+
bug!("unexpected free alias type")
7474
}
7575
ty::Param(param) => self.parameters.push(Parameter::from(param)),
7676
_ => {}

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
958958
// feature `lazy_type_alias` enabled get encoded as a type alias that normalization will
959959
// then actually instantiate the where bounds of.
960960
let alias_ty = ty::AliasTy::new_from_args(tcx, did, args);
961-
Ty::new_alias(tcx, ty::Weak, alias_ty)
961+
Ty::new_alias(tcx, ty::Free, alias_ty)
962962
} else {
963963
tcx.at(span).type_of(did).instantiate(tcx, args)
964964
}

compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ fn insert_required_predicates_to_be_wf<'tcx>(
157157
);
158158
}
159159

160-
ty::Alias(ty::Weak, alias) => {
160+
ty::Alias(ty::Free, alias) => {
161161
// This corresponds to a type like `Type<'a, T>`.
162162
// We check inferred and explicit predicates.
163-
debug!("Weak");
163+
debug!("Free");
164164
check_inferred_predicates(
165165
tcx,
166166
alias.def_id,

compiler/rustc_hir_analysis/src/variance/constraints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
107107
let current_item = &CurrentItem { inferred_start };
108108
let ty = tcx.type_of(def_id).instantiate_identity();
109109

110-
// The type as returned by `type_of` is the underlying type and generally not a weak projection.
110+
// The type as returned by `type_of` is the underlying type and generally not a free alias.
111111
// Therefore we need to check the `DefKind` first.
112112
if let DefKind::TyAlias = tcx.def_kind(def_id)
113113
&& tcx.type_alias_is_lazy(def_id)
@@ -282,7 +282,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
282282
self.add_constraints_from_invariant_args(current, data.args, variance);
283283
}
284284

285-
ty::Alias(ty::Weak, ref data) => {
285+
ty::Alias(ty::Free, ref data) => {
286286
self.add_constraints_from_args(current, data.def_id, data.args, variance);
287287
}
288288

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
337337
match ty.kind() {
338338
ty::Adt(adt_def, _) => Some(*adt_def),
339339
// FIXME(#104767): Should we handle bound regions here?
340-
ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _)
340+
ty::Alias(ty::Projection | ty::Inherent | ty::Free, _)
341341
if !ty.has_escaping_bound_vars() =>
342342
{
343343
if self.next_trait_solver() {
@@ -357,7 +357,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
357357
// WF obligations that are registered elsewhere, but they have a
358358
// better cause code assigned to them in `add_required_obligations_for_hir`.
359359
// This means that they should shadow obligations with worse spans.
360-
if let ty::Alias(ty::Projection | ty::Weak, ty::AliasTy { args, def_id, .. }) =
360+
if let ty::Alias(ty::Projection | ty::Free, ty::AliasTy { args, def_id, .. }) =
361361
ty.kind()
362362
{
363363
self.add_required_obligations_for_hir(span, *def_id, args, hir_id);

compiler/rustc_infer/src/infer/relate/generalize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'tcx> InferCtxt<'tcx> {
113113
}]);
114114
}
115115
// The old solver only accepts projection predicates for associated types.
116-
ty::Alias(ty::Inherent | ty::Weak | ty::Opaque, _) => {
116+
ty::Alias(ty::Inherent | ty::Free | ty::Opaque, _) => {
117117
return Err(TypeError::CyclicTy(source_ty));
118118
}
119119
_ => bug!("generalized `{source_ty:?} to infer, not an alias"),

0 commit comments

Comments
 (0)