Skip to content

Move struct placeholder pt2 - #150271

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Jamesbarford:chore/refactor-struct-placeholder-pt2
Jan 29, 2026
Merged

Move struct placeholder pt2#150271
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Jamesbarford:chore/refactor-struct-placeholder-pt2

Conversation

@Jamesbarford

Copy link
Copy Markdown
Contributor

r? ghost

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

Comment threadcompiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs Outdated
@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from 753b92c to 2077c6bCompareDecember 30, 2025 08:41
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_infer/src/infer/region_constraints/mod.rs Outdated
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_infer/src/infer/outlives/obligations.rs Outdated
Comment threadcompiler/rustc_middle/src/ty/region.rs Outdated
Comment threadcompiler/rustc_next_trait_solver/src/placeholder.rs Outdated
Comment threadcompiler/rustc_type_ir/src/binder.rs Outdated
Comment threadcompiler/rustc_type_ir/src/binder.rs Outdated
Comment threadcompiler/rustc_type_ir/src/interner.rs Outdated
@lcnr

lcnr commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

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
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from d262f5c to d36238dCompareJanuary 13, 2026 11:42
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from d36238d to a03a907CompareJanuary 13, 2026 13:29
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from a03a907 to b4de573CompareJanuary 15, 2026 14:43
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_public/src/mir/body.rs Outdated
Comment threadcompiler/rustc_public/src/ty.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from 044bbd5 to cdff0b9CompareJanuary 19, 2026 12:01
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs Outdated
@rust-log-analyzer

This comment has been minimized.

fn lift_to_interner(self, cx: U) -> Option<Self::Lifted> {
Some(BoundTy { var: self.var, kind: self.kind.lift_to_interner(cx)? })
}
}

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.

why can this one not be derived?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I get this error without the implementation;

error[E0277]: the trait bound `BoundTy<TyCtxt<'_>>: Lift<TyCtxt<'tcx>>` is not satisfied
--> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:59
|
672 | GenericKind::Placeholder(ref p) => write!(f, "{p}"),
| -----------^^^--
| | |
| | unsatisfied trait bound
| in this macro invocation (#1)
|
--> /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/macros/mod.rs:610:0
|
= note: in this expansion of `write!` (#1)
::: /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/macros/mod.rs:612:23
|
= note: in this macro invocation (#2)
::: /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/macros/mod.rs:997:4
|
= note: in this expansion of `$crate::format_args!` (#2)
|
= help: the nightly-only, unstable trait `for<'tcx> Lift<rustc_middle::ty::TyCtxt<'tcx>>` is not implemented for `BoundTy<rustc_middle::ty::TyCtxt<'_>>`
= help: the following other types implement trait `Lift<I>`:
`&RawList<(), BoundVariableKind<TyCtxt<'a>>>` implements `Lift<rustc_middle::ty::TyCtxt<'tcx>>`
`&RawList<(), GenericArg<'a>>` implements `Lift<rustc_middle::ty::TyCtxt<'tcx>>`
`&RawList<(), Ty<'a>>` implements `Lift<rustc_middle::ty::TyCtxt<'tcx>>`
`&RawList<(), Binder<TyCtxt<'a>, ...>>` implements `Lift<rustc_middle::ty::TyCtxt<'tcx>>`
`()` implements `Lift<rustc_middle::ty::TyCtxt<'tcx>>`
`AliasTerm<I>` implements `Lift<J>`
`AliasTy<I>` implements `Lift<J>`
`AllocId` implements `Lift<rustc_middle::ty::TyCtxt<'tcx>>`
and 68 others
= note: required for `Placeholder<TyCtxt<'_>, BoundTy<TyCtxt<'_>>>` to implement `for<'tcx> Lift<rustc_middle::ty::TyCtxt<'tcx>>`
= note: required for `rustc_middle::ty::TyCtxt<'_>` to implement `IrPrint<Placeholder<TyCtxt<'_>, BoundTy<...>>>`
= note: required for `Placeholder<TyCtxt<'_>, BoundTy<TyCtxt<'_>>>` to implement `std::fmt::Display`
= note: 1 redundant requirement hidden
= note: required for `&Placeholder<TyCtxt<'_>, BoundTy<TyCtxt<'_>>>` to implement `std::fmt::Display`
= note: the full name for the type has been written to '/home/jambar02/Documents/arm/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_infer-29c3d638b97358db.long-type-10995706924995725161.txt'
= note: consider using `--verbose` to print the full type name to the console

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.

without the manual implementation but with a derive?

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.

as in, using Lift_Generic

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I get the same error when doing;

#[derive_where(Clone,Copy,PartialEq,Eq,Hash;I:Interner)]#[derive(Lift_Generic)]#[cfg_attr( feature = "nightly", derive(Encodable_NoContext,Decodable_NoContext,HashStable_NoContext))]pubstructBoundTy<I:Interner>{pubvar: ty::BoundVar,pubkind:BoundTyKind<I>,}

@lcnrlcnrJan 27, 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.

that might be as BoundVar doesn't implement Lift.

Does only deriving it for BoundRegionKind also error? The same with its HashStable impl

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Doing it for BoundRegionKind allowed me to then also do it for BoundVariableKind and BoundTyKind.

type BoundTy: BoundVarLike<Self>;
type PlaceholderTy: PlaceholderLike<Self, Bound = Self::BoundTy>;
type Symbol: Copy + Hash + PartialEq + Eq + Debug;
type Symbol: Copy + Hash + PartialEq + Eq + Debug + Symbol<Self>;

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.

please move all these item bounds to be super traits of Symbol instead

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.

not actually resolved 😅

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I didn't push my changes 🤦

@lcnrlcnr left a comment

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.

nits, then r=me

also, for future PRs. It would have been good to keep the BoundRegionKind::NamedForPrinting rename in a separate commit as that one isn't strictly related to the other changes

View changes since this review

@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch 2 times, most recently from 8387fa4 to 267fa27CompareJanuary 27, 2026 12:09
Comment threadcompiler/rustc_type_ir/src/binder.rs Outdated
Comment threadcompiler/rustc_type_ir/src/binder.rs Outdated
@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from 267fa27 to 9f0791eCompareJanuary 29, 2026 08:34

@lcnrlcnr left a comment

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.

Comment threadcompiler/rustc_type_ir/src/binder.rs Outdated
@lcnr

lcnr commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

@bors delegate+

@rust-bors

rust-borsBot commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

✌️ @Jamesbarford, you can now approve this pull request!

If @lcnr told you to "r=me" after making some further change, then please make that change and post @bors r=lcnr.

@Jamesbarford
Jamesbarfordforce-pushed the chore/refactor-struct-placeholder-pt2 branch from 9f0791e to 25c1365CompareJanuary 29, 2026 11:12
@Jamesbarford

Copy link
Copy Markdown
ContributorAuthor

@bors r=lcnr

@rust-bors

rust-borsBot commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 25c1365 has been approved by lcnr

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 Jan 29, 2026
rust-borsBot pushed a commit that referenced this pull request Jan 29, 2026
…uwer
Rollup of 8 pull requests
Successful merges:
- #147387 (hir_owner_parent optimized to inlined call for non-incremental build)
- #150271 (Move struct placeholder pt2)
- #151283 (Suggest ignore returning value inside macro for unused_must_use lint)
- #151565 (Rename, clarify, and document code for "erasing" query values)
- #149482 (thread::scope: document how join interacts with TLS destructors)
- #151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
- #151833 (Treat unions as 'data types' in attr parsing diagnostics)
- #151834 (Update `askama` version to `0.15.4`)
@rust-bors
rust-borsBot merged commit 40d7cb8 into rust-lang:mainJan 29, 2026
11 checks passed
@rustbotrustbot added this to the 1.95.0 milestone Jan 29, 2026
rust-timer added a commit that referenced this pull request Jan 29, 2026
Rollup merge of #150271 - Jamesbarford:chore/refactor-struct-placeholder-pt2, r=lcnr
Move struct placeholder pt2
r? ghost
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 12, 2026
…-placeholder-pt2, r=lcnr
Move struct placeholder pt2
r? ghost
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 19, 2026
…uwer
Rollup of 8 pull requests
Successful merges:
- rust-lang/rust#147387 (hir_owner_parent optimized to inlined call for non-incremental build)
- rust-lang/rust#150271 (Move struct placeholder pt2)
- rust-lang/rust#151283 (Suggest ignore returning value inside macro for unused_must_use lint)
- rust-lang/rust#151565 (Rename, clarify, and document code for "erasing" query values)
- rust-lang/rust#149482 (thread::scope: document how join interacts with TLS destructors)
- rust-lang/rust#151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
- rust-lang/rust#151833 (Treat unions as 'data types' in attr parsing diagnostics)
- rust-lang/rust#151834 (Update `askama` version to `0.15.4`)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 19, 2026
…uwer
Rollup of 8 pull requests
Successful merges:
- rust-lang/rust#147387 (hir_owner_parent optimized to inlined call for non-incremental build)
- rust-lang/rust#150271 (Move struct placeholder pt2)
- rust-lang/rust#151283 (Suggest ignore returning value inside macro for unused_must_use lint)
- rust-lang/rust#151565 (Rename, clarify, and document code for "erasing" query values)
- rust-lang/rust#149482 (thread::scope: document how join interacts with TLS destructors)
- rust-lang/rust#151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
- rust-lang/rust#151833 (Treat unions as 'data types' in attr parsing diagnostics)
- rust-lang/rust#151834 (Update `askama` version to `0.15.4`)
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 27, 2026
…uwer
Rollup of 8 pull requests
Successful merges:
- rust-lang/rust#147387 (hir_owner_parent optimized to inlined call for non-incremental build)
- rust-lang/rust#150271 (Move struct placeholder pt2)
- rust-lang/rust#151283 (Suggest ignore returning value inside macro for unused_must_use lint)
- rust-lang/rust#151565 (Rename, clarify, and document code for "erasing" query values)
- rust-lang/rust#149482 (thread::scope: document how join interacts with TLS destructors)
- rust-lang/rust#151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
- rust-lang/rust#151833 (Treat unions as 'data types' in attr parsing diagnostics)
- rust-lang/rust#151834 (Update `askama` version to `0.15.4`)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
…uwer
Rollup of 8 pull requests
Successful merges:
- rust-lang/rust#147387 (hir_owner_parent optimized to inlined call for non-incremental build)
- rust-lang/rust#150271 (Move struct placeholder pt2)
- rust-lang/rust#151283 (Suggest ignore returning value inside macro for unused_must_use lint)
- rust-lang/rust#151565 (Rename, clarify, and document code for "erasing" query values)
- rust-lang/rust#149482 (thread::scope: document how join interacts with TLS destructors)
- rust-lang/rust#151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
- rust-lang/rust#151833 (Treat unions as 'data types' in attr parsing diagnostics)
- rust-lang/rust#151834 (Update `askama` version to `0.15.4`)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-clippyRelevant to the Clippy team.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Jamesbarford@rust-log-analyzer@lcnr@rustbot