diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-02-03 18:51:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-03 18:51:18 +0100 |
| commit | 46174188e8d8b6b42debbd0939a95d14b91c514f (patch) | |
| tree | 8ffabda42410e78509f79b3912db5ce17b9da589 | |
| parent | 65b3c0caf0549efab0ca0ad126d91ffdd7848cd3 (diff) | |
| parent | 68cc12ab71c50aea1f17e6c1cc631bb4c6a8ebb5 (diff) | |
| download | rust-46174188e8d8b6b42debbd0939a95d14b91c514f.tar.gz rust-46174188e8d8b6b42debbd0939a95d14b91c514f.zip | |
Rollup merge of #81716 - m-ou-se:fix-ice, r=eddyb
Fix non-existent-field ICE for generic fields. I mentioned this ICE in a chat and it took about 3 milliseconds before `@eddyb` found the problem and said this change would fix it. :) This also changes one the field types in the related test to one that triggered the ICE. Fixes #81627. Fixes #81672. Fixes #81709. Cc https://github.com/rust-lang/rust/pull/81480 `@b-naber` `@estebank.`
3 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 04c83a7665c..33b1c0bb2c9 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -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 { diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed b/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed index 167548a89de..e58b4e6ca4d 100644 --- a/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed +++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed @@ -3,7 +3,7 @@ struct Foo { first: Bar, _second: u32, - _third: u32, + _third: Vec<String>, } struct Bar { @@ -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 diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs b/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs index 81cc1af4dff..7e273ac23d8 100644 --- a/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs +++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs @@ -3,7 +3,7 @@ struct Foo { first: Bar, _second: u32, - _third: u32, + _third: Vec<String>, } struct Bar { @@ -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 |
