Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
526787d
rename from lazy_type_alias to checked_type_aliases
josetorrs Jul 4, 2026
37e12e1
Show sub-parts of types when only interesting part is lifetimes
estebank Jul 9, 2026
a85f928
Teach async closures and coroutines to print short types
estebank Jul 9, 2026
00d1b3f
Use `Highlight` when naming hidden type in return type
estebank Jul 9, 2026
76519dc
Make `Highlighted` take heed of `--verbose`
estebank Jul 9, 2026
24c30fb
Account for `for<'a>` in `<impl for<'a> Trait as Trait>` when shorten…
estebank Jul 10, 2026
e94c07c
Always show full signature on "`impl` doesn't match `trait`" error
estebank Jul 10, 2026
d228a89
Tweak logic to refer to items by their name instead of path when shor…
estebank Jul 10, 2026
b8c0562
Fix typo
estebank Jul 12, 2026
23204b1
address review comments
estebank Jul 12, 2026
ec430cb
tidy
estebank Jul 12, 2026
fa69dbd
Do not change closure short type rendering
estebank Jul 13, 2026
247cf33
Add missing backticks
estebank Jul 13, 2026
f43dbc2
Shorten `Highlighted` types when looking at regions, but never shorte…
estebank Jul 13, 2026
c6f5692
Tweak shortened closure logic
estebank Jul 13, 2026
05d7d3b
Add a regression test for an associated const equality region variabl…
jakubadamw Jul 15, 2026
2329d13
Add a regression test for a const parameter default body param-env ICE
jakubadamw Jul 15, 2026
26d2eda
Delete `lint-unknown-feature{,-default}.rs`
theemathas Jul 16, 2026
4b1bfb5
Delete FIXMEs about issue 44232.
theemathas Jul 16, 2026
5ccf44c
Track extra_lifetime_params_map per-owner
oli-obk May 27, 2026
38591d2
Add #[inline] to core::io methods with simple logic or forwarding
Darksonn Jul 16, 2026
e604a79
Rollup merge of #158758 - josetorrs:rename-lazy-type-alias, r=lcnr
jdonszelmann Jul 16, 2026
3ad59b1
Rollup merge of #159369 - Darksonn:core-io-inline, r=Mark-Simulacrum
jdonszelmann Jul 16, 2026
3782184
Rollup merge of #158992 - estebank:shorten-type-highlighted-lt, r=mejrs
jdonszelmann Jul 16, 2026
b33003c
Rollup merge of #159226 - oli-obk:extra_lifetime_params_map, r=petroc…
jdonszelmann Jul 16, 2026
7fe140b
Rollup merge of #159357 - jakubadamw:issue-148096-148620, r=folkertdev
jdonszelmann Jul 16, 2026
21f6f46
Rollup merge of #159360 - theemathas:del-44232-comments, r=petrochenkov
jdonszelmann Jul 16, 2026
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
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use super::diagnostics::{
use super::stability::{enabled_names, gate_unstable_abi};
use super::{
FnDeclKind, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
RelaxedBoundForbiddenReason, RelaxedBoundPolicy, ResolverAstLoweringExt,
RelaxedBoundForbiddenReason, RelaxedBoundPolicy,
};
use crate::diagnostics::ConstComptimeFn;

Expand Down Expand Up @@ -1878,7 +1878,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.collect();

// Introduce extra lifetimes if late resolution tells us to.
let extra_lifetimes = self.resolver.extra_lifetime_params(self.owner.id);
let extra_lifetimes = self.owner.extra_lifetime_params(self.owner.id);
params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| {
self.lifetime_res_to_generic_param(
ident,
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,6 @@ impl<'tcx> ResolverAstLowering<'tcx> {
)
.map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
}

/// Obtain the list of lifetimes parameters to add to an item.
///
/// Extra lifetime parameters should only be added in places that can appear
/// as a `binder` in `LifetimeRes`.
///
/// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
/// should appear at the enclosing `PolyTraitRef`.
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
}
}

/// How relaxed bounds `?Trait` should be treated.
Expand Down Expand Up @@ -1129,7 +1118,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
) -> &'hir [hir::GenericParam<'hir>] {
// Start by creating params for extra lifetimes params, as this creates the definitions
// that may be referred to by the AST inside `generic_params`.
let extra_lifetimes = self.resolver.extra_lifetime_params(binder);
let extra_lifetimes = self.owner.extra_lifetime_params(binder);
debug!(?extra_lifetimes);
let extra_lifetimes: Vec<_> = extra_lifetimes
.iter()
Expand Down
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() {
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: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl RegionName {
)) => {
diag.span_label(
*span,
format!("lifetime `{self}` appears in the type {type_name}"),
format!("lifetime `{self}` appears in the type `{type_name}`"),
);
}
RegionNameSource::AnonRegionFromOutput(
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 @@ -1215,10 +1215,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 @@ -236,7 +236,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 @@ -1582,9 +1582,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
17 changes: 14 additions & 3 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustc_abi::{
Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, VariantIdx,
};
use rustc_ast::node_id::NodeMap;
use rustc_ast::{self as ast};
use rustc_ast::{self as ast, NodeId};
pub use rustc_ast_ir::{Movability, Mutability, try_visit};
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::intern::Interned;
Expand Down Expand Up @@ -224,6 +224,8 @@ pub struct PerOwnerResolverData<'tcx> {

/// Resolution for import nodes, which have multiple resolutions in different namespaces.
pub import_res: hir::def::PerNS<Option<Res<ast::NodeId>>> = Default::default(),
/// Lifetime parameters that lowering will have to introduce.
pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, MissingLifetimeKind)>> = Default::default(),

/// The id of the owner
pub id: ast::NodeId,
Expand All @@ -245,6 +247,17 @@ impl<'tcx> PerOwnerResolverData<'tcx> {
pub fn get_lifetime_res(&self, id: ast::NodeId) -> Option<LifetimeRes> {
self.lifetimes_res_map.get(&id).copied()
}

/// Obtain the list of lifetimes parameters to add to an item.
///
/// Extra lifetime parameters should only be added in places that can appear
/// as a `binder` in `LifetimeRes`.
///
/// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
/// should appear at the enclosing `PolyTraitRef`.
pub fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
}
}

/// Resolutions that should only be used for lowering.
Expand All @@ -253,8 +266,6 @@ impl<'tcx> PerOwnerResolverData<'tcx> {
pub struct ResolverAstLowering<'tcx> {
/// Resolutions for nodes that have a single resolution.
pub partial_res_map: NodeMap<hir::def::PartialRes>,
/// Lifetime parameters that lowering will have to introduce.
pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, MissingLifetimeKind)>>,

pub next_node_id: ast::NodeId,

Expand Down
Loading
Loading