diff options
| author | bors <bors@rust-lang.org> | 2018-04-30 07:48:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-30 07:48:50 +0000 |
| commit | 7fbc4d881da41782233f8e0993e7613cee73d57b (patch) | |
| tree | 054d1955219d505a1b72be51f715c4c41a67984f /src | |
| parent | 9ff8ec8fdf02b6d8ba35373943e0c6de13597697 (diff) | |
| parent | f0069b848606b3e479aa49461b58b1dce6cd5443 (diff) | |
| download | rust-7fbc4d881da41782233f8e0993e7613cee73d57b.tar.gz rust-7fbc4d881da41782233f8e0993e7613cee73d57b.zip | |
Auto merge of #50272 - scottmcm:termination-test-error, r=nikomatsakis
Add a ui test for an incorrect Result success type in a #[test] cc https://github.com/rust-lang/rust/issues/48854#issuecomment-384730601 r? @nikomatsakis
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr | 14 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs new file mode 100644 index 00000000000..1c00edee770 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs @@ -0,0 +1,20 @@ +// Copyright 2018 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 + +#![feature(termination_trait_test)] + +use std::num::ParseIntError; + +#[test] +fn can_parse_zero_as_f32() -> Result<f32, ParseIntError> { //~ ERROR + "0".parse() +} diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr new file mode 100644 index 00000000000..8efd8a216f1 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -0,0 +1,14 @@ +error[E0277]: `main` has invalid return type `std::result::Result<f32, std::num::ParseIntError>` + --> $DIR/termination-trait-test-wrong-type.rs:18:1 + | +LL | / fn can_parse_zero_as_f32() -> Result<f32, ParseIntError> { //~ ERROR +LL | | "0".parse() +LL | | } + | |_^ `main` can only return types that implement `std::process::Termination` + | + = help: the trait `std::process::Termination` is not implemented for `std::result::Result<f32, std::num::ParseIntError>` + = note: required by `__test::test::assert_test_result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
