2016-11-30 16:35:25 -06:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
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`
|
2016-11-30 16:35:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Clone for cat {
|
|
|
|
fn clone(&self) -> Self {
|
|
|
|
clone();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `clone`
|
2016-11-30 16:35:25 -06:00
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Default for cat {
|
|
|
|
fn default() -> Self {
|
|
|
|
default();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `default`
|
2016-11-30 16:35:25 -06:00
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Groom for cat {
|
|
|
|
fn shave(other: usize) {
|
|
|
|
whiskers -= other;
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find value `whiskers`
|
2016-11-30 16:35:25 -06:00
|
|
|
shave(4);
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `shave`
|
2016-11-30 16:35:25 -06:00
|
|
|
purr();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `purr`
|
2016-11-30 16:35:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl cat {
|
|
|
|
fn static_method() {}
|
|
|
|
|
|
|
|
fn purr_louder() {
|
|
|
|
static_method();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `static_method`
|
2016-11-30 16:35:25 -06:00
|
|
|
purr();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `purr`
|
2016-11-30 16:35:25 -06:00
|
|
|
purr();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `purr`
|
2016-11-30 16:35:25 -06:00
|
|
|
purr();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `purr`
|
2016-11-30 16:35:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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`
|
2016-11-30 16:35:25 -06:00
|
|
|
shave();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `shave`
|
2016-11-30 16:35:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn burn_whiskers(&mut self) {
|
|
|
|
whiskers = 0;
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find value `whiskers`
|
2016-11-30 16:35:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn grow_older(other:usize) {
|
|
|
|
whiskers = 4;
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find value `whiskers`
|
2016-11-30 16:35:25 -06:00
|
|
|
purr_louder();
|
2017-11-20 06:13:27 -06:00
|
|
|
//~^ ERROR cannot find function `purr_louder`
|
2016-11-30 16:35:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
self += 1;
|
|
|
|
//~^ ERROR expected value, found module `self`
|
|
|
|
}
|