about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-05-29 11:32:14 +0000
committerbors <bors@rust-lang.org>2017-05-29 11:32:14 +0000
commit03bed655142dd5e42ba4539de53b3663d8a123e0 (patch)
tree2ee6c7a5bbe59f2f62675d772ecb7ec1d49f2212 /src/test
parentbe5f4fe6cc7179b900eb31ee3e9235fd12bd04c7 (diff)
parent99993780dc2db803877ed700cbf315246fc3ad7f (diff)
downloadrust-03bed655142dd5e42ba4539de53b3663d8a123e0.tar.gz
rust-03bed655142dd5e42ba4539de53b3663d8a123e0.zip
Auto merge of #41856 - qnighy:prohibit-parenthesized-params-in-more-types, r=arielb1
Prohibit parenthesized params in more types.

Prohibit parenthesized parameters in primitive types, type parameters, `Self`, etc.

Fixes #32995.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-22560.rs5
-rw-r--r--src/test/compile-fail/issue-32995-2.rs36
-rw-r--r--src/test/compile-fail/issue-32995.rs62
3 files changed, 102 insertions, 1 deletions
diff --git a/src/test/compile-fail/issue-22560.rs b/src/test/compile-fail/issue-22560.rs
index 2ad804fc8ce..eb5c6076440 100644
--- a/src/test/compile-fail/issue-22560.rs
+++ b/src/test/compile-fail/issue-22560.rs
@@ -19,7 +19,10 @@ type Test = Add +
             //~| ERROR E0191
             //~| NOTE missing associated type `Output` value
             Sub;
-            //~^ ERROR E0225
+            //~^ ERROR E0393
+            //~| NOTE missing reference to `RHS`
+            //~| NOTE because of the default `Self` reference, type parameters must be specified on object types
+            //~| ERROR E0225
             //~| NOTE non-Send/Sync additional trait
 
 fn main() { }
diff --git a/src/test/compile-fail/issue-32995-2.rs b/src/test/compile-fail/issue-32995-2.rs
new file mode 100644
index 00000000000..cb68d52ef96
--- /dev/null
+++ b/src/test/compile-fail/issue-32995-2.rs
@@ -0,0 +1,36 @@
+// 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.
+
+#![deny(parenthesized_params_in_types_and_modules)]
+//~^ NOTE lint level defined here
+//~| NOTE lint level defined here
+//~| NOTE lint level defined here
+#![allow(dead_code, unused_variables)]
+#![feature(conservative_impl_trait)]
+
+fn main() {
+    { fn f<X: ::std::marker()::Send>() {} }
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+
+    { fn f() -> impl ::std::marker()::Send { } }
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+}
+
+#[derive(Clone)]
+struct X;
+
+impl ::std::marker()::Copy for X {}
+//~^ ERROR parenthesized parameters may only be used with a trait
+//~| WARN previously accepted
+//~| NOTE issue #42238
diff --git a/src/test/compile-fail/issue-32995.rs b/src/test/compile-fail/issue-32995.rs
new file mode 100644
index 00000000000..f2ed8bf53ea
--- /dev/null
+++ b/src/test/compile-fail/issue-32995.rs
@@ -0,0 +1,62 @@
+// 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.
+
+#![deny(parenthesized_params_in_types_and_modules)]
+//~^ NOTE lint level defined here
+//~| NOTE lint level defined here
+//~| NOTE lint level defined here
+//~| NOTE lint level defined here
+//~| NOTE lint level defined here
+//~| NOTE lint level defined here
+//~| NOTE lint level defined here
+#![allow(dead_code, unused_variables)]
+
+fn main() {
+    let x: usize() = 1;
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+
+    let b: ::std::boxed()::Box<_> = Box::new(1);
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+
+    macro_rules! pathexpr {
+        ($p:path) => { $p }
+    }
+
+    let p = pathexpr!(::std::str()::from_utf8)(b"foo").unwrap();
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+
+    let p = pathexpr!(::std::str::from_utf8())(b"foo").unwrap();
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+
+    let o : Box<::std::marker()::Send> = Box::new(1);
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+
+    let o : Box<Send + ::std::marker()::Sync> = Box::new(1);
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+}
+
+fn foo<X:Default>() {
+    let d : X() = Default::default();
+    //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| WARN previously accepted
+    //~| NOTE issue #42238
+}