Skip to content

remove AliasTy::def_id()#158013

Open
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:AliasTy-def_id
Open

remove AliasTy::def_id()#158013
khyperia wants to merge 1 commit into
rust-lang:mainfrom
khyperia:AliasTy-def_id

Conversation

@khyperia

Copy link
Copy Markdown
Contributor

this is part of #156181

as well as part of #152245

this immediately uses the recently-introduced Alias<> type to narrow the kinds of aliases allowed in various places in code

fyi @lcnr

r? @BoxyUwU

@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 17, 2026
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Jun 17, 2026
@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

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

self.opt_rpitit_info(def_id).is_some()
}

pub fn get_impl_future_output_ty(self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {

@khyperia khyperia Jun 17, 2026

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.

I moved this from TypeErrCtxt to TyCtxt... maybe I should split this to another commit

View changes since the review

pub type ProjectionAliasTy<'tcx> = ir::ProjectionAliasTy<TyCtxt<'tcx>>;
pub type InherentAliasTy<'tcx> = ir::InherentAliasTy<TyCtxt<'tcx>>;
pub type OpaqueAliasTy<'tcx> = ir::OpaqueAliasTy<TyCtxt<'tcx>>;
pub type FreeAliasTy<'tcx> = ir::FreeAliasTy<TyCtxt<'tcx>>;

@khyperia khyperia Jun 17, 2026

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.

some of these are unused... I'm not sure what the preference is here, if we should have unused useful things that fill out a "pattern", or if we should strictly add only what is actually used. (same question for try_to_inherent and stuff)

View changes since the review


let (ty::Projection { def_id } | ty::Inherent { def_id }) = proj_ty.kind else {
panic!("expected projection or inherent alias, found {:?}", proj_ty.kind);
};

@khyperia khyperia Jun 17, 2026

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.

these variants were guarded against and and def_id fetched in the caller... there's sort of three ways to handle this:

  • guard in the caller, pass in the matched def_id as an additional argument alongside proj_ty
  • guard again in the callee, here, panicing if it's wrong (what I kind of arbitrarily chose to do here, and what I did in previous PRs)
  • create another Kind enum, for just Projection/Inherent, and pass in an Alias<> with that kind

View changes since the review

pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy};
use rustc_type_ir_macros::GenericTypeVisitable;
pub use ty::{Alias, AliasTerm, AliasTy, UnevaluatedConst};
pub use ty::{Alias, *};

@khyperia khyperia Jun 17, 2026

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.

unrelated to this PR, I realized there's a conflict here - rustc_type_ir::Alias used to resolve to the TyKind::Alias variant, now it's the Alias struct. A bit unfortunate, but fine I guess.

(also IMO having a nested ty module (recently added, in the Alias<> PR) is very confusing (since rustc_type_ir is itself imported with the alias name of ty absolutely everywhere in the compiler), but oh well)

View changes since the review

ty::Opaque { def_id: key.def_id.into() },
key.args,
)
.try_to_opaque()

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.

hmm, why this indirection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants