-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 2 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] | ||
fn main() -> i32 { | ||
//~^ ERROR the trait bound `i32: std::process::Termination` is not satisfied [E0277] | ||
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. Hmm, this is not your fault, but this error message seems less clear than before. @estebank -- can we improve this readily enough with a 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. Yes, you could annotate 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 looks like there is already a 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. Nevermind, once I cleaned my rustc build the note showed up. But since it's a label, not the primary error message, I had to use the 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. For what it's worth, you have further control on the That way, after including Niko's span change you could have the following output:
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.
You didn't need to use
instead for labels. |
||
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
.