-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
view-types: HIR lowering #158739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
view-types: HIR lowering #158739
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5e4558e
view-types: add a bunch of tests
scrabsha 9ee193e
view-types: lower view types to HIR
scrabsha 09b43e4
view-types: error when viewing the same field twice
scrabsha 55ab4c7
view-types: error when used on non-struct types
scrabsha 1390f89
view-types: resolve viewed fields
scrabsha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -411,6 +411,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { | |
| Infer, | ||
| Pat, | ||
| FieldOf, | ||
| View, | ||
| Err | ||
| ] | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //@ edition:2015 | ||
|
|
||
| #![feature(view_types, view_type_macro)] | ||
|
|
||
| pub use std::view::view_type; | ||
|
|
||
| #[macro_export] | ||
| macro_rules! view_bar { | ||
| () => { | ||
| $crate::view_type!(Bar.{ async }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #![feature(view_types, view_type_macro)] | ||
| #![allow(unused)] | ||
|
|
||
| use std::view::view_type; | ||
|
|
||
| struct Foo { | ||
| bar: usize, | ||
| } | ||
|
|
||
| struct Pair(usize); | ||
|
|
||
| fn f( | ||
| _foo: &mut view_type!(Foo.{ bar, bar }), | ||
| //~^ ERROR field `bar` is already part of the view | ||
| _pair: &mut view_type!(Pair.{ 0, 0 }), | ||
| //~^ ERROR field `0` is already part of the view | ||
| ) { | ||
| } | ||
|
|
||
| impl Foo { | ||
| fn f(self: &mut view_type!(Self.{ bar, bar })) {} | ||
| //~^ ERROR field `bar` is already part of the view | ||
| } | ||
|
|
||
| impl Pair { | ||
| fn f(self: &mut view_type!(Self.{ 0, 0 })) {} | ||
| //~^ ERROR field `0` is already part of the view | ||
| } | ||
|
|
||
| fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| error: field `bar` is already part of the view | ||
| --> $DIR/duplicate_field.rs:13:38 | ||
| | | ||
| LL | _foo: &mut view_type!(Foo.{ bar, bar }), | ||
| | --- ^^^ | ||
| | | | ||
| | field `bar` is declared as viewed here | ||
|
|
||
| error: field `0` is already part of the view | ||
| --> $DIR/duplicate_field.rs:15:38 | ||
| | | ||
| LL | _pair: &mut view_type!(Pair.{ 0, 0 }), | ||
| | - ^ | ||
| | | | ||
| | field `0` is declared as viewed here | ||
|
|
||
| error: field `bar` is already part of the view | ||
| --> $DIR/duplicate_field.rs:21:44 | ||
| | | ||
| LL | fn f(self: &mut view_type!(Self.{ bar, bar })) {} | ||
| | --- ^^^ | ||
| | | | ||
| | field `bar` is declared as viewed here | ||
|
|
||
| error: field `0` is already part of the view | ||
| --> $DIR/duplicate_field.rs:26:42 | ||
| | | ||
| LL | fn f(self: &mut view_type!(Self.{ 0, 0 })) {} | ||
| | - ^ | ||
| | | | ||
| | field `0` is declared as viewed here | ||
|
|
||
| error: aborting due to 4 previous errors | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| //@ run-pass | ||
| //@ aux-build: hygiene.rs | ||
|
|
||
| #![feature(view_types, view_type_macro, decl_macro)] | ||
| #![allow(unused)] | ||
|
|
||
| extern crate hygiene; | ||
|
|
||
| use std::view::view_type; | ||
|
|
||
| pub macro what($name: ident) { | ||
| struct Foo { | ||
| bar: usize, | ||
| $name: usize, | ||
| } | ||
|
|
||
| impl Foo { | ||
| fn f(self: &mut view_type!(Self.{ bar, $name })) {} | ||
| } | ||
| } | ||
|
|
||
| what!(bar); | ||
|
|
||
| struct Bar { | ||
| r#async: (), | ||
| } | ||
|
|
||
| impl Bar { | ||
| fn f(self: hygiene::view_bar!()) {} | ||
| } | ||
|
|
||
| fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.