-
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 5 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 |
---|---|---|
|
@@ -429,8 +429,8 @@ declare_features! ( | |
// `foo.rs` as an alternative to `foo/mod.rs` | ||
(active, non_modrs_mods, "1.24.0", Some(44660), None), | ||
|
||
// Termination trait in main (RFC 1937) | ||
(active, termination_trait, "1.24.0", Some(43301), None), | ||
// Termination trait in tests (RFC 1937) | ||
(active, termination_trait_test, "1.24.0", Some(48854), None), | ||
|
||
// Allows use of the :lifetime macro fragment specifier | ||
(active, macro_lifetime_matcher, "1.24.0", Some(46895), None), | ||
|
@@ -551,6 +551,8 @@ declare_features! ( | |
(accepted, match_beginning_vert, "1.25.0", Some(44101), None), | ||
// Nested groups in `use` (RFC 2128) | ||
(accepted, use_nested_groups, "1.25.0", Some(44494), None), | ||
// Termination trait in main (RFC 1937) | ||
(accepted, termination_trait, "1.25.0", Some(43301), None), | ||
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 build for Also, you could consider making this feature be 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 wasn't sure about this. The tracking issue (#48453) has milestone 1.25. re: 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. 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 commentThe 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.) |
||
// a..=b and ..=b | ||
(accepted, inclusive_range_syntax, "1.26.0", Some(28237), None), | ||
// allow `..=` in patterns (RFC 1192) | ||
|
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 | ||
} |
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 span is specified here; if you look up to line 1028 you can see it comes from the body:
rust/src/librustc_typeck/check/mod.rs
Line 1028 in 5ccf3ff
In general, to get a good span, you want to look to the HIR, which corresponds pretty closely to the input program. In this case, we want to look at the argument
decl
:rust/src/librustc_typeck/check/mod.rs
Line 1001 in 5ccf3ff
The
FnDecl
struct is declared here:rust/src/librustc/hir/mod.rs
Lines 1718 to 1727 in 5ccf3ff
We want to get the span from the return type, for which there is a convenient method:
rust/src/librustc/hir/mod.rs
Lines 1815 to 1820 in 5ccf3ff
So basically the span should be something like:
and use that instead of
span
.