about summary refs log tree commit diff
path: root/tests/ui/traits/trait-impl-self-mismatch.rs
blob: 54226cf2c9ad4b4eeab7c7729df8440929c5770c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//@compile-flags: -Zvalidate-mir -Zinline-mir -Zinline-mir-threshold=300

//! Ensure that a trait method implemented with the wrong signature
//! correctly triggers a compile error and not an ICE.
//! Regression test for <https://github.com/rust-lang/rust/issues/133065>.

trait Bar {
    fn bar(&self) {}
}

impl<T> Bar for T {
    fn bar() { //~ ERROR method `bar` has a `&self` declaration in the trait, but not in the impl
        let _ = "Hello".bytes().nth(3);
    }
}

fn main() {
    ().bar();
}