Skip to content

Add feature gate for view_types experiment#155939

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
scrabsha:view-types/feature-gate
May 1, 2026
Merged

Add feature gate for view_types experiment#155939
rust-bors[bot] merged 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
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 30, 2026
…r=nikomatsakis

Add feature gate for view_types experiment
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 30, 2026
…r=nikomatsakis

Add feature gate for view_types experiment
rust-bors Bot pushed a commit that referenced this pull request Apr 30, 2026
Rollup of 6 pull requests

Successful merges:

 - #155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets)
 - #155939 (Add feature gate for view_types experiment)
 - #155974 (add `c_variadic_experimental_arch` feature)
 - #155523 (Reorganize `tests/ui/issues/` - 02)
 - #155980 (Move `feature*` methods from `parse` mod to `errors` mod.)
 - #155987 (Make lifting infallible)

Failed merges:

 - #155237 (Disentangle AST crates and error crates)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 30, 2026
…r=nikomatsakis

Add feature gate for view_types experiment
rust-bors Bot pushed a commit that referenced this pull request Apr 30, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #155249 (Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup)
 - #155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets)
 - #155919 (simplify `ast_fragments!`)
 - #155939 (Add feature gate for view_types experiment)
 - #155974 (add `c_variadic_experimental_arch` feature)
 - #155991 (Catch unwinds from the global ctxt callback to complete queries profiling data in more cases)
 - #156003 (Pass Session to optimize_and_codegen_fat_lto)
 - #153566 (Add suggestion for E0401 on inner const items)
 - #154610 (Suggest public re-exports when a private module makes an import path inaccessible)
 - #155523 (Reorganize `tests/ui/issues/` - 02)
 - #155980 (Move `feature*` methods from `parse` mod to `errors` mod.)
 - #155987 (Make lifting infallible)
 - #155988 (tests/run-make/print-cfg: add Android target_env case)
rust-bors Bot pushed a commit that referenced this pull request May 1, 2026
Rollup of 19 pull requests

Successful merges:

 - #155237 (Disentangle AST crates and error crates)
 - #155249 (Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup)
 - #155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets)
 - #155919 (simplify `ast_fragments!`)
 - #155939 (Add feature gate for view_types experiment)
 - #155954 (rustdoc: preserve parent doc cfg for `macro_export` macros)
 - #155974 (add `c_variadic_experimental_arch` feature)
 - #155991 (Catch unwinds from the global ctxt callback to complete queries profiling data in more cases)
 - #156003 (Pass Session to optimize_and_codegen_fat_lto)
 - #153566 (Add suggestion for E0401 on inner const items)
 - #154610 (Suggest public re-exports when a private module makes an import path inaccessible)
 - #155523 (Reorganize `tests/ui/issues/` - 02)
 - #155821 (c-variadic: document `Clone` and `Drop` instances and require `VaArgSafe: Copy`)
 - #155980 (Move `feature*` methods from `parse` mod to `errors` mod.)
 - #155987 (Make lifting infallible)
 - #155988 (tests/run-make/print-cfg: add Android target_env case)
 - #156000 (Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld)
 - #156002 (Allow to use `Diagnostic` directly in `SharedContext::emit_lint`)
 - #156015 (rustc-dev-guide subtree update)
@rust-bors rust-bors Bot merged commit f7b1e7d into rust-lang:main May 1, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 1, 2026
@scrabsha scrabsha deleted the view-types/feature-gate branch May 1, 2026 07:43
rust-timer added a commit that referenced this pull request May 1, 2026
Rollup merge of #155939 - scrabsha:view-types/feature-gate, r=nikomatsakis

Add feature gate for view_types experiment
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request May 4, 2026
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155237 (Disentangle AST crates and error crates)
 - rust-lang/rust#155249 (Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup)
 - rust-lang/rust#155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets)
 - rust-lang/rust#155919 (simplify `ast_fragments!`)
 - rust-lang/rust#155939 (Add feature gate for view_types experiment)
 - rust-lang/rust#155954 (rustdoc: preserve parent doc cfg for `macro_export` macros)
 - rust-lang/rust#155974 (add `c_variadic_experimental_arch` feature)
 - rust-lang/rust#155991 (Catch unwinds from the global ctxt callback to complete queries profiling data in more cases)
 - rust-lang/rust#156003 (Pass Session to optimize_and_codegen_fat_lto)
 - rust-lang/rust#153566 (Add suggestion for E0401 on inner const items)
 - rust-lang/rust#154610 (Suggest public re-exports when a private module makes an import path inaccessible)
 - rust-lang/rust#155523 (Reorganize `tests/ui/issues/` - 02)
 - rust-lang/rust#155821 (c-variadic: document `Clone` and `Drop` instances and require `VaArgSafe: Copy`)
 - rust-lang/rust#155980 (Move `feature*` methods from `parse` mod to `errors` mod.)
 - rust-lang/rust#155987 (Make lifting infallible)
 - rust-lang/rust#155988 (tests/run-make/print-cfg: add Android target_env case)
 - rust-lang/rust#156000 (Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld)
 - rust-lang/rust#156002 (Allow to use `Diagnostic` directly in `SharedContext::emit_lint`)
 - rust-lang/rust#156015 (rustc-dev-guide subtree update)
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