Skip to content

Add feature gate for view_types experiment#155939

Open
scrabsha wants to merge 2 commits intorust-lang:mainfrom
scrabsha:view-types/feature-gate
Open

Add feature gate for view_types experiment#155939
scrabsha wants to merge 2 commits intorust-lang:mainfrom
scrabsha:view-types/feature-gate

Conversation

@scrabsha
Copy link
Copy Markdown
Contributor

@scrabsha scrabsha commented Apr 28, 2026

View all comments

Tracking issue: #155938

The goal of this feature is to experiment with the concept of view types: allowing the borrow checker to reason about borrows across function calls by having an syntax to express which fields of a struct are used by a function.

This will have the following limitations:

  • Usage of view types on pub or pub(...) functions is a hard error.
  • View groups are not considered at the moment.
  • Interaction with pattern types are not considered at the moment.

r? nikomatsakis

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 28, 2026
@scrabsha scrabsha mentioned this pull request Apr 28, 2026
8 tasks
@nikomatsakis
Copy link
Copy Markdown
Contributor

@rustbot label +I-lang-nominated

Hi y'all, I am starting up a lang-team experiment on view types as champion.

Also cc @rust-lang/types and @lqd in particular

@rustbot rustbot added the I-lang-nominated Nominated for discussion during a lang team meeting. label Apr 28, 2026
Copy link
Copy Markdown
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Comment thread tests/ui/feature-gates/feature-gate-view-types.rs
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@scrabsha scrabsha force-pushed the view-types/feature-gate branch from 711ae3e to d3992fa Compare April 28, 2026 21:57
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 28, 2026
Comment thread tests/ui/feature-gates/feature-gate-view-types.rs Outdated
@traviscross traviscross added P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Apr 29, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 29, 2026

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@nikomatsakis
Copy link
Copy Markdown
Contributor

We discussed this in the @rust-lang/lang meeting today. My recollection is generally positive vibes and excitement.

Copy link
Copy Markdown
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Comment thread tests/ui/feature-gates/feature-gate-view-types.rs Outdated
Comment thread tests/ui/feature-gates/feature-gate-view-types.rs
Comment thread tests/ui/feature-gates/feature-gate-view-types.rs
let view_end_span = self.prev_token.span;
let span = view_start_span.to(view_end_span);
self.psess.gated_spans.gate(sym::view_types, span);
}
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.

ok, so, right now we are effectively discarding the .{...} syntax. Seems ok for the first PR.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 29, 2026
Comment thread compiler/rustc_parse/src/parser/ty.rs Outdated
@scrabsha scrabsha force-pushed the view-types/feature-gate branch from e433590 to 77fb8d1 Compare April 29, 2026 18:15
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 29, 2026
@nikomatsakis
Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 29, 2026

📌 Commit 77fb8d1 has been approved by nikomatsakis

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 Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-radar Items that are on lang's radar and will need eventual work or consideration. 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.

6 participants