rust/compiler
Matthias Krüger 20a5e9fd7c
Rollup merge of #99986 - WaffleLapkin:record_struct_wrap_suggestion, r=compiler-errors
Add wrap suggestions for record variants

This PR adds a suggestions to wrap an expression in a record struct/variant when encountering mismatched types, similarly to a suggestion to wrap expression in a tuple struct that was added before.

An example:
```rust
struct B {
    f: u8,
}

enum E {
    A(u32),
    B { f: u8 },
}

fn main() {
    let _: B = 1;
    let _: E = 1;
}
```
```text
error[E0308]: mismatched types
  --> ./t.rs:11:16
   |
11 |     let _: B = 1;
   |            -   ^ expected struct `B`, found integer
   |            |
   |            expected due to this
   |
help: try wrapping the expression in `B`
   |
11 |     let _: B = B { f: 1 };
   |                ++++++   +

error[E0308]: mismatched types
  --> ./t.rs:12:16
   |
12 |     let _: E = 1;
   |            -   ^ expected enum `E`, found integer
   |            |
   |            expected due to this
   |
help: try wrapping the expression in a variant of `E`
   |
12 |     let _: E = E::A(1);
   |                +++++ +
12 |     let _: E = E::B { f: 1 };
   |                +++++++++   +
```

r? `@compiler-errors`
2022-07-31 23:39:44 +02:00
..
rustc Don't rerun the build script for the compiler each time on linux 2022-07-10 23:57:25 -05:00
rustc_apfloat Update smallvec to 1.8.1. 2022-06-27 08:48:55 +10:00
rustc_arena Rollup merge of #97711 - Nilstrieb:rustc-arena-ub, r=wesleywiser 2022-07-07 18:06:49 +05:30
rustc_ast Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov 2022-07-30 14:50:05 +00:00
rustc_ast_lowering Replace LifetimeRes::Anonymous by LifetimeRes::Infer. 2022-07-26 19:00:31 +02:00
rustc_ast_passes Remove visit_name from the AST visitor. 2022-07-29 15:28:32 +10:00
rustc_ast_pretty Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
rustc_attr avoid embedding StabilityLevel::Unstable reason string into metadata multiple times 2022-07-21 22:53:02 +03:00
rustc_borrowck Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot 2022-07-31 17:36:40 +05:30
rustc_builtin_macros Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov 2022-07-30 14:50:05 +00:00
rustc_codegen_cranelift Introduce an ArchiveBuilderBuilder 2022-07-28 09:08:47 +00:00
rustc_codegen_gcc Introduce an ArchiveBuilderBuilder 2022-07-28 09:08:47 +00:00
rustc_codegen_llvm Rollup merge of #99844 - bjorn3:archive_builder_interface_refactor, r=nagisa 2022-07-31 17:36:42 +05:30
rustc_codegen_ssa Rollup merge of #99844 - bjorn3:archive_builder_interface_refactor, r=nagisa 2022-07-31 17:36:42 +05:30
rustc_const_eval Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
rustc_data_structures remove some manual hash stable impls 2022-07-29 12:48:28 +02:00
rustc_driver Rename local_did to def_id 2022-07-29 18:26:10 -04:00
rustc_error_codes region_outlives_predicate no snapshot 2022-07-21 13:09:01 +02:00
rustc_error_messages lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
rustc_errors Auto merge of #99058 - michaelwoerister:remove-stable-set-and-map, r=nagisa 2022-07-20 22:19:30 +00:00
rustc_expand Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov 2022-07-30 14:50:05 +00:00
rustc_feature lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
rustc_fs_util
rustc_graphviz Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rustc_hir Replace LifetimeRes::Anonymous by LifetimeRes::Infer. 2022-07-26 19:00:31 +02:00
rustc_hir_pretty use rustc_hir_pretty::qpath_to_string to avoid span_to_snippet when rendering path 2022-07-17 04:58:38 +00:00
rustc_incremental Remove unused StableMap and StableSet types from rustc_data_structures 2022-07-20 13:11:39 +02:00
rustc_index Edit rustc_index::vec::IndexVec::pick3_mut docs 2022-07-21 08:52:18 -05:00
rustc_infer use appropriate HirID for finding else_span 2022-07-31 11:33:01 +09:00
rustc_interface Rollup merge of #99519 - Urgau:check-cfg-implicit, r=petrochenkov 2022-07-31 23:39:38 +02:00
rustc_lexer fix typo in comment 2022-06-28 19:59:09 +05:30
rustc_lint Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov 2022-07-30 14:50:05 +00:00
rustc_lint_defs Generate correct suggestion with named arguments used positionally 2022-07-25 00:00:27 -06:00
rustc_llvm Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GE 2022-07-30 18:53:51 +02:00
rustc_log clippy::complexity fixes 2022-05-26 13:14:24 +02:00
rustc_macros clippy::perf fixes 2022-07-20 11:48:11 +02:00
rustc_metadata Rename local_did to def_id 2022-07-29 18:26:10 -04:00
rustc_middle Rollup merge of #99973 - RalfJung:layout-things, r=eddyb 2022-07-31 23:39:42 +02:00
rustc_mir_build Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot 2022-07-31 17:36:40 +05:30
rustc_mir_dataflow Auto merge of #99667 - ouz-a:some_branch, r=oli-obk 2022-07-29 07:11:50 +00:00
rustc_mir_transform Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot 2022-07-31 17:36:40 +05:30
rustc_monomorphize Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
rustc_parse Auto merge of #99948 - Dylan-DPC:rollup-ed5136t, r=Dylan-DPC 2022-07-30 17:30:50 +00:00
rustc_parse_format Generate correct suggestion with named arguments used positionally 2022-07-25 00:00:27 -06:00
rustc_passes Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot 2022-07-31 17:36:40 +05:30
rustc_plugin_impl remove currently unused deps 2022-06-13 22:20:51 +03:00
rustc_privacy clippy::perf fixes 2022-07-20 11:48:11 +02:00
rustc_query_impl Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
rustc_query_system consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
rustc_resolve change the type of note field to Option<String> 2022-07-28 18:17:55 +09:00
rustc_save_analysis Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot 2022-07-14 14:14:21 +05:30
rustc_serialize Upgrade indexmap and thorin-dwp to use hashbrown 0.12 2022-07-17 07:05:58 -07:00
rustc_session Rollup merge of #99620 - hudson-ayers:fix-location-detail, r=davidtwco 2022-07-31 23:39:40 +02:00
rustc_smir Rustfmt 2022-06-02 10:29:00 +00:00
rustc_span Use line numbers relative to function in mir opt tests 2022-07-28 11:59:54 +02:00
rustc_symbol_mangling Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisa 2022-07-24 01:22:36 +00:00
rustc_target reorder fields in Laout debug output 2022-07-31 08:23:27 -04:00
rustc_trait_selection Rollup merge of #99862 - WaffleLapkin:type_mismatch_fix, r=compiler-errors 2022-07-30 20:39:47 +05:30
rustc_traits Rollup merge of #99714 - ouz-a:issue_57961, r=oli-obk 2022-07-28 16:38:30 +05:30
rustc_ty_utils Rename local_did to def_id 2022-07-29 18:26:10 -04:00
rustc_type_ir Inline DebruijnIndex methods 2022-07-22 17:00:49 +02:00
rustc_typeck Rollup merge of #99986 - WaffleLapkin:record_struct_wrap_suggestion, r=compiler-errors 2022-07-31 23:39:44 +02:00