rust/compiler
Hirochika Matsumoto 21eff8f050 Suggest replacing braces for brackets on array-esque invalid block expr
Newcomers may write `{1, 2, 3}` for making arrays, and the current error
message is not informative enough to quickly convince them what is
needed to fix the error.
This PR implements a diagnostic for this case, and its output looks like
this:
```text
error: this code is interpreted as a block expression, not an array
 --> src/lib.rs:1:22
  |
1 |   const FOO: [u8; 3] = {
  |  ______________________^
2 | |     1, 2, 3
3 | | };
  | |_^
  |
  = note: to define an array, one would use square brackets instead of curly braces
help: try using [] instead of {}
  |
1 | const FOO: [u8; 3] = [
2 |     1, 2, 3
3 | ];
  |
```

Fix #87672
2021-09-19 20:01:23 +09:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco 2021-09-15 14:56:58 -07:00
rustc_ast_lowering Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco 2021-09-15 14:56:58 -07:00
rustc_ast_passes delay error for enabling unstable lib features 2021-09-16 14:22:32 -04:00
rustc_ast_pretty Revert "Implement Anonymous{Struct, Union} in the AST" 2021-09-09 09:14:17 -04:00
rustc_attr
rustc_borrowck Rollup merge of #87460 - FabianWolff:issue-87456, r=Aaron1011 2021-09-17 17:41:13 +02:00
rustc_builtin_macros Auto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obk 2021-09-17 01:00:11 +00:00
rustc_codegen_cranelift Auto merge of #88839 - nbdd0121:alignof, r=nagisa 2021-09-12 23:49:24 +00:00
rustc_codegen_llvm Auto merge of #87867 - bjorn3:unique_type_id_interner, r=wesleywiser 2021-09-15 12:34:31 +00:00
rustc_codegen_ssa Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk 2021-09-17 14:09:47 +09:00
rustc_const_eval Auto merge of #88965 - fee1-dead:const-drop-1, r=oli-obk 2021-09-18 00:18:28 +00:00
rustc_data_structures Rollup merge of #88711 - Mark-Simulacrum:fix-dfs-bug, r=jackh726 2021-09-12 03:44:57 -07:00
rustc_driver Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk 2021-09-17 14:09:47 +09:00
rustc_error_codes Do not issue E0071 if a type error has already been reported 2021-09-12 23:07:23 +02:00
rustc_errors Make diagnostics clearer for ? operators 2021-09-17 13:13:28 +09:00
rustc_expand chore(rustc_expand): fix typo in comment 2021-09-15 09:13:18 -07:00
rustc_feature Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco 2021-09-15 14:56:58 -07:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #88954 - nbdd0121:panic3, r=oli-obk 2021-09-17 17:41:19 +02:00
rustc_hir_pretty don't convert types into identical types 2021-09-11 10:32:38 +02:00
rustc_incremental Auto merge of #83214 - cjgillot:dep-map, r=michaelwoerister 2021-09-06 23:58:16 +00:00
rustc_index
rustc_infer Auto merge of #88945 - Aaron1011:no-projection-completion, r=wesleywiser,jackh726 2021-09-17 09:44:28 +00:00
rustc_interface Rollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister 2021-09-15 14:56:56 -07:00
rustc_lexer
rustc_lint Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis 2021-09-17 14:09:44 +09:00
rustc_lint_defs Add reachable_patterns lint to rfc-2008-non_exhaustive 2021-09-14 15:45:13 -04:00
rustc_llvm PassWrapper: these two lines shouldn't have been ifdef'd 2021-09-16 15:04:18 -04:00
rustc_macros Use a separate interner type for UniqueTypeId 2021-09-13 14:42:06 +02:00
rustc_metadata Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb 2021-09-12 20:48:09 +00:00
rustc_middle Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisa 2021-09-16 22:17:33 +00:00
rustc_mir_build Add reachable_patterns lint to rfc-2008-non_exhaustive 2021-09-14 15:45:13 -04:00
rustc_mir_dataflow Make rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public 2021-09-15 11:41:37 -07:00
rustc_mir_transform Auto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearth 2021-09-16 19:33:39 +00:00
rustc_monomorphize Rebase fallout. 2021-09-08 20:40:30 +02:00
rustc_parse Suggest replacing braces for brackets on array-esque invalid block expr 2021-09-19 20:01:23 +09:00
rustc_parse_format
rustc_passes delay error for enabling unstable lib features 2021-09-16 14:22:32 -04:00
rustc_plugin_impl
rustc_privacy add a CastKind to Node::Cast 2021-09-09 01:32:03 +01:00
rustc_query_impl Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr 2021-09-12 03:44:56 -07:00
rustc_query_system Auto merge of #78780 - cjgillot:req, r=Mark-Simulacrum 2021-09-11 20:39:47 +00:00
rustc_resolve Auto merge of #87915 - estebank:fancy-spans, r=oli-obk 2021-09-13 16:31:12 +00:00
rustc_save_analysis Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
rustc_serialize rustc: Remove local variable IDs from Exports 2021-09-10 23:41:48 +03:00
rustc_session Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk 2021-09-17 14:09:47 +09:00
rustc_span Rollup merge of #88954 - nbdd0121:panic3, r=oli-obk 2021-09-17 17:41:19 +02:00
rustc_symbol_mangling
rustc_target Auto merge of #87794 - bonega:enum_niche_prefer_zero, r=nagisa 2021-09-13 22:14:57 +00:00
rustc_trait_selection Auto merge of #88962 - fee1-dead:const-drop, r=oli-obk 2021-09-17 21:37:01 +00:00
rustc_traits
rustc_ty_utils Remove the queries 2021-09-09 05:21:32 +00:00
rustc_type_ir Use index newtyping for TyVid 2021-09-06 22:38:06 -04:00
rustc_typeck Rollup merge of #88949 - FabianWolff:issue-87563, r=estebank 2021-09-17 17:41:17 +02:00