Skip to content

Commit 00732a8

Browse files
authored
Rollup merge of #103142 - fmease:fix-103052, r=oli-obk
Make diagnostic for unsatisfied `Termination` bounds more precise Don't blindly emit a diagnostic claiming that “*`main` has an invalid return type*” if we encounter a type that should but doesn't implement `std::process::Termination` and isn't actually the return type of the program entry `main`. Fixes #103052. ``@rustbot`` label A-diagnostics T-compiler T-libs r? diagnostics
2 parents 84b6896 + 350330e commit 00732a8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

std/src/process.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,8 +2154,16 @@ pub fn id() -> u32 {
21542154
#[cfg_attr(not(test), lang = "termination")]
21552155
#[stable(feature = "termination_trait_lib", since = "1.61.0")]
21562156
#[rustc_on_unimplemented(
2157-
message = "`main` has invalid return type `{Self}`",
2158-
label = "`main` can only return types that implement `{Termination}`"
2157+
on(
2158+
all(not(bootstrap), cause = "MainFunctionType"),
2159+
message = "`main` has invalid return type `{Self}`",
2160+
label = "`main` can only return types that implement `{Termination}`"
2161+
),
2162+
on(
2163+
bootstrap,
2164+
message = "`main` has invalid return type `{Self}`",
2165+
label = "`main` can only return types that implement `{Termination}`"
2166+
)
21592167
)]
21602168
pub trait Termination {
21612169
/// Is called to get the representation of the value as status code.

0 commit comments

Comments
 (0)