You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#64290 - Mark-Simulacrum:span-no-main, r=estebank
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.
Resolvesrust-lang#36561.
Copy file name to clipboardexpand all lines: src/test/ui-fulldeps/hash-stable-is-unstable.stderr
+2-7
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,3 @@
1
-
error[E0601]: `main` function not found in crate `hash_stable_is_unstable`
2
-
|
3
-
= note: consider adding a `main` function to `$DIR/hash-stable-is-unstable.rs`
4
-
5
1
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
6
2
--> $DIR/hash-stable-is-unstable.rs:3:1
7
3
|
@@ -47,7 +43,6 @@ LL | #[derive(HashStable)]
47
43
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
48
44
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
49
45
50
-
error: aborting due to 6 previous errors
46
+
error: aborting due to 5 previous errors
51
47
52
-
Some errors have detailed explanations: E0601, E0658.
53
-
For more information about an error, try `rustc --explain E0601`.
48
+
For more information about this error, try `rustc --explain E0658`.
Copy file name to clipboardexpand all lines: src/test/ui/json-short.stderr
+1-1
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ fn main() {
11
11
12
12
If you don't know the basics of Rust, you can go look to the Rust Book to get
13
13
started: https://doc.rust-lang.org/book/
14
-
"},"level":"error","spans":[],"children":[{"message":"consider adding a `main` function to `$DIR/json-short.rs`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0601]: `main` function not found in crate `json_short`
14
+
"},"level":"error","spans":[{"file_name":"$DIR/json-short.rs","byte_start":76,"byte_end":76,"line_start":2,"line_end":2,"column_start":63,"column_end":63,"is_primary":true,"text":[{"text":"// compile-flags: --json=diagnostic-short --error-format=json","highlight_start":63,"highlight_end":63}],"label":"consider adding a `main` function to `$DIR/json-short.rs`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-short.rs:2:63: error[E0601]: `main` function not found in crate `json_short`
15
15
"}
16
16
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
Copy file name to clipboardexpand all lines: src/test/ui/main-wrong-location.stderr
+13-3
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,21 @@
1
1
error[E0601]: `main` function not found in crate `main_wrong_location`
2
+
--> $DIR/main-wrong-location.rs:1:1
2
3
|
3
-
= 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.
4
-
note: here is a function named 'main'
5
-
--> $DIR/main-wrong-location.rs:4:5
4
+
LL | / mod m {
5
+
LL | |
6
+
LL | | // An inferred main entry point (that doesn't use #[main])
7
+
LL | | // must appear at the top of the crate
8
+
LL | | fn main() { }
9
+
LL | | }
10
+
| |_^ the main function must be defined at the crate level (in `$DIR/main-wrong-location.rs`)
11
+
|
12
+
note: here is a function named `main`
13
+
--> $DIR/main-wrong-location.rs:5:5
6
14
|
7
15
LL | fn main() { }
8
16
| ^^^^^^^^^^^^^
17
+
= note: you have one or more functions named `main` not defined at the crate level
18
+
= help: either move the `main` function definitions or attach the `#[main]` attribute to one of them
0 commit comments