-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Provide a span if main function is not present in crate #64290
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
2a5e2fe
to
b483725
Compare
I'm curious what issues there are with this, can you say more? (For context, I wrote this note, and at the time I noticed there are a few other diagnostics that don't have spans. I've also written editor integration where it has to handle these kinds of things, so I'm a bit surprised it causes issues. Tools still need to handle diagnostics without filenames.) FWIW, this seems like a good improvement. At the time I didn't know it was possible to generate a span like this. |
r=me once green |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
It's not completely clear exactly where the problems arise, but I was able to trigger an ICE or two, particularly with |
b483725
to
8f64e38
Compare
Ah, I also forgot to mention -- in some situations, I was unable to trigger an ICE with the normal machinery (though |
8f64e38
to
fa1ea7e
Compare
This comment has been minimized.
This comment has been minimized.
fa1ea7e
to
7dcf410
Compare
This comment has been minimized.
This comment has been minimized.
7dcf410
to
0b65805
Compare
This comment has been minimized.
This comment has been minimized.
0b65805
to
e04684e
Compare
This comment has been minimized.
This comment has been minimized.
e04684e
to
5021431
Compare
This comment has been minimized.
This comment has been minimized.
5021431
to
7583b98
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/librustc/middle/entry.rs
Outdated
err.note("the main function must be defined at the crate level \ | ||
but you have one or more functions named 'main' that are not \ | ||
defined at the crate level. Either move the definition or \ | ||
attach the `#[main]` attribute to override this behavior."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have a span pointing at where the main
function should be, like we're doing below?
src/librustc/middle/entry.rs
Outdated
None | ||
if tcx.sess.teach(&err.get_code().unwrap()) { | ||
err.note("If you don't know the basics of Rust, you can go look to the Rust Book \ | ||
to get started: https://doc.rust-lang.org/book/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation on both strings is off by two chars :)
7583b98
to
66e2d93
Compare
…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 retry rolled up. |
Unfortunately, the diagnotic 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.
6dc1483
to
b7f20d0
Compare
@bors r=estebank Ran with compare-mode=nll; can't wait until we can remove it. |
📌 Commit b7f20d0 has been approved by |
⌛ Testing commit b7f20d0 with merge 5453909254f2181a201c47c471a64ddc0f652b10... |
…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 retry rolled up. |
⌛ Testing commit b7f20d0 with merge 97ec3ff09407d4f17fedac2262e61fb69cc61351... |
…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 retry rolled up. |
rust-lang/rust#64290 changed that lint output causing test error, however there is no point in keeping this lint stderr
rust-lang/rust#64290 changed that lint output causing test error, however there is no point in keeping this lint stderr
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 #36561.