Skip to content

Commit 6f7f3ce

Browse files
authored
Rollup merge of #140574 - reddevilmidzy:add-test, r=compiler-errors
Add regression test for 133065 closes: #133065
2 parents bcf2490 + a9cd0a9 commit 6f7f3ce

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@compile-flags: -Zvalidate-mir -Zinline-mir -Zinline-mir-threshold=300
2+
3+
//! Ensure that a trait method implemented with the wrong signature
4+
//! correctly triggers a compile error and not an ICE.
5+
//! Regression test for <https://github.com/rust-lang/rust/issues/133065>.
6+
7+
trait Bar {
8+
fn bar(&self) {}
9+
}
10+
11+
impl<T> Bar for T {
12+
fn bar() { //~ ERROR method `bar` has a `&self` declaration in the trait, but not in the impl
13+
let _ = "Hello".bytes().nth(3);
14+
}
15+
}
16+
17+
fn main() {
18+
().bar();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0186]: method `bar` has a `&self` declaration in the trait, but not in the impl
2+
--> $DIR/trait-impl-self-mismatch.rs:12:5
3+
|
4+
LL | fn bar(&self) {}
5+
| ------------- `&self` used in trait
6+
...
7+
LL | fn bar() {
8+
| ^^^^^^^^ expected `&self` in impl
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0186`.

0 commit comments

Comments
 (0)