rust/tests/ui/structs
Esteban Küber d8456855f5 Suggest replacing Self with the right type on type error
When encountering a type error caused by the use of `Self`, suggest
using the actual type name instead.

```
error[E0308]: mismatched types
  --> $DIR/struct-path-self-type-mismatch.rs:13:9
   |
LL |   impl<T> Foo<T> {
   |        -  ------ this is the type of the `Self` literal
   |        |
   |        found type parameter
LL |       fn new<U>(u: U) -> Foo<U> {
   |              -           ------ expected `Foo<U>` because of return type
   |              |
   |              expected type parameter
LL | /         Self {
LL | |
LL | |             inner: u
LL | |
LL | |         }
   | |_________^ expected `Foo<U>`, found `Foo<T>`
   |
   = note: expected struct `Foo<U>`
              found struct `Foo<T>`
   = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
   = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
help: use the type name directly
   |
LL |         Foo::<U> {
   |         ~~~~~~~~
```

Fix #76086.
2023-11-16 16:19:19 +00:00
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
incomplete-fn-in-struct-definition.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
incomplete-fn-in-struct-definition.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-80853.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-80853.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
large-records.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
method-chain-expression-failure.rs Recurse over the method chain and maintain a stack to peek at previous receiver to align spans 2023-11-10 13:00:27 -08:00
method-chain-expression-failure.stderr Recurse over the method chain and maintain a stack to peek at previous receiver to align spans 2023-11-10 13:00:27 -08:00
multi-line-fru-suggestion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
multi-line-fru-suggestion.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rhs-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-base-wrong-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-base-wrong-type.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
struct-duplicate-comma.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-duplicate-comma.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-duplicate-comma.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-field-cfg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-field-cfg.stderr Don't mention already set fields 2023-06-05 21:00:08 +00:00
struct-field-init-syntax.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-field-init-syntax.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-field-privacy.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-field-privacy.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-decl-dupe.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-decl-dupe.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-dupe.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-dupe.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-hints-no-dupe.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-hints-no-dupe.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-hints.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-hints.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-missing.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-missing.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-shorthand-unresolved.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-shorthand-unresolved.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-shorthand.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-shorthand.stderr Don't mention already set fields 2023-06-05 21:00:08 +00:00
struct-fields-too-many.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-too-many.stderr Don't mention already set fields 2023-06-05 21:00:08 +00:00
struct-fields-typo.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fields-typo.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fn-in-definition.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-fn-in-definition.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-missing-comma.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-missing-comma.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-missing-comma.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-pat-derived-error.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-pat-derived-error.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-path-alias-bounds.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-path-alias-bounds.stderr Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
struct-path-associated-type.rs diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
struct-path-associated-type.stderr Unify suggestion wording 2023-10-17 17:33:55 +00:00
struct-path-self-type-mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-path-self-type-mismatch.stderr Suggest replacing Self with the right type on type error 2023-11-16 16:19:19 +00:00
struct-path-self.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-path-self.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-record-suggestion.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-record-suggestion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-record-suggestion.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
struct-tuple-field-names.rs better diagnostics for pattern matching tuple structs 2023-03-30 10:38:04 +02:00
struct-tuple-field-names.stderr better diagnostics for pattern matching tuple structs 2023-03-30 10:38:04 +02:00
struct-variant-privacy-xc.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-variant-privacy-xc.stderr Tweak privacy errors to account for reachable items 2023-06-22 16:50:31 +00:00
struct-variant-privacy.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-variant-privacy.stderr Tweak privacy errors to account for reachable items 2023-06-22 16:50:31 +00:00
structure-constructor-type-mismatch.rs diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
structure-constructor-type-mismatch.stderr diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
suggest-private-fields.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest-private-fields.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest-replacing-field-when-specifying-same-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest-replacing-field-when-specifying-same-type.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unresolved-struct-with-fru.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unresolved-struct-with-fru.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00