rust/compiler
bors dddebf94bc Auto merge of #86116 - FabianWolff:issue-86100, r=varkor
Suggest a trailing comma if a 1-tuple is expected and a parenthesized expression is found

This pull request fixes #86100. The following code:
```rust
fn main() {
    let t: (i32,) = (1);
}
```
currently produces:
```
warning: unnecessary parentheses around assigned value
 --> test.rs:2:21
  |
2 |     let t: (i32,) = (1);
  |                     ^^^ help: remove these parentheses
  |
  = note: `#[warn(unused_parens)]` on by default

error[E0308]: mismatched types
 --> test.rs:2:21
  |
2 |     let t: (i32,) = (1);
  |            ------   ^^^ expected tuple, found integer
  |            |
  |            expected due to this
  |
  = note: expected tuple `(i32,)`
              found type `{integer}`

error: aborting due to previous error; 1 warning emitted
```
With my changes, I get the same warning and the following error:
```
error[E0308]: mismatched types
 --> test.rs:2:21
  |
2 |     let t: (i32,) = (1);
  |            ------   ^^^ expected tuple, found integer
  |            |
  |            expected due to this
  |
  = note: expected tuple `(i32,)`
              found type `{integer}`
help: use a trailing comma to create a tuple with one element
  |
2 |     let t: (i32,) = (1,);
  |                     ^^^^
```
i.e. I have added a suggestion to add a trailing comma to create a 1-tuple. This suggestion is only issued if a 1-tuple is expected and the expression (`(1)` in the example above) is surrounded by parentheses and does not already have a tuple type. In this situation, I'd say that it is pretty likely that the user meant to create a tuple.
2021-06-11 10:25:53 +00:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_ast_lowering Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_ast_passes Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_ast_pretty Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_attr remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_builtin_macros Auto merge of #84863 - ABouttefeux:libtest, r=m-ou-se 2021-06-06 09:13:59 +00:00
rustc_codegen_cranelift Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
rustc_codegen_llvm Auto merge of #86020 - nagisa:nagisa/outliner, r=pnkfelix 2021-06-10 15:11:01 +00:00
rustc_codegen_ssa Auto merge of #86204 - alexcrichton:wasm-simd-stable, r=Amanieu 2021-06-11 05:02:41 +00:00
rustc_data_structures add VecMap docs 2021-06-08 17:17:48 -03:00
rustc_driver Rustfmt 2021-06-04 13:20:05 +02:00
rustc_error_codes Add E0316.md 2021-06-07 14:20:39 +02:00
rustc_errors Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor 2021-06-07 14:40:26 +00:00
rustc_expand Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_feature Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_fs_util
rustc_graphviz Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_hir Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
rustc_hir_pretty remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_incremental Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
rustc_index Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_infer Suggest a trailing comma if a 1-tuple is expected 2021-06-07 23:16:03 +02:00
rustc_interface Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
rustc_lexer Fix outdated crate names in compiler docs 2021-04-08 11:12:14 -05:00
rustc_lint Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_lint_defs Fix deny(invalid_doc_attributes) 2021-06-04 15:20:26 -04:00
rustc_llvm Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov 2021-06-06 03:59:17 +00:00
rustc_macros Remove unused functions and arguments from rustc_serialize 2021-06-01 19:29:11 +02:00
rustc_metadata Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
rustc_middle Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
rustc_mir Auto merge of #85994 - tmiasko:monomorphic-needs-drop, r=RalfJung 2021-06-11 07:44:58 +00:00
rustc_mir_build Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_parse Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_parse_format remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_passes Rollup merge of #86047 - jyn514:doc-attrs, r=petrochenkov 2021-06-06 19:11:24 +09:00
rustc_plugin_impl Use () for plugin_registrar_fn. 2021-05-12 13:58:43 +02:00
rustc_privacy Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
rustc_query_impl Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_query_system Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor 2021-06-07 14:40:26 +00:00
rustc_resolve Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_save_analysis Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
rustc_serialize Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor 2021-06-07 14:40:26 +00:00
rustc_session gcc-lld mvp 2021-06-10 17:10:40 +10:00
rustc_span Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_symbol_mangling Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
rustc_target Use try_into instead of asserting manually 2021-06-07 01:27:40 +02:00
rustc_trait_selection Differentiate different defining uses of taits when they reference distinct generic parameters 2021-06-07 19:10:12 -03:00
rustc_traits Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_ty_utils Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
rustc_type_ir Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_typeck Auto merge of #86118 - spastorino:tait-soundness-bug, r=nikomatsakis 2021-06-09 09:00:16 +00:00