rust/src
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
..
bootstrap Rollup merge of #85191 - GuillaumeGomez:improve-rustdoc-gui-tester, r=Mark-Simulacrum 2021-05-12 07:18:05 +09:00
build_helper
ci update perf version used for PGO 2021-05-10 14:39:28 +02:00
doc Auto merge of #84732 - DrChat:asm_powerpc, r=Amanieu 2021-05-13 05:40:55 +00:00
etc Fix HashMap/HashSet LLDB pretty-printer after hashbrown 0.11.0 2021-04-06 12:44:17 +03:00
librustdoc Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha 2021-05-12 17:19:29 +02:00
llvm-project@c78cf18a07 Update LLVM submodule 2021-05-08 11:01:09 +02:00
rustdoc-json-types rustdoc-json: Rename Import.span to Import.source 2021-03-21 19:47:12 -07:00
test Auto merge of #85041 - mibac138:suggest-generics, r=estebank 2021-05-13 08:08:20 +00:00
tools Auto merge of #82069 - Aaron1011:verbose-in-macro, r=estebank 2021-05-13 00:31:39 +00:00
README.md
stage0.txt Bump bootstrap compiler 2021-04-06 18:24:09 -07:00
version bump version to 1.54.0 2021-04-30 15:24:00 +02:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.