Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
self.check_type_no_bounds(bounds, "this context");

if self.features.lazy_type_alias() {

@fmease fmease Jul 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Personally speaking, I'm voting for checked_type_aliases, cc #t-types/lazy-type-alias > name bikeshed @ 💬)

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the poll is unanimous with renaming to checked_type_alias. I think I should be good with changing it along with renaming the test directory per #158758 (comment) to tests/ui/checked-type-alias/... (?) and this rename

I didn't vote in the poll as I didn't want to pretend I 100% fully understood everything haha

if self.features.checked_type_aliases() {
if let Err(err) = self.check_type_alias_where_clause_location(ty_alias) {
self.dcx().emit_err(err);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ pub(crate) struct FieldlessUnion {
pub(crate) struct WhereClauseAfterTypeAlias {
#[primary_span]
pub span: Span,
#[help("add `#![feature(lazy_type_alias)]` to the crate attributes to enable")]
#[help("add `#![feature(checked_type_aliases)]` to the crate attributes to enable")]
pub help: bool,
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ declare_features! (
(removed, issue_5723_bootstrap, "1.95.0", None, None),
/// Lazily evaluate constants. This allows constants to depend on type parameters.
(removed, lazy_normalization_consts, "1.56.0", Some(72219), Some("superseded by `generic_const_exprs`"), 88369),
/// Allow to have type alias types for inter-crate use.
(removed, lazy_type_alias, "1.72.0", Some(112792), Some("renamed to `checked_type_aliases`"), 158758),
/// Changes `impl Trait` to capture all lifetimes in scope.
(removed, lifetime_capture_rules_2024, "1.87.0", None, Some("unnecessary -- use edition 2024 instead"), 136787),
/// Allows using the `#[link_args]` attribute.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ declare_features! (
(unstable, cfg_version, "1.45.0", Some(64796)),
/// Allows to use the `#[cfi_encoding = ""]` attribute.
(unstable, cfi_encoding, "1.71.0", Some(89653)),
/// Allow to have type alias types for inter-crate use.
(incomplete, checked_type_aliases, "CURRENT_RUSTC_VERSION", Some(112792)),
/// The `clflushopt` target feature on x86.
(unstable, clflushopt_target_feature, "1.98.0", Some(157096)),
/// Allows `for<...>` on closures and coroutines.
Expand Down Expand Up @@ -609,8 +611,6 @@ declare_features! (
(unstable, lahfsahf_target_feature, "1.78.0", Some(150251)),
/// Allows setting the threshold for the `large_assignments` lint.
(unstable, large_assignments, "1.52.0", Some(83518)),
/// Allow to have type alias types for inter-crate use.
(incomplete, lazy_type_alias, "1.72.0", Some(112792)),
/// Allows using `#[link(kind = "link-arg", name = "...")]`
/// to pass custom arguments to the linker.
(unstable, link_arg_attribute, "1.76.0", Some(99427)),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
tcx.ensure_ok().predicates_of(def_id);
let ty = tcx.type_of(def_id).instantiate_identity();
let span = tcx.def_span(def_id);
if tcx.type_alias_is_lazy(def_id) {
if tcx.type_alias_is_checked(def_id) {
res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| {
let item_ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty);
wfcx.register_wf_obligation(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ where

let mut wfcx = WfCheckingCtxt { ocx, body_def_id, param_env };

// As of now, bounds are only checked on lazy type aliases, they're ignored for most type
// As of now, bounds are only enforced on checked type aliases, they're ignored for most type
// aliases. So, only check for false global bounds if we're not ignoring bounds altogether.
let ignore_bounds =
tcx.def_kind(body_def_id) == DefKind::TyAlias && !tcx.type_alias_is_lazy(body_def_id);
tcx.def_kind(body_def_id) == DefKind::TyAlias && !tcx.type_alias_is_checked(body_def_id);

if !ignore_bounds && !tcx.features().trivial_bounds() {
wfcx.check_false_global_bounds()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) fn provide(providers: &mut Providers) {
type_of: type_of::type_of,
type_of_opaque: type_of::type_of_opaque,
type_of_opaque_hir_typeck: type_of::type_of_opaque_hir_typeck,
type_alias_is_lazy: type_of::type_alias_is_lazy,
type_alias_is_checked: type_of::type_alias_is_checked,
item_bounds: item_bounds::item_bounds,
explicit_item_bounds: item_bounds::explicit_item_bounds,
item_self_bounds: item_bounds::item_self_bounds,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
}
}

pub(crate) fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
pub(crate) fn type_alias_is_checked<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
use hir::intravisit::Visitor;
if tcx.features().lazy_type_alias() {
if tcx.features().checked_type_aliases() {
return true;
}
struct HasTait;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let identically_named = suggested_name == assoc_ident.name;

if let DefKind::TyAlias = tcx.def_kind(item_def_id)
&& !tcx.type_alias_is_lazy(item_def_id)
&& !tcx.type_alias_is_checked(item_def_id)
{
err.sugg =
Some(diagnostics::AssocItemNotFoundSugg::SimilarInOtherTraitQPath {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,10 +1214,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let args = self.lower_generic_args_of_path_segment(span, def_id, item_segment);

if let DefKind::TyAlias = tcx.def_kind(def_id)
&& tcx.type_alias_is_lazy(def_id)
&& tcx.type_alias_is_checked(def_id)
{
// Type aliases defined in crates that have the
// feature `lazy_type_alias` enabled get encoded as a type alias that normalization will
// feature `checked_type_alias` enabled get encoded as a type alias that normalization will
// then actually instantiate the where bounds of.
let alias_ty = ty::AliasTy::new_from_args(tcx, ty::Free { def_id }, args);
Ty::new_alias(tcx, ty::IsRigid::No, alias_ty)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(super) fn infer_predicates(
}
}

DefKind::TyAlias if tcx.type_alias_is_lazy(item_did) => {
DefKind::TyAlias if tcx.type_alias_is_checked(item_did) => {
insert_required_predicates_to_be_wf(
tcx,
tcx.type_of(item_did).instantiate_identity().skip_norm_wip(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/outlives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(super) fn inferred_outlives_of(
let crate_map = tcx.inferred_outlives_crate(());
crate_map.predicates.get(&item_def_id.to_def_id()).copied().unwrap_or(&[])
}
DefKind::TyAlias if tcx.type_alias_is_lazy(item_def_id) => {
DefKind::TyAlias if tcx.type_alias_is_checked(item_def_id) => {
let crate_map = tcx.inferred_outlives_crate(());
crate_map.predicates.get(&item_def_id.to_def_id()).copied().unwrap_or(&[])
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,8 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
return;
}

// Bounds of lazy type aliases and TAITs are respected.
if cx.tcx.type_alias_is_lazy(item.owner_id) {
// Bounds of checked type aliases and TAITs are respected.
if cx.tcx.type_alias_is_checked(item.owner_id) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl<'a> Diagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"
));
if self.enable_feat_help {
diag.help(msg!("add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics"));
diag.help(msg!("add `#![feature(checked_type_aliases)]` to the crate attributes to enable the desired semantics"));
}

// We perform the walk in here instead of in `<TypeAliasBounds as LateLintPass>` to
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ provide! { tcx, def_id, other, cdata,
explicit_super_predicates_of => { table_defaulted_array }
explicit_implied_predicates_of => { table_defaulted_array }
type_of => { table }
type_alias_is_lazy => { table_direct }
type_alias_is_checked => { table_direct }
variances_of => { table }
fn_sig => { table }
codegen_fn_attrs => { table }
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,9 +1579,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
if let DefKind::TyAlias = def_kind {
self.tables
.type_alias_is_lazy
.set(def_id.index, self.tcx.type_alias_is_lazy(def_id));
if self.tcx.type_alias_is_lazy(def_id) {
.type_alias_is_checked
.set(def_id.index, self.tcx.type_alias_is_checked(def_id));
if self.tcx.type_alias_is_checked(def_id) {
record!(self.tables.args_known_to_outlive_alias_params[def_id] <- tcx.args_known_to_outlive_alias_params(def_id));
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ define_tables! {
- defaulted:
intrinsic: Table<DefIndex, Option<LazyValue<ty::IntrinsicDef>>>,
is_macro_rules: Table<DefIndex, bool>,
type_alias_is_lazy: Table<DefIndex, bool>,
type_alias_is_checked: Table<DefIndex, bool>,
attr_flags: Table<DefIndex, AttrFlags>,
// The u64 is the crate-local part of the DefPathHash. All hashes in this crate have the same
// StableCrateId, so we omit encoding those into the table.
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,22 +332,22 @@ rustc_queries! {
}
}

/// Returns whether the type alias given by `DefId` is lazy.
/// Returns whether the type alias given by `DefId` is checked.
///
/// I.e., if the type alias expands / ought to expand to a [free] [alias type]
/// instead of the underlying aliased type.
///
/// Relevant for features `lazy_type_alias` and `type_alias_impl_trait`.
/// Relevant for features `checked_type_aliases` and `type_alias_impl_trait`.
///
/// # Panics
///
/// This query *may* panic if the given definition is not a type alias.
///
/// [free]: rustc_middle::ty::Free
/// [alias type]: rustc_middle::ty::AliasTy
query type_alias_is_lazy(key: DefId) -> bool {
query type_alias_is_checked(key: DefId) -> bool {
desc {
"computing whether the type alias `{path}` is lazy",
"computing whether the type alias `{path}` is checked",
path = tcx.def_path_str(key),
}
separate_provide_extern
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Computes a projection goal for inherent associated types,
//! `#![feature(lazy_type_alias)]` and `#![feature(type_alias_impl_trait)]`.
//! `#![feature(checked_type_aliases)]` and `#![feature(type_alias_impl_trait)]`.
//!
//! Since a free alias is never ambiguous, this just computes the `type_of` of
//! the alias and registers the where-clauses of the type alias.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ symbols! {
cfi,
cfi_encoding,
char,
checked_type_aliases,
clflushopt_target_feature,
client,
clippy,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> {
// placeholders as the trait solver does not expect to encounter escaping bound
// vars in obligations.
//
// FIXME(lazy_type_alias): Check how much this actually matters for perf before
// FIXME(checked_type_alias): Check how much this actually matters for perf before
// stabilization. This is a bit weird and generally not how we handle binders in
// the compiler so ideally we'd do the same boundvar->placeholder->boundvar dance
// that other kinds of normalization do.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/normalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Secondly, instead of having normalization directly return the type specified in
We do this so that normalization is idempotent/callers do not need to run it in a loop.

```rust
#![feature(lazy_type_alias)]
#![feature(checked_type_alias)]

type Foo<T: Iterator> = Bar<T>;
type Bar<T: Iterator> = <T as Iterator>::Item;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
}

ty::Alias(_, ty::AliasTy { kind: ty::Free { def_id }, args, .. }) => {
if cx.tcx.features().lazy_type_alias() {
if cx.tcx.features().checked_type_aliases() {
// Free type alias `data` represents the `type X` in `type X = Y`. If we need `Y`,
// we need to use `type_of`.
let path =
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ impl<'item> DocVisitor<'item> for TypeImplCollector<'_, '_, 'item> {
// Only include this impl if it actually unifies with this alias.
// Synthetic impls are not included; those are also included in the HTML.
//
// FIXME(lazy_type_alias): Once the feature is complete or stable, rewrite this
// FIXME(checked_type_alias): Once the feature is complete or stable, rewrite this
// to use type unification.
// Be aware of `tests/rustdoc-html/type-alias/deeply-nested-112515.rs` which might
// regress.
Expand Down
2 changes: 1 addition & 1 deletion tests/crashes/114198.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ known-bug: #114198
//@ compile-flags: -Zprint-mono-items -Clink-dead-code

#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]

impl Trait for Struct {}
trait Trait {
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-html/reexport/alias-reexport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@ aux-build:alias-reexport2.rs

#![crate_name = "foo"]
#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]
#![allow(incomplete_features)]

extern crate alias_reexport2;
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-html/reexport/alias-reexport2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// gate-test-lazy_type_alias
// gate-test-checked_type_aliases
//@ aux-build:alias-reexport.rs

#![crate_name = "foo"]
#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]
#![allow(incomplete_features)]

extern crate alias_reexport;
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-html/reexport/auxiliary/alias-reexport.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]

pub type Reexported = u8;
2 changes: 1 addition & 1 deletion tests/rustdoc-html/reexport/auxiliary/alias-reexport2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]

extern crate alias_reexport;

Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-html/sidebar/top-toc-html.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ignore-tidy-linelength

#![crate_name = "foo"]
#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]
#![allow(incomplete_features)]

//! # Basic [link](https://example.com), *emphasis*, **_very emphasis_** and `code`
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-html/sidebar/top-toc-idmap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "foo"]
#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]
#![allow(incomplete_features)]

//! # Structs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![crate_name = "inner_types_lazy"]

#![feature(lazy_type_alias)]
#![feature(checked_type_aliases)]
#![allow(incomplete_features)]

//@ has 'inner_types_lazy/struct.Pair.html'
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ Tests for the `--check-cfg` compiler mechanism for checking cfg configurations,

See [Checking conditional configurations | The rustc book](https://doc.rust-lang.org/rustc/check-cfg.html).

## `tests/ui/checked-type-alias/`

Tests for `#![feature(checked_type_aliases)]`. See [Tracking issue for checked type aliases](https://github.com/rust-lang/rust/issues/112792).

## `tests/ui/closure-expected-type/`: Closure type inference

Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the *expected type* we have alongside the *actual types* that we get from inputs.
Expand Down Expand Up @@ -800,10 +804,6 @@ See [Early vs Late bound parameters | rustc-dev-guide](https://rustc-dev-guide.r

See [Type Layout | Reference](https://doc.rust-lang.org/reference/type-layout.html).

## `tests/ui/lazy-type-alias/`

Tests for `#![feature(lazy_type_alias)]`. See [Tracking issue for lazy type aliases #112792](https://github.com/rust-lang/rust/issues/112792).

## `tests/ui/lazy-type-alias-impl-trait/`

This feature allows use of an `impl Trait` in multiple locations while actually using the same concrete type (`type Alias = impl Trait;`) everywhere, keeping the original `impl Trait` hidden.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ check-pass

#![feature(inherent_associated_types, lazy_type_alias)]
#![feature(inherent_associated_types, checked_type_aliases)]
#![expect(incomplete_features)]

// Test that we *do* normalize free aliases in order to resolve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | pub type Alias<T: Bound> = (Source<T>::Assoc,);
|
= note: this is a known limitation of the type checker that may be lifted in a future edition.
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
= help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics
= help: add `#![feature(checked_type_aliases)]` to the crate attributes to enable the desired semantics
= note: `#[warn(type_alias_bounds)]` on by default
help: remove this bound
|
Expand Down
Loading
Loading