Skip to content

Tracking Issue for view types #155938

@scrabsha

Description

@scrabsha

This is a tracking issue for experimenting on the concept of view types. The feature gate for the issue is #![feature(view_types)].

Description of the feature

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.

The goal for now is to support the following:

struct Foo {
    a: usize,
    b: usize,
}

fn bar(a: &mut Foo.{ a }, b: &mut Foo.{ b }) {
    a.a += 1;
    b.b += 1;
}

fn main() {
    let mut foo = Foo { a: 0, b: 0 };
    bar(&mut foo, &mut foo);
}

The syntax described in Maximally minimal view types, a follow-up is used here, but it will certainly change during the experiment.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps

Unresolved Questions

Implementation history

Metadata

Metadata

Assignees

Labels

B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions