Skip to content

yeet alias new_from_def_id - #162760

Open
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:yeet-new_from_def_id
Open

khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:yeet-new_from_def_id

Conversation

@khyperia

Copy link
Copy Markdown
Member

this PR fixes the // FIXME: remove in favor of explicit construction on alias_term_kind_from_def_id

vaguely related to rust-lang/project-const-generics#98 / #152245

this PR might be slightly perf-positive due to calling def_kind less. the change to THIR ExprKind is maybe very tiny bit different perf characteristics too but highly unlikely.

fyi @lcnr who didn't like AliasConstInherentArgsKind #161929 (comment) (it gets yeeted in this PR)

r? @BoxyUwU

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

@khyperia
khyperia marked this pull request as ready for review September 14, 2026 10:56
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_sanitizers

cc @rcvalle

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred in rustc_ty_utils::consts.rs

cc @BoxyUwU

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 14, 2026
ct: ty::AliasConst::new(
self.tcx,
ty::AliasConstKind::Anon { def_id: did },
self.tcx.mk_args(&[]),

@khyperia khyperia Sep 14, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

debating if I should pull this change out into another PR:

this changes the args from the ADT's args to []. This is because discriminant anon consts have no generics, but we were passing the ADT's generics to it here. This is wrong, and with this change, the debug assert in AliasConst::new for correct generic args triggers. Before, we were simply harmlessly ignoring the extra generic args.

View changes since the review

@bit-aloo bit-aloo left a comment

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.

LGTM 🚀 . Few questions though..

View changes since this review

Comment on lines 73 to 76
let user_ty = user_ty.as_ref().and_then(push_cuta);
// Under generic_const_args, `def_id` might be a regular const declared in a trait, but
// is `impl`d as a directly represented const. We do not know whether it is here, so we
// must use type system normalization for all consts under generic_const_args.

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.

Can we reword this?

Comment thread compiler/rustc_mir_build/src/thir/cx/expr.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants