Skip to content

remove AliasTy::def_id()#158013

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
khyperia:AliasTy-def_id
Jun 23, 2026
Merged

remove AliasTy::def_id()#158013
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
khyperia:AliasTy-def_id

Conversation

@khyperia

@khyperia khyperia commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

View all comments

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

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.

could be nice yeah, but also was fine as is for me when reviewing

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

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.

panic'ing seems fine for now 🤔 needing a ProjectionOrInherentAlias seems like maybe slightly overkill

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

Comment thread compiler/rustc_infer/src/infer/mod.rs Outdated
ty::Opaque { def_id: key.def_id.into() },
key.args,
)
.try_to_opaque()

@lcnr lcnr Jun 17, 2026

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?

View changes since the review

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.

there is currently no way to construct a OpaqueAliasTy directly (in particular, I want to make sure debug_assert_args_compatible is called).

  • option 1: make a bespoke constructor for OpaqueAliasTy (and optionally Projection/Inherent/Free too, depending on the policy on unused code, I'm not sure)
  • option 2: some kind of generic constructor, hmm. Maybe one that takes T: Into<AliasTerm>, and then call an AliasTerm-based debug_assert_args_compatible?
  • option 3: hit it with a stupid hammer and use the AliasTy constructor and .try_to_opaque()

I went with option 3 :s (option 1 I was nervous about unused code, option 2 runs into the issue that we talked about of I::OpaqueTyId not being a newtype wrapper - I::OpaqueTyId can't impl Into<AliasTerm> at the moment, it's just a DefId). Happy to refactor, I just dunno what the nicest thing to do is

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.

I think that 1 is fine, id personally kinda bias towards adding all the dead code for the other kinds of aliases just so it's less annoying when they do actually need to be used, but it's also fine to only add the stuff actually needed 😌

@BoxyUwU

BoxyUwU commented Jun 19, 2026

Copy link
Copy Markdown
Member

looked over it seems good to me :3

@BoxyUwU

BoxyUwU commented Jun 19, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 19, 2026
@rustbot

rustbot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@khyperia

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 Jun 20, 2026

@Shourya742 Shourya742 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. I have a few questions, but overall the changes were easy to follow and understand. Thanks.

View changes since this review

Comment on lines +165 to +168
.tcx
.infer_ctxt()
.build(cx.typing_mode())
.err_ctxt()
.tcx

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.

I think we may no longer need to construct an InferCtxt here. If I understand correctly, it was previously required to obtain an err_ctxt and then call get_impl_future_output_ty. Since we already have access to tcx, would it make sense to call cx.tcx.get_impl_future_output_ty(ret_ty) directly instead (as we moved it to tcx)?

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.

good point! I did the move too quickly and didn't realize we could skip building it entirely. Nice, pushed!

Comment on lines +34 to +38
@@ -36,7 +35,7 @@ fn result_err_ty<'tcx>(
.tcx
.infer_ctxt()
.build(cx.typing_mode())
.err_ctxt()
.tcx

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.

I think this follows the same, we can directly use tcx?

Comment on lines +168 to +169
let infcx = cx.tcx.infer_ctxt().build(cx.typing_mode());
if let Some(future_ty) = infcx.err_ctxt().get_impl_future_output_ty(return_ty(cx, item_id))
if let Some(future_ty) = infcx.tcx.get_impl_future_output_ty(return_ty(cx, item_id))

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.

I think follows the same, we can use cx.tcx.get_impl_future_output_ty?

@BoxyUwU

BoxyUwU commented Jun 23, 2026

Copy link
Copy Markdown
Member

@bors r+ rollup=never p=1

@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 992c2de has been approved by BoxyUwU

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 23, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 23, 2026
remove AliasTy::def_id()



this is part of #156181

as well as part of #152245

this immediately uses [the recently-introduced `Alias<>` type](#156538) to narrow the kinds of aliases allowed in various places in code

fyi @lcnr

r? @BoxyUwU
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-aarch64-apple failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] zerofrom test:false 0.076
   Compiling serde_derive v1.0.228
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-Wl,-exported_symbols_list" "-Wl,/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/yoke-derive/7fe6fb8ff385634f/out/rustcm96NsH/list" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/yoke-derive/7fe6fb8ff385634f/out/rustcm96NsH/symbols.o" "<7 object files omitted>" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/yoke-derive/7fe6fb8ff385634f/out/rustcm96NsH/rmeta.o" "<1 object files omitted>" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/synstructure/971d5cb1c2bb7029/out/libsynstructure-971d5cb1c2bb7029.rlib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/syn/c096cb8fc5f8ec7c/out/libsyn-c096cb8fc5f8ec7c.rlib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/quote/f82bde6d5961fcb6/out/libquote-f82bde6d5961fcb6.rlib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/proc-macro2/b089cc3d8a1dc156/out/libproc_macro2-b089cc3d8a1dc156.rlib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/unicode-ident/59c09d8f5bb0c300/out/libunicode_ident-59c09d8f5bb0c300.rlib" "<sysroot>/lib/rustlib/aarch64-apple-darwin/lib/{libproc_macro-*,librustc_literal_escaper-*,libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-o" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/bootstrap-tools/release/build/yoke-derive/7fe6fb8ff385634f/out/libyoke_derive-7fe6fb8ff385634f.dylib" "-Wl,-dead_strip" "-dynamiclib" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: clang: error: unable to execute command: Segmentation fault: 11
          clang: error: linker command failed due to signal (use -v to see invocation)
          Apple clang version 17.0.0 (clang-1700.6.3.2)
          Target: arm64-apple-darwin24.6.0
          Thread model: posix
          InstalledDir: /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
          clang: note: diagnostic msg: 
          ********************
          
          PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
          Linker snapshot containing input(s) and associated run script(s) are located at:
          clang: note: diagnostic msg: /var/folders/bh/cdl3cft92_dbvg852_fp7y7w0000gn/T/linker-crash-29e6d3
          clang: note: diagnostic msg: 
          
          ********************
          

[RUSTC-TIMING] yoke_derive test:false 1.947

@rust-bors rust-bors Bot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 23, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 23, 2026
@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 7f16348 failed: CI. Failed job:

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

A linker segfaulted, that seems unlikely to be related
@bors retry
@bors try jobs=dist-aarch64-apple

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 23, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 23, 2026
remove AliasTy::def_id()


try-job: dist-aarch64-apple
@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c5e14b4 (c5e14b4b76201f9351f76197eebc367db9b0ff54)
Base parent: 4429659 (4429659e4745016bd3f26a4a421843edc7fbc422)

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: BoxyUwU
Duration: 3h 35m 13s
Pushing f28ac76 to main...

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 23, 2026
@rust-bors rust-bors Bot merged commit f28ac76 into rust-lang:main Jun 23, 2026
15 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 4429659 (parent) -> f28ac76 (this PR)

Test differences

Show 56 test diffs

56 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard f28ac764c36004fa6a6e098d15b4016a838c13c6 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-llvm-22-1: 43m 56s -> 1h 12m (+65.5%)
  2. aarch64-apple: 2h 21m -> 3h 28m (+47.2%)
  3. i686-gnu-2: 1h 37m -> 53m 17s (-45.4%)
  4. dist-aarch64-apple: 1h 50m -> 2h 29m (+34.9%)
  5. dist-apple-various: 1h 50m -> 2h 27m (+33.5%)
  6. i686-gnu-1: 2h 19m -> 1h 38m (-29.6%)
  7. x86_64-msvc-1: 2h 43m -> 1h 55m (-29.4%)
  8. dist-x86_64-llvm-mingw: 1h 31m -> 1h 56m (+28.0%)
  9. dist-various-1: 59m 38s -> 1h 13m (+23.9%)
  10. dist-x86_64-apple: 1h 59m -> 2h 28m (+23.5%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f28ac76): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary -3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-4.8%, -1.9%] 11
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 504.341s -> 510.446s (1.21%)
Artifact size: 353.08 MiB -> 353.05 MiB (-0.01%)

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

Labels

merged-by-bors This PR was explicitly merged by bors. 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.

8 participants