]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #90035 - SparrowLii:rfc2528, r=jackh726
authorMatthias Krüger <matthias.krueger@famsik.de>
Tue, 9 Nov 2021 18:00:41 +0000 (19:00 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Nov 2021 18:00:41 +0000 (19:00 +0100)
commit610b4e503ccc5cb6d4ef98bb5016ba42eaf94522
treec8db226e573691cc2ffcd379127dc226d48bd564
parentfd74c93403c455187c343f3828274824addc9881
parent926892ddc0b75b50f5d0a3483d829e501aa8e895
Rollup merge of #90035 - SparrowLii:rfc2528, r=jackh726

implement rfc-2528 type_changing-struct-update

This PR implement rfc2528-type_changing-struct-update.
The main change process is as follows:
1. Move the processing part of `base_expr` into `check_expr_struct_fields` to avoid returning `remaining_fields` (a relatively complex hash table)
2. Before performing the type consistency check(`check_expr_has_type_or_error`), if the `type_changing_struct_update` feature is set, enter a different processing flow, otherwise keep the original flow
3. In the case of the same structure definition, check each field in `remaining_fields`. If the field in `base_expr` is not the suptype of the field in `adt_ty`, an error(`FeildMisMatch`) will be reported.

The MIR part does not need to be changed, because only the items contained in `remaining_fields` will be extracted from `base_expr` when MIR is generated. This means that fields with different types in `base_expr` will not be used
Updates #86618
cc `@nikomatsakis`
compiler/rustc_typeck/src/check/expr.rs