Do not point at whole file missing fn main
Only point at the end of the crate. We could try making it point at the beginning of the crate, but that is confused with `DUMMY_SP`, causing the output to be *worse*. This change will make it so that VSCode will *not* underline the whole file when `main` is missing, so other errors will be visible.
This commit is contained in:
parent
32cbc7630b
commit
91f3603299
19 changed files with 54 additions and 103 deletions
|
@ -218,9 +218,9 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
|
|||
// The file may be empty, which leads to the diagnostic machinery not emitting this
|
||||
// note. This is a relatively simple way to detect that case and emit a span-less
|
||||
// note instead.
|
||||
if tcx.sess.source_map().lookup_line(sp.lo()).is_ok() {
|
||||
err.set_span(sp);
|
||||
err.span_label(sp, ¬e);
|
||||
if tcx.sess.source_map().lookup_line(sp.hi()).is_ok() {
|
||||
err.set_span(sp.shrink_to_hi());
|
||||
err.span_label(sp.shrink_to_hi(), ¬e);
|
||||
} else {
|
||||
err.note(¬e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue