rust/src/test/ui/resolve/issue-2356.rs

95 lines
1.7 KiB
Rust
Raw Normal View History

trait Groom {
fn shave(other: usize);
}
pub struct Cat {
whiskers: isize,
}
pub enum MaybeDog {
Dog,
NoDog
}
impl MaybeDog {
fn bark() {
// If this provides a suggestion, it's a bug as MaybeDog doesn't impl Groom
shave();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `shave`
}
}
impl Clone for Cat {
fn clone(&self) -> Self {
clone();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `clone`
loop {}
}
}
impl Default for Cat {
fn default() -> Self {
default();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `default`
loop {}
}
}
impl Groom for Cat {
fn shave(other: usize) {
whiskers -= other;
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find value `whiskers`
shave(4);
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `shave`
purr();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `purr`
}
}
impl Cat {
fn static_method() {}
fn purr_louder() {
static_method();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `static_method`
purr();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `purr`
purr();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `purr`
purr();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `purr`
}
}
impl Cat {
fn meow() {
if self.whiskers > 3 {
//~^ ERROR expected value, found module `self`
println!("MEOW");
}
}
fn purr(&self) {
grow_older();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `grow_older`
shave();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `shave`
}
fn burn_whiskers(&mut self) {
whiskers = 0;
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find value `whiskers`
}
pub fn grow_older(other:usize) {
whiskers = 4;
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find value `whiskers`
purr_louder();
2017-11-20 06:13:27 -06:00
//~^ ERROR cannot find function `purr_louder`
}
}
fn main() {
self += 1;
//~^ ERROR expected value, found module `self`
}