-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`
- Loading branch information
Showing
11 changed files
with
67 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const FOO: usize = 0; | ||
|
||
fn main() { | ||
FOO(); //~ ERROR expected function, found `usize` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0618]: expected function, found `usize` | ||
--> $DIR/const-as-fn.rs:4:5 | ||
| | ||
LL | const FOO: usize = 0; | ||
| --------------------- `FOO` defined here | ||
... | ||
LL | FOO(); | ||
| ^^^-- | ||
| | | ||
| call expression requires function | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0618`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
struct S; | ||
|
||
fn repro_ref(thing: S) { | ||
thing(); //~ ERROR expected function, found `S` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0618]: expected function, found `S` | ||
--> $DIR/80853.rs:4:5 | ||
| | ||
LL | fn repro_ref(thing: S) { | ||
| ----- `thing` has type `S` | ||
LL | thing(); | ||
| ^^^^^-- | ||
| | | ||
| call expression requires function | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0618`. |