rust/tests/ui/traits/impl-1.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
340 B
Rust
Raw Normal View History

2014-10-30 02:41:07 +00:00
// Test calling methods on an impl for a bare trait. This test checks that the
// trait impl is only applied to a trait object, not concrete types which implement
// the trait.
2015-04-18 05:12:20 +00:00
trait T {}
2014-10-30 02:41:07 +00:00
2019-05-28 18:46:13 +00:00
impl<'a> dyn T + 'a {
2014-10-30 02:41:07 +00:00
fn foo(&self) {}
}
2015-01-31 16:23:42 +00:00
impl T for i32 {}
2014-10-30 02:41:07 +00:00
fn main() {
2015-01-31 16:23:42 +00:00
let x = &42i32;
x.foo(); //~ERROR: no method named `foo` found
2014-10-30 02:41:07 +00:00
}