1
Fork 0
rust/compiler
Dylan DPC 070de4bc48
Rollup merge of #99942 - compiler-errors:nonsense-un-tupled-fn-trait-error, r=cjgillot
Fix nonsense non-tupled `Fn` trait error

Given this code:

```rust
#![feature(unboxed_closures)]

fn a<F: Fn<usize>>(f: F) {}

fn main() {
    a(|_: usize| {});
}
```

We currently emit this error:
```
error[E0631]: type mismatch in closure arguments
 --> src/main.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ ---------- found signature of `fn(usize) -> _`
  |     |
  |     expected signature of `fn(usize) -> _`
  |
note: required by a bound in `a`
 --> src/main.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

For more information about this error, try `rustc --explain E0631`.
error: could not compile `playground` due to previous error
```
Notably, it says the same thing for "expected" and "found"!

Fix the output so that we instead emit:
```
error[E0308]: mismatched types
 --> /home/gh-compiler-errors/test.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ types differ
  |
  = note: expected trait `Fn<usize>`
             found trait `Fn<(usize,)>`
note: required by a bound in `a`
 --> /home/gh-compiler-errors/test.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

error: aborting due to previous error
```

The error could still use some work, namely the "mismatched types" part, but I'm leaving it a bit rough since the only way you'd ever get this error is when you're messing with `#![feature(unboxed_closures)]`.

Simply making sure we actually print out the difference in trait-refs is good enough for me. I could probably factor in some additional improvements if those are desired.
2022-08-16 18:16:11 +05:30
..
rustc Don't rerun the build script for the compiler each time on linux 2022-07-10 23:57:25 -05:00
rustc_apfloat Warn about dead tuple struct fields 2022-08-03 12:17:23 +02:00
rustc_arena Stabilize ptr_const_cast 2022-08-10 17:22:58 +02:00
rustc_ast Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
rustc_ast_lowering Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov 2022-08-16 07:54:22 +00:00
rustc_ast_passes Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_ast_pretty Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
rustc_attr Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_borrowck TypeError can be Copy 2022-08-14 19:58:46 +00:00
rustc_builtin_macros Rollup merge of #100277 - m-ou-se:format-args-1, r=compiler-errors 2022-08-15 10:28:10 +02:00
rustc_codegen_cranelift also update anyhow in codegen_cranelift 2022-08-08 09:04:26 -04:00
rustc_codegen_gcc Introduce an ArchiveBuilderBuilder 2022-07-28 09:08:47 +00:00
rustc_codegen_llvm Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa 2022-08-16 06:05:57 +02:00
rustc_codegen_ssa Rollup merge of #100528 - tux3:riscv-bitmanip-features, r=davidtwco 2022-08-15 20:11:37 +02:00
rustc_const_eval Rollup merge of #100600 - saethlin:rename-memory-hooks, r=RalfJung 2022-08-16 06:06:00 +02:00
rustc_data_structures remove some manual hash stable impls 2022-07-29 12:48:28 +02:00
rustc_driver Error on broken pipe but do not ICE 2022-08-02 01:08:50 +01:00
rustc_error_codes region_outlives_predicate no snapshot 2022-07-21 13:09:01 +02:00
rustc_error_messages Rollup merge of #100377 - est31:fluent_grepability, r=davidtwco 2022-08-15 20:11:34 +02:00
rustc_errors Rollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errors 2022-08-16 06:05:59 +02:00
rustc_expand Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_feature Add missing closing quote 2022-08-15 15:57:55 +08:00
rustc_fs_util
rustc_graphviz Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rustc_hir Auto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisa 2022-08-16 02:32:47 +00:00
rustc_hir_pretty Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillot 2022-08-15 05:50:54 +00:00
rustc_incremental Remove trait_of_item query. 2022-08-01 21:39:26 +02:00
rustc_index debuginfo: Change C++-like encoding for enums. 2022-08-12 10:53:07 +02:00
rustc_infer Fix error message with non-tupled bare fn trait 2022-08-16 01:21:11 +00:00
rustc_interface Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_lexer Shrink Token. 2022-08-01 08:53:04 +10:00
rustc_lint Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillot 2022-08-15 05:50:54 +00:00
rustc_lint_defs Warn about dead tuple struct fields 2022-08-03 12:17:23 +02:00
rustc_llvm Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa 2022-08-16 06:05:57 +02:00
rustc_log clippy::complexity fixes 2022-05-26 13:14:24 +02:00
rustc_macros Change fluent_messages macro to expect _ slugs instead of - slugs 2022-08-12 22:26:08 +02:00
rustc_metadata Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_middle Fix error message with non-tupled bare fn trait 2022-08-16 01:21:11 +00:00
rustc_mir_build Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_mir_dataflow Remove redundant TransferWrapper struct 2022-08-01 17:08:19 +02:00
rustc_mir_transform Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_monomorphize Refuse to codegen an upstream static. 2022-08-10 18:30:12 +02:00
rustc_parse Rollup merge of #100559 - nnethercote:parser-simplifications, r=compiler-errors 2022-08-15 20:11:38 +02:00
rustc_parse_format add a comment about what we can parse now 2022-08-04 20:43:35 +09:00
rustc_passes Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoerister 2022-08-15 20:11:32 +02:00
rustc_plugin_impl remove currently unused deps 2022-06-13 22:20:51 +03:00
rustc_privacy Adjust cfgs 2022-08-12 16:28:15 -04:00
rustc_query_impl Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
rustc_query_system Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov 2022-08-16 07:54:22 +00:00
rustc_resolve Rollup merge of #100367 - fmease:fix-100365, r=compiler-errors 2022-08-13 21:06:49 -07:00
rustc_save_analysis Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00
rustc_serialize Upgrade indexmap and thorin-dwp to use hashbrown 0.12 2022-07-17 07:05:58 -07:00
rustc_session Revert "Revert "Remove num_cpus dependency from bootstrap, build-manifest and rustc_session"" 2022-08-15 16:24:07 +02:00
rustc_smir Rustfmt 2022-06-02 10:29:00 +00:00
rustc_span Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoerister 2022-08-15 20:11:32 +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 rustc_target: Update some old naming around self contained linking 2022-08-12 18:47:13 +03:00
rustc_trait_selection Fix error message with non-tupled bare fn trait 2022-08-16 01:21:11 +00:00
rustc_traits Rollup merge of #100095 - jackh726:early-binder, r=lcnr 2022-08-04 22:25:04 +02:00
rustc_transmute safe transmute: fix broken intradoc link 2022-08-02 14:44:23 +00:00
rustc_ty_utils Add bound_impl_subject and bound_return_ty 2022-08-03 01:02:46 -04:00
rustc_type_ir Inline DebruijnIndex methods 2022-07-22 17:00:49 +02:00
rustc_typeck Rollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errors 2022-08-16 06:05:59 +02:00