-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize termination_trait, split out termination_trait_test #49162
Changes from 6 commits
c5c650d
97b3bf9
e5a55e7
be29e52
5ccf3ff
72334fe
1937661
94bdeb6
2cdc7af
b6934c9
2b13d95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// compile-flags: --test | ||
|
||
fn main() {} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() -> Result<(), ()> { | ||
//~^ ERROR functions used as tests must have signature fn() -> () | ||
Ok(()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() -> i32 { //~ ERROR main function has wrong type [E0580] | ||
// error-pattern:`main` can only return types that implement std::process::Termination, not `i32` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if this suggested some types that do work, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's a good idea. In particular, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like fitting the Only question is, will a new Rust user from C who writes For now, I've only included There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The longer explanation at E0580 would do well to give the full list of types implementing Termination in the examples, and link to the std docs for the arcane types. |
||
fn main() -> i32 { | ||
0 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0277]: the trait bound `char: std::process::Termination` is not satisfied | ||
--> $DIR/termination-trait-main-wrong-type.rs:11:14 | ||
| | ||
LL | fn main() -> char { //~ ERROR | ||
| ^^^^ `main` can only return types that implement std::process::Termination, not `char` | ||
| | ||
= help: the trait `std::process::Termination` is not implemented for `char` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build for
accepted
is when it was accepted, right? Which I think will now be 1.26.Also, you could consider making this feature be
termination_trait_main
, which would let all the remaining checks (and attributes in the minimal nightly code) stay unchanged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about this. The tracking issue (#48453) has milestone 1.25.
re:
termination_trait_main
, it makes a little more sense since the trait itself is still not stable. However, it makes just as much sense to me to keep the trait for tests as it is now in the PR. Then we'd havetermination_trait_main
,termination_trait_lib
, andtermination_trait_test
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After re-reading the Forge guide, it should definitely be 1.26. Updated.
For the feature name, I see where you're coming from more now: pull out the thing being stabilized, and leave the unstable stuff in the "main feature." I have no strong preference here at all, and went with the initial recommendation. If two people agree on what it should be, or one person feels more strongly and no one objects, I'll change it to that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good by me! (I try to say "consider" for things I'm not that concerned about.)