-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make hir ProjectionKind more precise #20
Conversation
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.
Leaving some thoughts here so that I don't forget
51168fc
to
73c4487
Compare
73c4487
to
4253304
Compare
4253304
to
f2754af
Compare
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.
In rust-lang/project-rfc-2229#1 it mentioned Downcast
projection kind, which is not present in this PR. Should this PR mark that issue as closed ?
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arora-aman, @Azhng, @ChrisPardy, @jenniferwills, @logmosier, and @null-sleep)
src/librustc_typeck/mem_categorization.rs, line 822 at r1 (raw file):
// S { f1: p1, ..., fN: pN } let variant_index = if let Some(variant_index) =
Shouldn't this be 0 since there's is only one variant for a struct ?
Enums can be defined like structures too: https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html#destructuring-enums Downcast in MIR is to represent using an enum variant |
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.
Also use mc::Result
for error handling so it's consistent with rest of the code
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arora-aman, @ChrisPardy, @jenniferwills, @logmosier, and @null-sleep)
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.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @Azhng, @ChrisPardy, @jenniferwills, @logmosier, and @null-sleep)
src/librustc_typeck/mem_categorization.rs, line 822 at r1 (raw file):
Previously, Azhng (Archer Zhang) wrote…
Shouldn't this be 0 since there's is only one variant for a struct ?
Enums can be defined like structures too: https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html#destructuring-enums
f2754af
to
1262f59
Compare
@Azhng fixed |
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.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @arora-aman, @ChrisPardy, @jenniferwills, @logmosier, and @null-sleep)
src/librustc_typeck/mem_categorization.rs, line 786 at r2 (raw file):
// Any ADT related errors would've been catched when reading the `variant_index` let total_fields = self.total_fields_in_adt_variant(pat.hir_id, variant_index, pat.span).unwrap();
I think we can use the ?
syntax here instead of unwrapping
src/librustc_typeck/mem_categorization.rs, line 816 at r2 (raw file):
for fp in field_pats { let field_ty = self.pat_ty_adjusted(&fp.pat)?; let field_index = self
The code here that retrieve field_index
is almost identical to the code in cat_expr_unadjusted
. Maybe refactor it to a helper func ?
1262f59
to
a24fc4b
Compare
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.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arora-aman, @ChrisPardy, @jenniferwills, @logmosier, and @null-sleep)
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.
LGTM too
Rust PR: rust-lang#74140 |
a24fc4b
to
f201d96
Compare
f201d96
to
5c66ad1
Compare
This commit also categorizing access as Field, Index, or Subslice. Ideas are taken from `mir::ProjectionElem`. Proposed changes: https://github.com/rust-lang/project-rfc-2229/blob/master/hir-place-target.md Closes: rust-lang/project-rfc-2229#1, rust-lang/project-rfc-2229#2 Co-authored-by: Aman Arora <me@aman-arora.com> Co-authored-by: Chris Pardy <chrispardy36@gmail.com> Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
5c66ad1
to
1acccb0
Compare
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.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @arora-aman, @ChrisPardy, @jenniferwills, @logmosier, and @null-sleep)
src/librustc_typeck/mem_categorization.rs, line 799 at r3 (raw file):
self.total_fields_in_adt_variant(pat.hir_id, variant_index, pat.span)?; for (i, subpat) in subpats.iter().enumerate_and_adjust(total_fields, dots_pos) {
TIL
This is only for the very direct specific type slide of HirPat borrow |
This commit also categorizing access as Field, Index, or Subslice.
Ideas are taken from
mir::ProjectionElem
.Proposed changes: https://github.com/rust-lang/project-rfc-2229/blob/master/hir-place-target.md
Closes: rust-lang/project-rfc-2229#1,
Closes: rust-lang/project-rfc-2229#2
This change is