Skip to content

Commit ac3c144

Browse files
committed
trait-method-number-parameters
1 parent 2779261 commit ac3c144

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/ui/traits/trait-method-signature-mismatch.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
//! This test verifies that implementing a trait method with a signature that does not
2+
//! exactly match its declaration in the trait results in a compilation error.
3+
//! Specifically, it checks for errors when the number of parameters or the return type
4+
//! in the `impl` differs from the trait definition.
5+
16
trait Foo {
27
fn foo(&mut self, x: i32, y: i32) -> i32;
38
}
49

510
impl Foo for i32 {
611
fn foo(
7-
&mut self, //~ ERROR
12+
&mut self, //~ ERROR method `foo` has 2 parameters but the declaration
813
x: i32,
914
) {
1015
}

tests/ui/traits/trait-method-signature-mismatch.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0050]: method `foo` has 2 parameters but the declaration in trait `Foo::foo` has 3
2-
--> $DIR/trait-method-number-parameters.rs:7:9
2+
--> $DIR/trait-method-signature-mismatch.rs:12:9
33
|
44
LL | fn foo(&mut self, x: i32, y: i32) -> i32;
55
| ------------------------- trait requires 3 parameters

0 commit comments

Comments
 (0)