-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
8 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,6 +451,7 @@ symbols! { | |
call_once, | ||
caller_location, | ||
capture_disjoint_fields, | ||
cause, | ||
cdylib, | ||
ceilf32, | ||
ceilf64, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Check that we don't blindly emit a diagnostic claiming that "`main` has an invalid return type" | ||
// if we encounter a type that doesn't implement `std::process::Termination` and is not actually | ||
// the return type of the program entry `main`. | ||
|
||
fn receive(_: impl std::process::Termination) {} | ||
|
||
struct Something; | ||
|
||
fn main() { | ||
receive(Something); //~ ERROR the trait bound `Something: Termination` is not satisfied | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0277]: the trait bound `Something: Termination` is not satisfied | ||
--> $DIR/issue-103052-1.rs:10:13 | ||
| | ||
LL | receive(Something); | ||
| ------- ^^^^^^^^^ the trait `Termination` is not implemented for `Something` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `receive` | ||
--> $DIR/issue-103052-1.rs:5:20 | ||
| | ||
LL | fn receive(_: impl std::process::Termination) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `receive` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![feature(return_position_impl_trait_in_trait)] | ||
#![allow(incomplete_features)] | ||
|
||
mod child { | ||
trait Main { | ||
fn main() -> impl std::process::Termination; | ||
} | ||
|
||
struct Something; | ||
|
||
impl Main for () { | ||
fn main() -> Something { //~ ERROR the trait bound `Something: Termination` is not satisfied | ||
Something | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0277]: the trait bound `Something: Termination` is not satisfied | ||
--> $DIR/issue-103052-2.rs:12:22 | ||
| | ||
LL | fn main() -> Something { | ||
| ^^^^^^^^^ the trait `Termination` is not implemented for `Something` | ||
| | ||
note: required by a bound in `Main::main::{opaque#0}` | ||
--> $DIR/issue-103052-2.rs:6:27 | ||
| | ||
LL | fn main() -> impl std::process::Termination; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{opaque#0}` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
5 changes: 2 additions & 3 deletions
5
src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters