Skip to content

Conversation

@Jamesbarford
Copy link
Contributor

r? ghost

@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Dec 22, 2025
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford Jamesbarford force-pushed the chore/refactor-struct-placeholder-pt2 branch from 753b92c to 2077c6b Compare December 30, 2025 08:41
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

pub enum GenericKind<'tcx> {
Param(ty::ParamTy),
Placeholder(ty::PlaceholderType<'tcx>),
Placeholder(ty::PlaceholderType<TyCtxt<'tcx>>),
Copy link
Contributor

Choose a reason for hiding this comment

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

there are currently a bunch of spurious edits + outdated formatting things here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Woops, yes, I'm sorting things out bit by bit. I'll squash all the commits when I'm done and remove the odd edits and commented out code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm getting the following error and I'm not too sure why as I'm using #[derive_where(HashStable_NoContext)];

error[E0599]: the method `hash_stable` exists for reference `&binder::BoundRegion<I>`, but its trait bounds were not satisfied
    --> compiler/rustc_type_ir/src/region_kind.rs:228:19
     |
 228 |                 r.hash_stable(hcx, hasher);
     |                   ^^^^^^^^^^^ method cannot be called on `&binder::BoundRegion<I>` due to unsatisfied trait bounds
     |
    ::: compiler/rustc_type_ir/src/binder.rs:1014:1
     |
1014 | pub enum BoundRegionKind<I: Interner> {
     | ------------------------------------- doesn't satisfy `BoundRegionKind<I>: HashStable<_>`
...
1083 | pub struct BoundRegion<I: Interner> {
     | ----------------------------------- doesn't satisfy `binder::BoundRegion<I>: HashStable<_>`
     |
     = note: trait bound `BoundRegionKind<I>: HashStable<_>` was not satisfied
     = note: the following trait bounds were not satisfied:
             `binder::BoundRegion<I>: HashStable<_>`
             which is required by `&binder::BoundRegion<I>: HashStable<_>`
note: the trait `HashStable` must be implemented
    --> /rust/compiler/rustc_data_structures/src/stable_hasher.rs:44:1
     |
  44 | pub trait HashStable<CTX> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: the method `hash_stable` exists for reference `&binder::Placeholder<I, binder::BoundRegion<I>>`, but its trait bounds were not satisfied
    --> compiler/rustc_type_ir/src/region_kind.rs:237:19
     |
 237 |                 r.hash_stable(hcx, hasher);
     |                   ^^^^^^^^^^^ method cannot be called on `&binder::Placeholder<I, binder::BoundRegion<I>>` due to unsatisfied trait bounds
     |
    ::: compiler/rustc_type_ir/src/binder.rs:969:1
     |
 969 | pub struct Placeholder<I: Interner, T> {
     | -------------------------------------- doesn't satisfy `_: HashStable<_>`
...
1083 | pub struct BoundRegion<I: Interner> {
     | ----------------------------------- doesn't satisfy `binder::BoundRegion<I>: HashStable<_>`
     |
     = note: trait bound `binder::BoundRegion<I>: HashStable<_>` was not satisfied
     = note: the following trait bounds were not satisfied:
             `binder::Placeholder<I, binder::BoundRegion<I>>: HashStable<_>`
             which is required by `&binder::Placeholder<I, binder::BoundRegion<I>>: HashStable<_>`
note: the trait `HashStable` must be implemented
    --> /rust/compiler/rustc_data_structures/src/stable_hasher.rs:44:1
     |
  44 | pub trait HashStable<CTX> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^

@rust-log-analyzer

This comment has been minimized.

origin: infer::SubregionOrigin<'tcx>,
region: ty::Region<'tcx>,
placeholder_ty: ty::PlaceholderType<'tcx>,
placeholder_ty: ty::PlaceholderType<TyCtxt<'tcx>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

// fn new(var: BoundVar, kind: BoundRegionKind) -> Self {
// Self { var, kind }
// }
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

yeet :3

Comment on lines 19 to 20
mapped_regions: IndexMap<I::PlaceholderRegion, ty::BoundRegion>,
mapped_types: IndexMap<I::PlaceholderTy, ty::BoundTy>,
Copy link
Contributor

Choose a reason for hiding this comment

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

why does PlaceholderRegion and PlaceholderTy still exist? 🤔

Comment on lines 959 to 964
#[derive_where(Clone, Ord, Hash; I: Interner, T)]
#[derive_where(PartialOrd; I: Interner, T: Ord)]
#[derive_where(Copy; I: Interner, T: Copy, T)]
#[derive_where(Eq; T)]
#[derive_where(PartialEq; T)]
Copy link
Contributor

Choose a reason for hiding this comment

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

what's going on there. Why do we sometimes not require I: Interner. Having just T there seems odd and unnecessary?


pub type PlaceholderConst<I: Interner> = ty::Placeholder<I, BoundConst>;

impl<I: Interner> PlaceholderLike<I> for PlaceholderConst<I> {
Copy link
Contributor

Choose a reason for hiding this comment

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

no longer need the trait, can just use inherent methods now

type ParamTy: ParamLike;
type BoundTy: BoundVarLike<Self>;
type PlaceholderTy: PlaceholderLike<Self, Bound = Self::BoundTy>;
type PlaceholderTy: PlaceholderLike<Self, Bound = ty::BoundTy<Self>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

should also be removed

@lcnr
Copy link
Contributor

lcnr commented Jan 5, 2026

The reason HashStable isn't implemented is kinda stupid.

HashStable_NoContext is a "perfect derive", i.e. we simply add where-clauses that each field implements the trait. This means the derive for BoundRegionKind adds I::DefId: HasHStable<CTX> and I::Symbol: HashStable<CTX>. These are then considered to not hold in the manual impl. Though tbf, I don't get why the manual impl exists at all.

Try to replace the manual impl with a derive and see if anything breaks. If it does break, add I::DefId: HashStable<CTX> and I::Symbol: HashStable<CTX> to the manual impl

@Jamesbarford Jamesbarford force-pushed the chore/refactor-struct-placeholder-pt2 branch from d262f5c to d36238d Compare January 13, 2026 11:42
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford Jamesbarford force-pushed the chore/refactor-struct-placeholder-pt2 branch from d36238d to a03a907 Compare January 13, 2026 13:29
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford Jamesbarford force-pushed the chore/refactor-struct-placeholder-pt2 branch from a03a907 to b4de573 Compare January 15, 2026 14:43
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 6649 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [style (compiler)]: /checkout/compiler/rustc_type_ir/src/binder.rs:1027: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
tidy [style (compiler)]: /checkout/compiler/rustc_type_ir/src/binder.rs:1054: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
tidy [style (compiler)]: FAIL
tidy: The following check failed: style (compiler)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 yarn` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1357:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:00:54
  local time: Thu Jan 15 14:50:37 UTC 2026
  network time: Thu, 15 Jan 2026 14:50:38 GMT
##[error]Process completed with exit code 1.

}

impl Rvalue {
impl<'tcx> Rvalue<'tcx> {
Copy link
Contributor

Choose a reason for hiding this comment

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

rustc_public should use owned values everywhere

pub enum RegionKind<'tcx> {
ReEarlyParam(EarlyParamRegion),
ReBound(DebruijnIndex, BoundRegion),
ReBound(DebruijnIndex, BoundRegion<'tcx>),
Copy link
Contributor

Choose a reason for hiding this comment

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

instead duplicate the BoundRegion struct in rustc_public

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

Labels

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. 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