-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Refactor AliasTy. AliasTerm & UnevaluatedConst to use Alias
#156538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rust-bors
merged 2 commits into
rust-lang:main
from
Jamesbarford:chore/merge-AliasTy-AliasTerm
Jun 16, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| use derive_where::derive_where; | ||
| #[cfg(feature = "nightly")] | ||
| use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash_NoContext}; | ||
| use rustc_type_ir_macros::{ | ||
| GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic, | ||
| }; | ||
|
|
||
| use crate::predicate::AliasTermKind; | ||
| use crate::ty_kind::AliasTyKind; | ||
| use crate::{Interner, UnevaluatedConstKind}; | ||
|
|
||
| /// Represents an alias of a type, constant, or other term-like item. | ||
| /// | ||
| /// * For a projection, this would be `<Ty as Trait<...>>::N<...>`. | ||
| /// * For an inherent projection, this would be `Ty::N<...>`. | ||
| /// * For an opaque type, there is no explicit syntax. | ||
| #[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner, K)] | ||
| #[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic, Lift_Generic)] | ||
| #[cfg_attr( | ||
| feature = "nightly", | ||
| derive(Decodable_NoContext, Encodable_NoContext, StableHash_NoContext) | ||
| )] | ||
| pub struct Alias<I: Interner, K> { | ||
| pub kind: K, | ||
|
|
||
| /// The parameters of the associated, opaque, or constant alias. | ||
| /// | ||
| /// For a projection, these are the generic parameters for the trait and the | ||
| /// GAT parameters, if there are any. | ||
| /// | ||
| /// For an inherent projection, they consist of the self type and the GAT parameters, | ||
| /// if there are any. | ||
| /// | ||
| /// For RPIT the generic parameters are for the generics of the function, | ||
| /// while for TAIT it is used for the generic parameters of the alias. | ||
| pub args: I::GenericArgs, | ||
|
|
||
| /// This field exists to prevent the creation of `Alias` without using the relevant constructor. | ||
| #[derive_where(skip(Debug))] | ||
| #[type_visitable(ignore)] | ||
| #[type_foldable(identity)] | ||
| #[lift(identity)] | ||
| pub(crate) _use_alias_new_instead: (), | ||
| } | ||
|
|
||
| impl<I: Interner, K: PartialEq> Eq for Alias<I, K> {} | ||
|
|
||
| impl<I: Interner, K: Copy> Alias<I, K> { | ||
| pub fn kind(self, _interner: I) -> K { | ||
| self.kind | ||
| } | ||
| } | ||
|
|
||
| pub type AliasTerm<I> = Alias<I, AliasTermKind<I>>; | ||
| pub type AliasTy<I> = Alias<I, AliasTyKind<I>>; | ||
| pub type UnevaluatedConst<I> = Alias<I, UnevaluatedConstKind<I>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| mod alias; | ||
|
|
||
| pub use alias::{Alias, AliasTerm, AliasTy, UnevaluatedConst}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not work? 🤔
does
AliasimplementDebugin a weird way?View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope 😞.
TypeVisitable_GenericcreatesAlias<I, K>: TypeVisitable<I>and;So can prove
Alias<I, K>: fmt::Debugbut notK: DebugError;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annoying 😭 alright, r=me if CI passes