-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code: link
use std::process::Termination;
fn foo<T: Termination>(_: T) {}
fn bar() {foo(1_i32);}
The current output is:
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): `main` has invalid return type `i32`
--> src/lib.rs:3:15
|
3 | fn bar() {foo(1_i32);}
| --- ^^^^^ `main` can only return types that implement `Termination`
| |
| required by a bound introduced by this call
|
= help: the trait `Termination` is not implemented for `i32`
note: required by a bound in `foo`
--> src/lib.rs:2:11
|
2 | fn foo<T: Termination>(_: T) {}
| ^^^^^^^^^^^ required by this bound in `foo`
Ideally the output should look like:
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `i32: std::process::Termination` is not satisfied
--> src/lib.rs:3:15
|
3 | fn bar() {foo(1_i32);}
| --- ^^^^^ the trait `std::process::Termination` is not implemented for `i32`
| |
| required by a bound introduced by this call
rust/library/std/src/process.rs
Lines 2154 to 2160 in 3271760
#[cfg_attr(not(test), lang = "termination")] | |
#[stable(feature = "termination_trait_lib", since = "1.61.0")] | |
#[rustc_on_unimplemented( | |
message = "`main` has invalid return type `{Self}`", | |
label = "`main` can only return types that implement `{Termination}`" | |
)] | |
pub trait Termination { |
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.