forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Field projections dev PR #1
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
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
95d2452
rustc_hir_typeck: match all ty kinds in probe
BennoLossin 03707aa
add field_projections feature gate
BennoLossin 154f5cb
add field traits
BennoLossin b4901a8
error on manually implementing field traits
BennoLossin 0319e13
add unaligned_field_offset intrinsic
BennoLossin f6ecb16
add builtin `field_of!` macro
BennoLossin 6202eac
move `NoFieldOnType` error
BennoLossin 297bdad
add `FieldPath`
BennoLossin f92a04b
use `FieldPath` in `offset_of!`
BennoLossin b6b2961
add FRTs to HIR
BennoLossin f6a9247
add FRTs as `ty::Field`
BennoLossin 8848a57
printing `ty::Field`
BennoLossin f92fc96
FRTs are `Sized`
BennoLossin 437303e
FRTs are uninhabited
BennoLossin eded109
FRTs are not trivially `Copy` & `Clone`
BennoLossin ca4ca97
FRTs are trivially `Freeze`
BennoLossin a63c681
FRTs are not trivially `Unpin`
BennoLossin a75ba70
FRTs don't implement `Drop`
BennoLossin baf2b38
add coherence check for FRTs
BennoLossin 14f4d3e
borrow check of FRTs (have no fields & can't be dereferenced)
BennoLossin e907a0e
const eval of FRTs (they are uninhabited, so not really much to do)
BennoLossin 3ce340a
add FRTs to rustc_public
BennoLossin 867fb8d
FRTs & symbol names
BennoLossin 3a33d16
FRTs & FFI
BennoLossin c0ca97f
rustdoc support for FRTs
BennoLossin b273c2b
add builtin impls of `Field` and `UnalignedField` for FRTs
BennoLossin 6be7991
add values for associated items of `UnalignedField`
BennoLossin 0428f2a
basic test
BennoLossin a6b191a
debuginfo for FRTs
BennoLossin 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
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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| `UnalignedField` or `Field` was manually implemented, which is not allowed. | ||
|
|
||
| Erroneous code examples: | ||
|
|
||
| ```compile_fail,E0806 | ||
| use std::field::UnalignedField; | ||
|
|
||
| pub struct MyStruct; | ||
|
|
||
| unsafe impl UnalignedField for MyStruct { | ||
| type Base = (); | ||
| type Type = (); | ||
| const OFFSET: usize = 0; | ||
| } | ||
| ``` | ||
|
|
||
| ```compile_fail,E0806 | ||
| use std::field::{Field, field_of}; | ||
|
|
||
| pub struct MyStruct(usize); | ||
|
|
||
| unsafe impl Field for field_of!(MyStruct, 0) {} | ||
| ``` |
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 |
|---|---|---|
|
|
@@ -548,6 +548,7 @@ E0802: 0802, | |
| E0803: 0803, | ||
| E0804: 0804, | ||
| E0805: 0805, | ||
| E0806: 0806, | ||
| ); | ||
| ) | ||
| } | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small nit here is that we don't need the check since the caller has checked the kind. We don't actually need any info about the container or the field path... Even if we do, we can pass them through from the args I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied what the other functions do 🤷 should I still change it?