Skip to content

view-types: better documentation for View variant - #166241

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scrabsha:view-types/better-documentation-view-variant
Nov 20, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scrabsha:view-types/better-documentation-view-variant

Conversation

@scrabsha

@scrabsha scrabsha commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

asked in #t-types > View types experiment.

part of #155938.

r? @oli-obk
cc @jackh726

Note

AI:0 AI:0 I've not used an LLM for any part of this PR, this includes any related work like research.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 20, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 20, 2026
@scrabsha scrabsha mentioned this pull request Nov 20, 2026
4 of 15 tasks

@oli-obk oli-obk 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.

@rust-bors

rust-bors Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit dbea82c has been approved by oli-obk

It is now in the queue for this repository.

@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 Nov 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 20, 2026
…tation-view-variant, r=oli-obk

view-types: better documentation for View variant
rust-bors Bot pushed a commit that referenced this pull request Nov 20, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #157721 (compiletest: Add testing for lint machinery at runtime)
 - #153746 (rustdoc: add emoji icons for unstable and deprecated to search results)
 - #164378 (RISC-V: enable relax target feature by default)
 - #166241 (view-types: better documentation for View variant)
 - #166246 (Add rustdoc-ui tests for (some) malformed doc attributes)
@jackh726

Copy link
Copy Markdown
Member

This is a good start, but I do not think this really satisfies my concern. I don't have a good notion of what this TyKind variant is for (I could certainly hazard a guess that would probably be correct - but that's not necessarily true for others).

Some questions that were previously answered for both pattern types and unsafe binders prior to MCP acceptance:

  • how are these types created
  • what does subtyping look like for these?
  • can you implement traits for these?

In general, it would also be good to know:

  • What is the information contained in this variant going to be used for?
  • Are there alternatives to adding a new variant (for example, you could almost imagine this being a Pattern type variant)

@rust-bors
rust-bors Bot merged commit a1f1f49 into rust-lang:main Nov 20, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 20, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 20, 2026
Rollup merge of #166241 - scrabsha:view-types/better-documentation-view-variant, r=oli-obk

view-types: better documentation for View variant
@scrabsha
scrabsha deleted the view-types/better-documentation-view-variant branch November 20, 2026 16:59
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 23, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#157721 (compiletest: Add testing for lint machinery at runtime)
 - rust-lang/rust#153746 (rustdoc: add emoji icons for unstable and deprecated to search results)
 - rust-lang/rust#164378 (RISC-V: enable relax target feature by default)
 - rust-lang/rust#166241 (view-types: better documentation for View variant)
 - rust-lang/rust#166246 (Add rustdoc-ui tests for (some) malformed doc attributes)
@oli-obk

oli-obk commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

how are these types created

That's documented on the variant

what does subtyping look like for these?

The same as for Adts, but equality for the field list. All this is experimental, so writing it down where it will diverge isn't too useful.

can you implement traits for these?

There are def traits implemented for them. If the question is whether you can have manual impls, then just like all other types, yes, tho caveats may apply that don't belong on the TyKind variant.

What is the information contained in this variant going to be used for?

That's fairly clearly documented, even the format of how that's encoded is.

Are there alternatives to adding a new variant (for example, you could almost imagine this being a Pattern type variant)

Yes, but again, that doesn't belong here. We decided that encoding this in fancy ways as another language item adt was not appropriate. It may be in the future, but mixing them up with pattern types or Adts while the semantics aren't figured out fully is asking for trouble. We'll miss cases or have to take a lot of care not to affect stable semantics of Adts.

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

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants