Skip to content

Commit 7fbc4d8

Browse files
committed
Auto merge of #50272 - scottmcm:termination-test-error, r=nikomatsakis
Add a ui test for an incorrect Result success type in a #[test] cc #48854 (comment) r? @nikomatsakis
2 parents 9ff8ec8 + f0069b8 commit 7fbc4d8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: --test
12+
13+
#![feature(termination_trait_test)]
14+
15+
use std::num::ParseIntError;
16+
17+
#[test]
18+
fn can_parse_zero_as_f32() -> Result<f32, ParseIntError> { //~ ERROR
19+
"0".parse()
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: `main` has invalid return type `std::result::Result<f32, std::num::ParseIntError>`
2+
--> $DIR/termination-trait-test-wrong-type.rs:18:1
3+
|
4+
LL | / fn can_parse_zero_as_f32() -> Result<f32, ParseIntError> { //~ ERROR
5+
LL | | "0".parse()
6+
LL | | }
7+
| |_^ `main` can only return types that implement `std::process::Termination`
8+
|
9+
= help: the trait `std::process::Termination` is not implemented for `std::result::Result<f32, std::num::ParseIntError>`
10+
= note: required by `__test::test::assert_test_result`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)