From 8e11189cbb129b5df33e27d21c077da6cfc5926f Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Fri, 23 Jun 2017 17:43:35 -0700 Subject: Move tests to `ui` --- .../compile-fail/block-must-not-have-result-do.rs | 15 -------- .../compile-fail/block-must-not-have-result-res.rs | 20 ---------- .../block-must-not-have-result-while.rs | 18 --------- .../compile-fail/consider-removing-last-semi.rs | 21 ----------- src/test/compile-fail/for-loop-has-unit-body.rs | 17 --------- src/test/compile-fail/issue-11714.rs | 17 --------- src/test/compile-fail/issue-13428.rs | 26 ------------- src/test/compile-fail/issue-13624.rs | 43 ---------------------- src/test/compile-fail/issue-20862.rs | 19 ---------- src/test/compile-fail/issue-22645.rs | 27 -------------- src/test/compile-fail/issue-3563.rs | 18 --------- src/test/compile-fail/issue-5500.rs | 17 --------- .../block-result/block-must-not-have-result-do.rs | 15 ++++++++ .../block-must-not-have-result-do.stderr | 11 ++++++ .../block-result/block-must-not-have-result-res.rs | 20 ++++++++++ .../block-must-not-have-result-res.stderr | 11 ++++++ .../block-must-not-have-result-while.rs | 18 +++++++++ .../block-must-not-have-result-while.stderr | 11 ++++++ .../ui/block-result/consider-removing-last-semi.rs | 21 +++++++++++ .../consider-removing-last-semi.stderr | 38 +++++++++++++++++++ .../ui/block-result/expected-return-on-unit.stderr | 4 ++ src/test/ui/block-result/issue-11714.rs | 17 +++++++++ src/test/ui/block-result/issue-11714.stderr | 21 +++++++++++ src/test/ui/block-result/issue-13428.rs | 26 +++++++++++++ src/test/ui/block-result/issue-13428.stderr | 41 +++++++++++++++++++++ src/test/ui/block-result/issue-13624.rs | 43 ++++++++++++++++++++++ src/test/ui/block-result/issue-13624.stderr | 20 ++++++++++ src/test/ui/block-result/issue-20862.rs | 19 ++++++++++ src/test/ui/block-result/issue-20862.stderr | 17 +++++++++ src/test/ui/block-result/issue-22645.rs | 27 ++++++++++++++ src/test/ui/block-result/issue-22645.stderr | 21 +++++++++++ src/test/ui/block-result/issue-3563.rs | 18 +++++++++ src/test/ui/block-result/issue-3563.stderr | 17 +++++++++ src/test/ui/block-result/issue-5500.rs | 17 +++++++++ src/test/ui/block-result/issue-5500.stderr | 11 ++++++ .../ui/block-result/unexpected-return-on-unit.rs | 24 ++++++++++++ .../block-result/unexpected-return-on-unit.stderr | 11 ++++++ .../ui/mismatched_types/for-loop-has-unit-body.rs | 17 +++++++++ .../mismatched_types/for-loop-has-unit-body.stderr | 11 ++++++ 39 files changed, 527 insertions(+), 258 deletions(-) delete mode 100644 src/test/compile-fail/block-must-not-have-result-do.rs delete mode 100644 src/test/compile-fail/block-must-not-have-result-res.rs delete mode 100644 src/test/compile-fail/block-must-not-have-result-while.rs delete mode 100644 src/test/compile-fail/consider-removing-last-semi.rs delete mode 100644 src/test/compile-fail/for-loop-has-unit-body.rs delete mode 100644 src/test/compile-fail/issue-11714.rs delete mode 100644 src/test/compile-fail/issue-13428.rs delete mode 100644 src/test/compile-fail/issue-13624.rs delete mode 100644 src/test/compile-fail/issue-20862.rs delete mode 100644 src/test/compile-fail/issue-22645.rs delete mode 100644 src/test/compile-fail/issue-3563.rs delete mode 100644 src/test/compile-fail/issue-5500.rs create mode 100644 src/test/ui/block-result/block-must-not-have-result-do.rs create mode 100644 src/test/ui/block-result/block-must-not-have-result-do.stderr create mode 100644 src/test/ui/block-result/block-must-not-have-result-res.rs create mode 100644 src/test/ui/block-result/block-must-not-have-result-res.stderr create mode 100644 src/test/ui/block-result/block-must-not-have-result-while.rs create mode 100644 src/test/ui/block-result/block-must-not-have-result-while.stderr create mode 100644 src/test/ui/block-result/consider-removing-last-semi.rs create mode 100644 src/test/ui/block-result/consider-removing-last-semi.stderr create mode 100644 src/test/ui/block-result/expected-return-on-unit.stderr create mode 100644 src/test/ui/block-result/issue-11714.rs create mode 100644 src/test/ui/block-result/issue-11714.stderr create mode 100644 src/test/ui/block-result/issue-13428.rs create mode 100644 src/test/ui/block-result/issue-13428.stderr create mode 100644 src/test/ui/block-result/issue-13624.rs create mode 100644 src/test/ui/block-result/issue-13624.stderr create mode 100644 src/test/ui/block-result/issue-20862.rs create mode 100644 src/test/ui/block-result/issue-20862.stderr create mode 100644 src/test/ui/block-result/issue-22645.rs create mode 100644 src/test/ui/block-result/issue-22645.stderr create mode 100644 src/test/ui/block-result/issue-3563.rs create mode 100644 src/test/ui/block-result/issue-3563.stderr create mode 100644 src/test/ui/block-result/issue-5500.rs create mode 100644 src/test/ui/block-result/issue-5500.stderr create mode 100644 src/test/ui/block-result/unexpected-return-on-unit.rs create mode 100644 src/test/ui/block-result/unexpected-return-on-unit.stderr create mode 100644 src/test/ui/mismatched_types/for-loop-has-unit-body.rs create mode 100644 src/test/ui/mismatched_types/for-loop-has-unit-body.stderr diff --git a/src/test/compile-fail/block-must-not-have-result-do.rs b/src/test/compile-fail/block-must-not-have-result-do.rs deleted file mode 100644 index 2a6c71dbe39..00000000000 --- a/src/test/compile-fail/block-must-not-have-result-do.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - loop { - true //~ ERROR mismatched types - } -} diff --git a/src/test/compile-fail/block-must-not-have-result-res.rs b/src/test/compile-fail/block-must-not-have-result-res.rs deleted file mode 100644 index 8728685fc8b..00000000000 --- a/src/test/compile-fail/block-must-not-have-result-res.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct r; - -impl Drop for r { - fn drop(&mut self) { - true //~ ERROR mismatched types - } -} - -fn main() { -} diff --git a/src/test/compile-fail/block-must-not-have-result-while.rs b/src/test/compile-fail/block-must-not-have-result-while.rs deleted file mode 100644 index a0fb470e1e4..00000000000 --- a/src/test/compile-fail/block-must-not-have-result-while.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - while true { - true //~ ERROR mismatched types - //~| expected type `()` - //~| found type `bool` - //~| expected (), found bool - } -} diff --git a/src/test/compile-fail/consider-removing-last-semi.rs b/src/test/compile-fail/consider-removing-last-semi.rs deleted file mode 100644 index 530a0e41562..00000000000 --- a/src/test/compile-fail/consider-removing-last-semi.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> String { //~ ERROR mismatched types - 0u8; - "bla".to_string(); //~ HELP consider removing this semicolon -} - -fn g() -> String { //~ ERROR mismatched types - "this won't work".to_string(); - "removeme".to_string(); //~ HELP consider removing this semicolon -} - -fn main() {} diff --git a/src/test/compile-fail/for-loop-has-unit-body.rs b/src/test/compile-fail/for-loop-has-unit-body.rs deleted file mode 100644 index 8c61fc602e0..00000000000 --- a/src/test/compile-fail/for-loop-has-unit-body.rs +++ /dev/null @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - for x in 0..3 { - x //~ ERROR mismatched types - //~| NOTE expected () - //~| NOTE expected type `()` - } -} diff --git a/src/test/compile-fail/issue-11714.rs b/src/test/compile-fail/issue-11714.rs deleted file mode 100644 index 192f78e41cb..00000000000 --- a/src/test/compile-fail/issue-11714.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn blah() -> i32 { //~ ERROR mismatched types - 1 - - ; //~ HELP consider removing this semicolon: -} - -fn main() { } diff --git a/src/test/compile-fail/issue-13428.rs b/src/test/compile-fail/issue-13428.rs deleted file mode 100644 index 9406199afc2..00000000000 --- a/src/test/compile-fail/issue-13428.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for #13428 - -fn foo() -> String { //~ ERROR mismatched types - format!("Hello {}", - "world") - // Put the trailing semicolon on its own line to test that the - // note message gets the offending semicolon exactly - ; //~ HELP consider removing this semicolon -} - -fn bar() -> String { //~ ERROR mismatched types - "foobar".to_string() - ; //~ HELP consider removing this semicolon -} - -pub fn main() {} diff --git a/src/test/compile-fail/issue-13624.rs b/src/test/compile-fail/issue-13624.rs deleted file mode 100644 index e4ed87c3cb0..00000000000 --- a/src/test/compile-fail/issue-13624.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub enum Enum { - EnumStructVariant { x: u8, y: u8, z: u8 } - } - - pub fn get_enum_struct_variant() -> () { - Enum::EnumStructVariant { x: 1, y: 2, z: 3 } - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `a::Enum` - //~| expected (), found enum `a::Enum` - } -} - -mod b { - mod test { - use a; - - fn test_enum_struct_variant() { - let enum_struct_variant = ::a::get_enum_struct_variant(); - match enum_struct_variant { - a::Enum::EnumStructVariant { x, y, z } => { - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `a::Enum` - //~| expected (), found enum `a::Enum` - } - } - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/issue-20862.rs b/src/test/compile-fail/issue-20862.rs deleted file mode 100644 index 9df63583998..00000000000 --- a/src/test/compile-fail/issue-20862.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: i32) { - |y| x + y -//~^ ERROR: mismatched types -} - -fn main() { - let x = foo(5)(2); -//~^ ERROR: expected function, found `()` -} diff --git a/src/test/compile-fail/issue-22645.rs b/src/test/compile-fail/issue-22645.rs deleted file mode 100644 index 81f66e3e2cf..00000000000 --- a/src/test/compile-fail/issue-22645.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Add; - -trait Scalar {} -impl Scalar for f64 {} - -struct Bob; - -impl Add for Bob { - type Output = Bob; - fn add(self, rhs : RHS) -> Bob { Bob } -} - -fn main() { - let b = Bob + 3.5; - b + 3 //~ ERROR E0277 - //~^ ERROR: mismatched types -} diff --git a/src/test/compile-fail/issue-3563.rs b/src/test/compile-fail/issue-3563.rs deleted file mode 100644 index 7928c04b9df..00000000000 --- a/src/test/compile-fail/issue-3563.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait A { - fn a(&self) { - || self.b() - //~^ ERROR no method named `b` found for type `&Self` in the current scope - //~| ERROR mismatched types - } -} -fn main() {} diff --git a/src/test/compile-fail/issue-5500.rs b/src/test/compile-fail/issue-5500.rs deleted file mode 100644 index 1cbb7588e17..00000000000 --- a/src/test/compile-fail/issue-5500.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - &panic!() - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `&_` - //~| expected (), found reference -} diff --git a/src/test/ui/block-result/block-must-not-have-result-do.rs b/src/test/ui/block-result/block-must-not-have-result-do.rs new file mode 100644 index 00000000000..2a6c71dbe39 --- /dev/null +++ b/src/test/ui/block-result/block-must-not-have-result-do.rs @@ -0,0 +1,15 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + loop { + true //~ ERROR mismatched types + } +} diff --git a/src/test/ui/block-result/block-must-not-have-result-do.stderr b/src/test/ui/block-result/block-must-not-have-result-do.stderr new file mode 100644 index 00000000000..a770ebeab35 --- /dev/null +++ b/src/test/ui/block-result/block-must-not-have-result-do.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/block-must-not-have-result-do.rs:13:9 + | +13 | true //~ ERROR mismatched types + | ^^^^ expected (), found bool + | + = note: expected type `()` + found type `bool` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/block-must-not-have-result-res.rs b/src/test/ui/block-result/block-must-not-have-result-res.rs new file mode 100644 index 00000000000..8728685fc8b --- /dev/null +++ b/src/test/ui/block-result/block-must-not-have-result-res.rs @@ -0,0 +1,20 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct r; + +impl Drop for r { + fn drop(&mut self) { + true //~ ERROR mismatched types + } +} + +fn main() { +} diff --git a/src/test/ui/block-result/block-must-not-have-result-res.stderr b/src/test/ui/block-result/block-must-not-have-result-res.stderr new file mode 100644 index 00000000000..b1146864566 --- /dev/null +++ b/src/test/ui/block-result/block-must-not-have-result-res.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/block-must-not-have-result-res.rs:15:9 + | +15 | true //~ ERROR mismatched types + | ^^^^ expected (), found bool + | + = note: expected type `()` + found type `bool` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/block-must-not-have-result-while.rs b/src/test/ui/block-result/block-must-not-have-result-while.rs new file mode 100644 index 00000000000..a0fb470e1e4 --- /dev/null +++ b/src/test/ui/block-result/block-must-not-have-result-while.rs @@ -0,0 +1,18 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + while true { + true //~ ERROR mismatched types + //~| expected type `()` + //~| found type `bool` + //~| expected (), found bool + } +} diff --git a/src/test/ui/block-result/block-must-not-have-result-while.stderr b/src/test/ui/block-result/block-must-not-have-result-while.stderr new file mode 100644 index 00000000000..31ec7cdd3c5 --- /dev/null +++ b/src/test/ui/block-result/block-must-not-have-result-while.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/block-must-not-have-result-while.rs:13:9 + | +13 | true //~ ERROR mismatched types + | ^^^^ expected (), found bool + | + = note: expected type `()` + found type `bool` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/consider-removing-last-semi.rs b/src/test/ui/block-result/consider-removing-last-semi.rs new file mode 100644 index 00000000000..530a0e41562 --- /dev/null +++ b/src/test/ui/block-result/consider-removing-last-semi.rs @@ -0,0 +1,21 @@ +// Copyright 2016 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> String { //~ ERROR mismatched types + 0u8; + "bla".to_string(); //~ HELP consider removing this semicolon +} + +fn g() -> String { //~ ERROR mismatched types + "this won't work".to_string(); + "removeme".to_string(); //~ HELP consider removing this semicolon +} + +fn main() {} diff --git a/src/test/ui/block-result/consider-removing-last-semi.stderr b/src/test/ui/block-result/consider-removing-last-semi.stderr new file mode 100644 index 00000000000..944c9d6c427 --- /dev/null +++ b/src/test/ui/block-result/consider-removing-last-semi.stderr @@ -0,0 +1,38 @@ +error[E0308]: mismatched types + --> $DIR/consider-removing-last-semi.rs:11:18 + | +11 | fn f() -> String { //~ ERROR mismatched types + | __________________^ +12 | | 0u8; +13 | | "bla".to_string(); //~ HELP consider removing this semicolon +14 | | } + | |_^ expected struct `std::string::String`, found () + | + = note: expected type `std::string::String` + found type `()` +help: consider removing this semicolon: + --> $DIR/consider-removing-last-semi.rs:13:22 + | +13 | "bla".to_string(); //~ HELP consider removing this semicolon + | ^ + +error[E0308]: mismatched types + --> $DIR/consider-removing-last-semi.rs:16:18 + | +16 | fn g() -> String { //~ ERROR mismatched types + | __________________^ +17 | | "this won't work".to_string(); +18 | | "removeme".to_string(); //~ HELP consider removing this semicolon +19 | | } + | |_^ expected struct `std::string::String`, found () + | + = note: expected type `std::string::String` + found type `()` +help: consider removing this semicolon: + --> $DIR/consider-removing-last-semi.rs:18:27 + | +18 | "removeme".to_string(); //~ HELP consider removing this semicolon + | ^ + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/expected-return-on-unit.stderr b/src/test/ui/block-result/expected-return-on-unit.stderr new file mode 100644 index 00000000000..8a0d7a335d6 --- /dev/null +++ b/src/test/ui/block-result/expected-return-on-unit.stderr @@ -0,0 +1,4 @@ +error[E0601]: main function not found + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-11714.rs b/src/test/ui/block-result/issue-11714.rs new file mode 100644 index 00000000000..192f78e41cb --- /dev/null +++ b/src/test/ui/block-result/issue-11714.rs @@ -0,0 +1,17 @@ +// Copyright 2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn blah() -> i32 { //~ ERROR mismatched types + 1 + + ; //~ HELP consider removing this semicolon: +} + +fn main() { } diff --git a/src/test/ui/block-result/issue-11714.stderr b/src/test/ui/block-result/issue-11714.stderr new file mode 100644 index 00000000000..cba9c3f51d7 --- /dev/null +++ b/src/test/ui/block-result/issue-11714.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-11714.rs:11:18 + | +11 | fn blah() -> i32 { //~ ERROR mismatched types + | __________________^ +12 | | 1 +13 | | +14 | | ; //~ HELP consider removing this semicolon: +15 | | } + | |_^ expected i32, found () + | + = note: expected type `i32` + found type `()` +help: consider removing this semicolon: + --> $DIR/issue-11714.rs:14:5 + | +14 | ; //~ HELP consider removing this semicolon: + | ^ + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-13428.rs b/src/test/ui/block-result/issue-13428.rs new file mode 100644 index 00000000000..9406199afc2 --- /dev/null +++ b/src/test/ui/block-result/issue-13428.rs @@ -0,0 +1,26 @@ +// Copyright 2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #13428 + +fn foo() -> String { //~ ERROR mismatched types + format!("Hello {}", + "world") + // Put the trailing semicolon on its own line to test that the + // note message gets the offending semicolon exactly + ; //~ HELP consider removing this semicolon +} + +fn bar() -> String { //~ ERROR mismatched types + "foobar".to_string() + ; //~ HELP consider removing this semicolon +} + +pub fn main() {} diff --git a/src/test/ui/block-result/issue-13428.stderr b/src/test/ui/block-result/issue-13428.stderr new file mode 100644 index 00000000000..d0ed8935cd7 --- /dev/null +++ b/src/test/ui/block-result/issue-13428.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/issue-13428.rs:13:20 + | +13 | fn foo() -> String { //~ ERROR mismatched types + | ____________________^ +14 | | format!("Hello {}", +15 | | "world") +16 | | // Put the trailing semicolon on its own line to test that the +17 | | // note message gets the offending semicolon exactly +18 | | ; //~ HELP consider removing this semicolon +19 | | } + | |_^ expected struct `std::string::String`, found () + | + = note: expected type `std::string::String` + found type `()` +help: consider removing this semicolon: + --> $DIR/issue-13428.rs:18:5 + | +18 | ; //~ HELP consider removing this semicolon + | ^ + +error[E0308]: mismatched types + --> $DIR/issue-13428.rs:21:20 + | +21 | fn bar() -> String { //~ ERROR mismatched types + | ____________________^ +22 | | "foobar".to_string() +23 | | ; //~ HELP consider removing this semicolon +24 | | } + | |_^ expected struct `std::string::String`, found () + | + = note: expected type `std::string::String` + found type `()` +help: consider removing this semicolon: + --> $DIR/issue-13428.rs:23:5 + | +23 | ; //~ HELP consider removing this semicolon + | ^ + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-13624.rs b/src/test/ui/block-result/issue-13624.rs new file mode 100644 index 00000000000..e4ed87c3cb0 --- /dev/null +++ b/src/test/ui/block-result/issue-13624.rs @@ -0,0 +1,43 @@ +// Copyright 2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + pub enum Enum { + EnumStructVariant { x: u8, y: u8, z: u8 } + } + + pub fn get_enum_struct_variant() -> () { + Enum::EnumStructVariant { x: 1, y: 2, z: 3 } + //~^ ERROR mismatched types + //~| expected type `()` + //~| found type `a::Enum` + //~| expected (), found enum `a::Enum` + } +} + +mod b { + mod test { + use a; + + fn test_enum_struct_variant() { + let enum_struct_variant = ::a::get_enum_struct_variant(); + match enum_struct_variant { + a::Enum::EnumStructVariant { x, y, z } => { + //~^ ERROR mismatched types + //~| expected type `()` + //~| found type `a::Enum` + //~| expected (), found enum `a::Enum` + } + } + } + } +} + +fn main() {} diff --git a/src/test/ui/block-result/issue-13624.stderr b/src/test/ui/block-result/issue-13624.stderr new file mode 100644 index 00000000000..72ff859d7e9 --- /dev/null +++ b/src/test/ui/block-result/issue-13624.stderr @@ -0,0 +1,20 @@ +error[E0308]: mismatched types + --> $DIR/issue-13624.rs:17:5 + | +17 | Enum::EnumStructVariant { x: 1, y: 2, z: 3 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum` + | + = note: expected type `()` + found type `a::Enum` + +error[E0308]: mismatched types + --> $DIR/issue-13624.rs:32:9 + | +32 | a::Enum::EnumStructVariant { x, y, z } => { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum` + | + = note: expected type `()` + found type `a::Enum` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-20862.rs b/src/test/ui/block-result/issue-20862.rs new file mode 100644 index 00000000000..9df63583998 --- /dev/null +++ b/src/test/ui/block-result/issue-20862.rs @@ -0,0 +1,19 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: i32) { + |y| x + y +//~^ ERROR: mismatched types +} + +fn main() { + let x = foo(5)(2); +//~^ ERROR: expected function, found `()` +} diff --git a/src/test/ui/block-result/issue-20862.stderr b/src/test/ui/block-result/issue-20862.stderr new file mode 100644 index 00000000000..757fe1666c3 --- /dev/null +++ b/src/test/ui/block-result/issue-20862.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-20862.rs:12:5 + | +12 | |y| x + y + | ^^^^^^^^^ expected (), found closure + | + = note: expected type `()` + found type `[closure@$DIR/issue-20862.rs:12:5: 12:14 x:_]` + +error[E0618]: expected function, found `()` + --> $DIR/issue-20862.rs:17:13 + | +17 | let x = foo(5)(2); + | ^^^^^^^^^ + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-22645.rs b/src/test/ui/block-result/issue-22645.rs new file mode 100644 index 00000000000..81f66e3e2cf --- /dev/null +++ b/src/test/ui/block-result/issue-22645.rs @@ -0,0 +1,27 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Add; + +trait Scalar {} +impl Scalar for f64 {} + +struct Bob; + +impl Add for Bob { + type Output = Bob; + fn add(self, rhs : RHS) -> Bob { Bob } +} + +fn main() { + let b = Bob + 3.5; + b + 3 //~ ERROR E0277 + //~^ ERROR: mismatched types +} diff --git a/src/test/ui/block-result/issue-22645.stderr b/src/test/ui/block-result/issue-22645.stderr new file mode 100644 index 00000000000..3921a301c92 --- /dev/null +++ b/src/test/ui/block-result/issue-22645.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `{integer}: Scalar` is not satisfied + --> $DIR/issue-22645.rs:25:5 + | +25 | b + 3 //~ ERROR E0277 + | ^ the trait `Scalar` is not implemented for `{integer}` + | + = help: the following implementations were found: + + = note: required because of the requirements on the impl of `std::ops::Add<{integer}>` for `Bob` + +error[E0308]: mismatched types + --> $DIR/issue-22645.rs:25:3 + | +25 | b + 3 //~ ERROR E0277 + | ^^^^^ expected (), found struct `Bob` + | + = note: expected type `()` + found type `Bob` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-3563.rs b/src/test/ui/block-result/issue-3563.rs new file mode 100644 index 00000000000..7928c04b9df --- /dev/null +++ b/src/test/ui/block-result/issue-3563.rs @@ -0,0 +1,18 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait A { + fn a(&self) { + || self.b() + //~^ ERROR no method named `b` found for type `&Self` in the current scope + //~| ERROR mismatched types + } +} +fn main() {} diff --git a/src/test/ui/block-result/issue-3563.stderr b/src/test/ui/block-result/issue-3563.stderr new file mode 100644 index 00000000000..9b403bcd93d --- /dev/null +++ b/src/test/ui/block-result/issue-3563.stderr @@ -0,0 +1,17 @@ +error[E0599]: no method named `b` found for type `&Self` in the current scope + --> $DIR/issue-3563.rs:13:17 + | +13 | || self.b() + | ^ + +error[E0308]: mismatched types + --> $DIR/issue-3563.rs:13:9 + | +13 | || self.b() + | ^^^^^^^^^^^ expected (), found closure + | + = note: expected type `()` + found type `[closure@$DIR/issue-3563.rs:13:9: 13:20 self:_]` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/issue-5500.rs b/src/test/ui/block-result/issue-5500.rs new file mode 100644 index 00000000000..1cbb7588e17 --- /dev/null +++ b/src/test/ui/block-result/issue-5500.rs @@ -0,0 +1,17 @@ +// Copyright 2013 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + &panic!() + //~^ ERROR mismatched types + //~| expected type `()` + //~| found type `&_` + //~| expected (), found reference +} diff --git a/src/test/ui/block-result/issue-5500.stderr b/src/test/ui/block-result/issue-5500.stderr new file mode 100644 index 00000000000..bffe2a82ca8 --- /dev/null +++ b/src/test/ui/block-result/issue-5500.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/issue-5500.rs:12:5 + | +12 | &panic!() + | ^^^^^^^^^ expected (), found reference + | + = note: expected type `()` + found type `&_` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/block-result/unexpected-return-on-unit.rs b/src/test/ui/block-result/unexpected-return-on-unit.rs new file mode 100644 index 00000000000..291b7a16f14 --- /dev/null +++ b/src/test/ui/block-result/unexpected-return-on-unit.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we do some basic error correcton in the tokeniser (and don't spew +// too many bogus errors). + +fn foo() -> usize { + 3 +} + +fn bar() { + foo() +} + +fn main() { + bar() +} diff --git a/src/test/ui/block-result/unexpected-return-on-unit.stderr b/src/test/ui/block-result/unexpected-return-on-unit.stderr new file mode 100644 index 00000000000..ad10312d064 --- /dev/null +++ b/src/test/ui/block-result/unexpected-return-on-unit.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/unexpected-return-on-unit.rs:19:5 + | +19 | foo() + | ^^^^^ expected (), found usize + | + = note: expected type `()` + found type `usize` + +error: aborting due to previous error(s) + diff --git a/src/test/ui/mismatched_types/for-loop-has-unit-body.rs b/src/test/ui/mismatched_types/for-loop-has-unit-body.rs new file mode 100644 index 00000000000..8c61fc602e0 --- /dev/null +++ b/src/test/ui/mismatched_types/for-loop-has-unit-body.rs @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + for x in 0..3 { + x //~ ERROR mismatched types + //~| NOTE expected () + //~| NOTE expected type `()` + } +} diff --git a/src/test/ui/mismatched_types/for-loop-has-unit-body.stderr b/src/test/ui/mismatched_types/for-loop-has-unit-body.stderr new file mode 100644 index 00000000000..6787fe91bf3 --- /dev/null +++ b/src/test/ui/mismatched_types/for-loop-has-unit-body.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/for-loop-has-unit-body.rs:13:9 + | +13 | x //~ ERROR mismatched types + | ^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error: aborting due to previous error(s) + -- cgit 1.4.1-3-g733a5