diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2018-04-26 21:33:05 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2018-04-26 21:33:05 -0700 |
| commit | f0069b848606b3e479aa49461b58b1dce6cd5443 (patch) | |
| tree | ef43896e66cc11218af71a1185647ff4677af171 | |
| parent | e05b78daa628ad88952d856c68cb5708434fa934 (diff) | |
| download | rust-f0069b848606b3e479aa49461b58b1dce6cd5443.tar.gz rust-f0069b848606b3e479aa49461b58b1dce6cd5443.zip | |
Add a ui test for an incorrect Result success type in a #[test]
| -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`. |
