rust/src/test/ui/structs
Dylan DPC 6bf486711b
Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor
fix the false 'defined here' messages

Closes #80853.

Take this code:

```rust
struct S;

fn repro_ref(thing: S) {
    thing();
}
```

Previously, the error message would be this:

```
error[E0618]: expected function, found `S`
 --> src/lib.rs:4:5
  |
3 | fn repro_ref(thing: S) {
  |              ----- `S` defined here
4 |     thing();
  |     ^^^^^--
  |     |
  |     call expression requires function

error: aborting due to previous error
```

This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted:

```
error[E0618]: expected function, found `S`
  --> $DIR/80853.rs:4:5
   |
LL | fn repro_ref(thing: S) {
   |              ----- is of type `S`
LL |     thing();
   |     ^^^^^--
   |     |
   |     call expression requires function
   |
   = note: local variable `S` is not a function

error: aborting due to previous error
```

As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example:

```
LL | struct Empty2;
   | -------------- is of type `Empty2`
```

As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously):

```
LL | struct Empty2;
   | -------------- `Empty2` defined here
```

If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me.

**Update: This is now fixed**

CC `@camelid`
2021-02-25 14:34:00 +01:00
..
auxiliary
80853.rs add helpful error notes and fix the false 'defined here' messages 2021-02-25 16:11:18 +05:30
80853.stderr add helpful error notes and fix the false 'defined here' messages 2021-02-25 16:11:18 +05:30
rhs-type.rs
struct-base-wrong-type.rs
struct-base-wrong-type.stderr
struct-duplicate-comma.fixed Audit uses of span_suggestion_short 2020-07-02 15:18:33 +09:00
struct-duplicate-comma.rs Audit uses of span_suggestion_short 2020-07-02 15:18:33 +09:00
struct-duplicate-comma.stderr Audit uses of span_suggestion_short 2020-07-02 15:18:33 +09:00
struct-field-cfg.rs
struct-field-cfg.stderr Fixing Spelling Typos 2020-11-06 09:25:58 +05:30
struct-field-init-syntax.rs
struct-field-init-syntax.stderr
struct-field-privacy.rs pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
struct-field-privacy.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
struct-fields-decl-dupe.rs
struct-fields-decl-dupe.stderr
struct-fields-dupe.rs
struct-fields-dupe.stderr
struct-fields-hints-no-dupe.rs
struct-fields-hints-no-dupe.stderr
struct-fields-hints.rs
struct-fields-hints.stderr
struct-fields-missing.rs
struct-fields-missing.stderr
struct-fields-shorthand-unresolved.rs
struct-fields-shorthand-unresolved.stderr
struct-fields-shorthand.rs
struct-fields-shorthand.stderr
struct-fields-too-many.rs
struct-fields-too-many.stderr
struct-fields-typo.rs
struct-fields-typo.stderr
struct-missing-comma.fixed Audit uses of span_suggestion_short 2020-07-02 15:18:33 +09:00
struct-missing-comma.rs Audit uses of span_suggestion_short 2020-07-02 15:18:33 +09:00
struct-missing-comma.stderr Audit uses of span_suggestion_short 2020-07-02 15:18:33 +09:00
struct-pat-derived-error.rs
struct-pat-derived-error.stderr Tweak suggestion for missing field in patterns 2021-01-26 11:27:53 -08:00
struct-path-alias-bounds.rs pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
struct-path-alias-bounds.stderr pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
struct-path-associated-type.rs
struct-path-associated-type.stderr
struct-path-self-type-mismatch.rs
struct-path-self-type-mismatch.stderr
struct-path-self.rs
struct-path-self.stderr
struct-tuple-field-names.rs Clarify error message and remove pretty printing in help suggestions. 2021-02-14 13:15:37 -05:00
struct-tuple-field-names.stderr Fix suggestion span and move suggestions into new subwindow. 2021-02-20 15:33:08 -05:00
struct-variant-privacy-xc.rs
struct-variant-privacy-xc.stderr
struct-variant-privacy.rs
struct-variant-privacy.stderr
structure-constructor-type-mismatch.rs Rework diagnostics for wrong number of generic args 2021-01-10 13:07:40 +01:00
structure-constructor-type-mismatch.stderr Rework diagnostics for wrong number of generic args 2021-01-10 13:07:40 +01:00