about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-05-24 17:34:23 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-05-24 18:43:48 -0400
commit558cbfb19b8e43e447f1cae6ecdb06c0b961067e (patch)
tree8b5bbc46eecee1ff841b735f46895ec349d128fd /src/test
parenta76bff86e6f4b56b2c3fd1704ce8535ed207dd78 (diff)
downloadrust-558cbfb19b8e43e447f1cae6ecdb06c0b961067e.tar.gz
rust-558cbfb19b8e43e447f1cae6ecdb06c0b961067e.zip
prohibit turbofish in `impl Trait` methods
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.rs27
-rw-r--r--src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.stderr9
2 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.rs b/src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.rs
new file mode 100644
index 00000000000..ac53612d2da
--- /dev/null
+++ b/src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.rs
@@ -0,0 +1,27 @@
+// 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 <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.
+
+use std::any::Any;
+pub struct EventHandler {
+}
+
+impl EventHandler
+{
+    pub fn handle_event<T: Any>(&mut self, _efunc: impl FnMut(T)) {}
+}
+
+struct TestEvent(i32);
+
+fn main() {
+    let mut evt = EventHandler {};
+    evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
+        //~^ ERROR cannot provide explicit type parameters
+    });
+}
diff --git a/src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.stderr b/src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.stderr
new file mode 100644
index 00000000000..fec3f78535d
--- /dev/null
+++ b/src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.stderr
@@ -0,0 +1,9 @@
+error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
+  --> $DIR/universal-turbofish-in-method-issue-50950.rs:24:9
+   |
+LL |     evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
+   |         ^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0632`.