Skip to content

Commit

Permalink
Fix non-existent-field ICE for generic fields.
Browse files Browse the repository at this point in the history
Co-authored-by: eddyb <eddyb@lyken.rs>
  • Loading branch information
m-ou-se and eddyb committed Feb 3, 2021
1 parent 6ad11e2 commit 68cc12a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

field_path.push(candidate_field.ident.normalize_to_macros_2_0());
let field_ty = candidate_field.ty(self.tcx, subst);
if let Some((nested_fields, _)) = self.get_field_candidates(span, &field_ty) {
if let Some((nested_fields, subst)) = self.get_field_candidates(span, &field_ty) {
for field in nested_fields.iter() {
let ident = field.ident.normalize_to_macros_2_0();
if ident == target_field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
struct Foo {
first: Bar,
_second: u32,
_third: u32,
_third: Vec<String>,
}

struct Bar {
Expand Down Expand Up @@ -32,7 +32,7 @@ fn main() {
let d = D { test: e };
let c = C { c: d };
let bar = Bar { bar: c };
let fooer = Foo { first: bar, _second: 4, _third: 5 };
let fooer = Foo { first: bar, _second: 4, _third: Vec::new() };

let _test = &fooer.first.bar.c;
//~^ ERROR no field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
struct Foo {
first: Bar,
_second: u32,
_third: u32,
_third: Vec<String>,
}

struct Bar {
Expand Down Expand Up @@ -32,7 +32,7 @@ fn main() {
let d = D { test: e };
let c = C { c: d };
let bar = Bar { bar: c };
let fooer = Foo { first: bar, _second: 4, _third: 5 };
let fooer = Foo { first: bar, _second: 4, _third: Vec::new() };

let _test = &fooer.c;
//~^ ERROR no field
Expand Down

0 comments on commit 68cc12a

Please sign in to comment.