diff options
Diffstat (limited to 'src/test/ui')
4 files changed, 60 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`. diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs new file mode 100644 index 00000000000..92d21864c74 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs @@ -0,0 +1,13 @@ +// 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. + +// Tests that an `impl Trait` that is not `impl Termination` will not work. +fn main() -> impl Copy { } +//~^ ERROR `main` has invalid return type `impl std::marker::Copy` diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr new file mode 100644 index 00000000000..7485f3066bb --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `impl std::marker::Copy` + --> $DIR/termination-trait-impl-trait.rs:12:14 + | +LL | fn main() -> impl Copy { } + | ^^^^^^^^^ `main` can only return types that implement `std::process::Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
