rust/compiler
bors 703f2e1685 Auto merge of #85041 - mibac138:suggest-generics, r=estebank
Suggest adding a type parameter for impls

Add a new suggestion upon encountering an unknown type in a `impl` that suggests adding a new type parameter. This diagnostic suggests to add a new type parameter even though it may be a const parameter, however after adding the parameter and running rustc again a follow up error steers the user to change the type parameter to a const parameter.

```rust
struct X<const C: ()>();
impl X<C> {}
```
suggests
```
error[E0412]: cannot find type `C` in this scope
 --> bar.rs:2:8
  |
1 | struct X<const C: ()>();
  | ------------------------ similarly named struct `X` defined here
2 | impl X<C> {}
  |        ^
  |
help: a struct with a similar name exists
  |
2 | impl X<X> {}
  |        ^
help: you might be missing a type parameter
  |
2 | impl<C> X<C> {}
  |     ^^^
```
After adding a type parameter the code now becomes
```rust
struct X<const C: ()>();
impl<C> X<C> {}
```
and the error now fully steers the user towards the correct code
```
error[E0747]: type provided when a constant was expected
 --> bar.rs:2:11
  |
2 | impl<C> X<C> {}
  |           ^
  |
help: consider changing this type parameter to be a `const` generic
  |
2 | impl<const C: ()> X<C> {}
  |      ^^^^^^^^^^^
```
r? `@estebank`
Somewhat related #84946
2021-05-13 08:08:20 +00:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Add more precise span informations to generic types 2021-05-12 11:36:07 +02:00
rustc_ast_lowering Add more precise span informations to generic types 2021-05-12 11:36:07 +02:00
rustc_ast_passes Implement RFC 2951: Native link modifiers 2021-05-05 16:04:25 -07:00
rustc_ast_pretty parser: Remove support for inner attributes on non-block expressions 2021-05-03 13:33:53 +03:00
rustc_attr Allow specifying alignment for functions 2021-04-05 17:36:51 -04:00
rustc_builtin_macros Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_codegen_cranelift Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_codegen_llvm Auto merge of #84732 - DrChat:asm_powerpc, r=Amanieu 2021-05-13 05:40:55 +00:00
rustc_codegen_ssa Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_data_structures Only compute Obligation cache_key once in register_obligation_at 2021-05-04 11:57:53 -07:00
rustc_driver Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot 2021-05-12 08:38:03 +00:00
rustc_error_codes Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis 2021-05-04 08:09:23 +00:00
rustc_errors Show macro name in 'this error originates in macro' message 2021-05-12 19:03:06 -04:00
rustc_expand Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_feature remove const_fn feature gate 2021-05-09 14:29:31 +02:00
rustc_fs_util
rustc_graphviz Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_hir Auto merge of #83759 - SkiFire13:fix-diag, r=estebank 2021-05-13 03:19:13 +00:00
rustc_hir_pretty Handle pretty printing of else if let clauses 2021-04-23 13:29:18 -04:00
rustc_incremental Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot 2021-05-12 08:38:03 +00:00
rustc_index Change bitwise operator to more easily keep data in vector registers 2021-05-04 11:55:18 -04:00
rustc_infer Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_interface Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_lexer Fix outdated crate names in compiler docs 2021-04-08 11:12:14 -05:00
rustc_lint Implement span quoting for proc-macros 2021-05-12 00:51:31 -04:00
rustc_lint_defs Add additional migrations to handle auto-traits and clone traits 2021-05-06 14:17:59 -04:00
rustc_llvm Support -C passes in NewPM 2021-05-08 10:58:08 +02:00
rustc_macros Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_metadata Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_middle Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_mir Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_mir_build Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk 2021-04-24 23:16:03 +00:00
rustc_parse Rollup merge of #84793 - estebank:parse-struct-field-default, r=davidtwco 2021-05-12 17:19:25 +02:00
rustc_parse_format Rollup merge of #83348 - osa1:issue83344, r=jackh726 2021-03-28 01:33:13 +09:00
rustc_passes Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_plugin_impl
rustc_privacy fix few typos 2021-04-19 15:57:08 +03:00
rustc_query_impl Apply --cfg parallel_compiler when documenting 2021-05-01 00:25:11 -04:00
rustc_query_system Show nicer error when an 'unstable fingerprints' error occurs 2021-05-10 17:43:51 -04:00
rustc_resolve Auto merge of #85041 - mibac138:suggest-generics, r=estebank 2021-05-13 08:08:20 +00:00
rustc_save_analysis Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_serialize Auto merge of #83465 - michaelwoerister:safe-read_raw_bytes, r=cjgillot 2021-03-26 01:28:59 +00:00
rustc_session Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_span Auto merge of #84732 - DrChat:asm_powerpc, r=Amanieu 2021-05-13 05:40:55 +00:00
rustc_symbol_mangling Rollup merge of #80525 - devsnek:wasm64, r=nagisa 2021-04-05 00:24:23 +02:00
rustc_target Add initial asm!() support for PowerPC 2021-05-11 19:04:16 -05:00
rustc_trait_selection Rollup merge of #84987 - lcnr:nits, r=Mark-Simulacrum 2021-05-07 00:38:45 +02:00
rustc_traits Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_ty_utils Implement changes suggested by tmiasko and davidtwco 2021-05-10 17:47:50 +02:00
rustc_type_ir Make TypeFoldable::is_global() false when fresh tys/consts are present 2021-05-01 16:58:33 -04:00
rustc_typeck Auto merge of #83759 - SkiFire13:fix-diag, r=estebank 2021-05-13 03:19:13 +00:00