Skip to content

view-types: propagate view types to rustc_middle - #159291

Draft
scrabsha wants to merge 1 commit into
rust-lang:mainfrom
scrabsha:view-types/in-mir
Draft

view-types: propagate view types to rustc_middle#159291
scrabsha wants to merge 1 commit into
rust-lang:mainfrom
scrabsha:view-types/in-mir

Conversation

@scrabsha

@scrabsha scrabsha commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

⚠️ this PR is big and boring and need self-review. review from other people is welcome, but it is probably not worth your time (at least in its current state) ⚠️

TODO:

  • PR description
  • tracking issue
  • maybe some tests?

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 14, 2026
@rust-log-analyzer

This comment has been minimized.

@scrabsha
scrabsha force-pushed the view-types/in-mir branch from e9822b0 to 4600dd1 Compare July 14, 2026 14:42
@rust-log-analyzer

This comment has been minimized.

@scrabsha
scrabsha force-pushed the view-types/in-mir branch from 4600dd1 to e2963ed Compare July 14, 2026 15:28
@rust-log-analyzer

This comment has been minimized.

@scrabsha
scrabsha force-pushed the view-types/in-mir branch from e2963ed to 15cc52f Compare July 15, 2026 09:44
@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Jul 15, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@scrabsha
scrabsha force-pushed the view-types/in-mir branch from 26818c0 to 8a1ca0e Compare July 27, 2026 20:01
@rust-log-analyzer

This comment has been minimized.

@scrabsha
scrabsha force-pushed the view-types/in-mir branch from 8a1ca0e to 26b0846 Compare July 28, 2026 09:38
/// Returns the type of the discriminant of this type.
pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match self.kind() {
// It is somewhat guaranteed that view types

@scrabsha scrabsha Jul 30, 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.

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159836) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

@scrabsha

scrabsha commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

discussed privately with @oli-obk : we want to model the set of viewed fields as a type. something like:

enum TyKind {
    View(AdtDef, GenericArgs, Ty),
}

the Ty field would be either an inferred type, or a tuple: (FieldRepresentingType<Foo, FIRST_VARIANT, 0>, Foo<FIRST_VARIANT, 1>) would represent Foo.{ first_field, second_field }. this is handy because it makes viewed field set inference trivial: instaed of adding a new inference variable just for view types, we can leverage the already-existing and super cool type inference algorithms and just relate types in order to infer the set of viewed fields. cool stuff!!

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc 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.

3 participants