Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error without location #36561

Closed
alygin opened this issue Sep 18, 2016 · 2 comments · Fixed by #64290
Closed

Error without location #36561

alygin opened this issue Sep 18, 2016 · 2 comments · Fixed by #64290
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alygin
Copy link
Contributor

alygin commented Sep 18, 2016

There're two known compiler errors that provide no location information:

error: main function not found
error: aborting due to previous error

It holds true for both the standard output and the JSON error format.

While the latter is a meta error and obviously is not related to a particular place in the source code, the former one could at least come with a file name. It would be of use to both humans and IDEs, particularly when there're several executables in a single project (in the examples or src/bin folders).

Since there's always a particular file in which rustc is looking for the main() function, this file name should be mentioned in the message either with the 1:1 position, or with no position at all. This would let the user or IDE to quickly jump directly to the file in which the problem must be fixed.

@TimNN TimNN added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 18, 2016
@steveklabnik steveklabnik added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@estebank
Copy link
Contributor

Current output:

$ rustc file.rs
error[E0601]: `main` function not found in crate `file`
  |
  = note: consider adding a `main` function to `file.rs`

@alygin
Copy link
Contributor Author

alygin commented Jun 19, 2018

@estebank, thank you for the notice, the output surely looks much better now. Though, it still lacks a code reference that would conform with other error messages and could be used by parsers.

I mean something like this:

$ rustc file.rs
error[E0601]: `main` function not found in crate `file`
 --> file.rs
  |
  = note: consider adding a `main` function to `file.rs`

Extracting the file name from the note text, which is a subject to occasional change, doesn't seem like a reliable approach.

Centril added a commit to Centril/rust that referenced this issue Sep 14, 2019
…ebank

Provide a span if main function is not present in crate

Unfortunately, the diagnostic machinery does not cope well with an empty
span which can happen if the crate is empty, in which case we merely set
a spanless note.

Tests are already updated for this change, so a dedicated test is not added.

Resolves rust-lang#36561.
Centril added a commit to Centril/rust that referenced this issue Sep 14, 2019
…ebank

Provide a span if main function is not present in crate

Unfortunately, the diagnostic machinery does not cope well with an empty
span which can happen if the crate is empty, in which case we merely set
a spanless note.

Tests are already updated for this change, so a dedicated test is not added.

Resolves rust-lang#36561.
Centril added a commit to Centril/rust that referenced this issue Sep 14, 2019
…ebank

Provide a span if main function is not present in crate

Unfortunately, the diagnostic machinery does not cope well with an empty
span which can happen if the crate is empty, in which case we merely set
a spanless note.

Tests are already updated for this change, so a dedicated test is not added.

Resolves rust-lang#36561.
@bors bors closed this as completed in d29df01 Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants