Skip to content

Commit 68cc12a

Browse files
m-ou-seeddyb
andcommitted
Fix non-existent-field ICE for generic fields.
Co-authored-by: eddyb <[email protected]>
1 parent 6ad11e2 commit 68cc12a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compiler/rustc_typeck/src/check/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19741974

19751975
field_path.push(candidate_field.ident.normalize_to_macros_2_0());
19761976
let field_ty = candidate_field.ty(self.tcx, subst);
1977-
if let Some((nested_fields, _)) = self.get_field_candidates(span, &field_ty) {
1977+
if let Some((nested_fields, subst)) = self.get_field_candidates(span, &field_ty) {
19781978
for field in nested_fields.iter() {
19791979
let ident = field.ident.normalize_to_macros_2_0();
19801980
if ident == target_field {

src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
struct Foo {
44
first: Bar,
55
_second: u32,
6-
_third: u32,
6+
_third: Vec<String>,
77
}
88

99
struct Bar {
@@ -32,7 +32,7 @@ fn main() {
3232
let d = D { test: e };
3333
let c = C { c: d };
3434
let bar = Bar { bar: c };
35-
let fooer = Foo { first: bar, _second: 4, _third: 5 };
35+
let fooer = Foo { first: bar, _second: 4, _third: Vec::new() };
3636

3737
let _test = &fooer.first.bar.c;
3838
//~^ ERROR no field

src/test/ui/suggestions/non-existent-field-present-in-subfield.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
struct Foo {
44
first: Bar,
55
_second: u32,
6-
_third: u32,
6+
_third: Vec<String>,
77
}
88

99
struct Bar {
@@ -32,7 +32,7 @@ fn main() {
3232
let d = D { test: e };
3333
let c = C { c: d };
3434
let bar = Bar { bar: c };
35-
let fooer = Foo { first: bar, _second: 4, _third: 5 };
35+
let fooer = Foo { first: bar, _second: 4, _third: Vec::new() };
3636

3737
let _test = &fooer.c;
3838
//~^ ERROR no field

0 commit comments

Comments
 (0)