-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #51051 - nikomatsakis:turbofish-impl-trait-method, r=eddyb
prohibit turbofish in `impl Trait` methods Fix #50950
- Loading branch information
Showing
5 changed files
with
75 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/ui/impl-trait/universal-turbofish-in-method-issue-50950.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |