about summary refs log tree commit diff
path: root/compiler/rustc_passes
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2022-01-21 00:15:39 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2022-03-05 02:42:55 +0000
commit91f360329926981802f8bf5a320517c3ddd37829 (patch)
treed54e059b902be1bfcb98537cc09e27e8ca3958c4 /compiler/rustc_passes
parent32cbc7630b2d6b7141e2588f91380c1a58cf0016 (diff)
downloadrust-91f360329926981802f8bf5a320517c3ddd37829.tar.gz
rust-91f360329926981802f8bf5a320517c3ddd37829.zip
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.
Diffstat (limited to 'compiler/rustc_passes')
-rw-r--r--compiler/rustc_passes/src/entry.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_passes/src/entry.rs b/compiler/rustc_passes/src/entry.rs
index fdabe41dafa..f5040a373c2 100644
--- a/compiler/rustc_passes/src/entry.rs
+++ b/compiler/rustc_passes/src/entry.rs
@@ -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, &note);
+    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(), &note);
     } else {
         err.note(&note);
     }