Fix suggestion for _ on return type for fn in impl for Trait
This commit is contained in:
parent
42dbbabcb0
commit
319fbe371d
7 changed files with 129 additions and 73 deletions
|
|
@ -2,12 +2,14 @@
|
|||
#![allow(unused)]
|
||||
|
||||
trait Foo<T>: Sized {
|
||||
fn bar(i: i32, t: T, s: &Self) {}
|
||||
fn bar(i: i32, t: T, s: &Self) -> (T, i32);
|
||||
}
|
||||
|
||||
impl Foo<usize> for () {
|
||||
fn bar(i: i32, t: usize, s: &()) {}
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
fn bar(i: i32, t: usize, s: &()) -> (usize, i32) {
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
(1, 2)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@
|
|||
#![allow(unused)]
|
||||
|
||||
trait Foo<T>: Sized {
|
||||
fn bar(i: i32, t: T, s: &Self) {}
|
||||
fn bar(i: i32, t: T, s: &Self) -> (T, i32);
|
||||
}
|
||||
|
||||
impl Foo<usize> for () {
|
||||
fn bar(i: _, t: _, s: _) {}
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
fn bar(i: _, t: _, s: _) -> _ {
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
(1, 2)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/replace-impl-infer-ty-from-trait.rs:9:15
|
||||
|
|
||||
LL | fn bar(i: _, t: _, s: _) {}
|
||||
| ^ ^ ^ not allowed in type signatures
|
||||
| | |
|
||||
LL | fn bar(i: _, t: _, s: _) -> _ {
|
||||
| ^ ^ ^ ^ not allowed in type signatures
|
||||
| | | |
|
||||
| | | not allowed in type signatures
|
||||
| | not allowed in type signatures
|
||||
| not allowed in type signatures
|
||||
|
|
||||
help: try replacing `_` with the types in the corresponding trait method signature
|
||||
|
|
||||
LL | fn bar(i: i32, t: usize, s: &()) {}
|
||||
| ~~~ ~~~~~ ~~~
|
||||
LL | fn bar(i: i32, t: usize, s: &()) -> (usize, i32) {
|
||||
| ~~~ ~~~~~ ~~~ ~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ unsafe fn test12(x: *const usize) -> *const *const _ {
|
|||
|
||||
impl Clone for Test9 {
|
||||
fn clone(&self) -> _ { Test9 }
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
|
||||
fn clone_from(&mut self, other: _) { *self = Test9; }
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
|
|
@ -113,7 +113,7 @@ pub fn main() {
|
|||
|
||||
impl Clone for FnTest9 {
|
||||
fn clone(&self) -> _ { FnTest9 }
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
|
||||
fn clone_from(&mut self, other: _) { *self = FnTest9; }
|
||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||
|
|
|
|||
|
|
@ -545,14 +545,16 @@ help: use type parameters instead
|
|||
LL | fn test10<T>(&self, _x : T) { }
|
||||
| +++ ~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item.rs:59:24
|
||||
|
|
||||
LL | fn clone(&self) -> _ { Test9 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct return type: `Test9`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: try replacing `_` with the type in the corresponding trait method signature
|
||||
|
|
||||
LL | fn clone(&self) -> Test9 { Test9 }
|
||||
| ~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item.rs:62:37
|
||||
|
|
@ -585,14 +587,16 @@ help: use type parameters instead
|
|||
LL | fn fn_test10<T>(&self, _x : T) { }
|
||||
| +++ ~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item.rs:115:28
|
||||
|
|
||||
LL | fn clone(&self) -> _ { FnTest9 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace with the correct return type: `FnTest9`
|
||||
| ^ not allowed in type signatures
|
||||
|
|
||||
help: try replacing `_` with the type in the corresponding trait method signature
|
||||
|
|
||||
LL | fn clone(&self) -> FnTest9 { FnTest9 }
|
||||
| ~~~~~~~
|
||||
|
||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||
--> $DIR/typeck_type_placeholder_item.rs:118:41
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue