Don't suggest using fields in a static method

This commit is contained in:
ggomez 2016-05-13 17:17:10 +02:00 committed by Guillaume Gomez
parent e87cd7e380
commit 145747ebfc
3 changed files with 93 additions and 24 deletions

View file

@ -32,7 +32,8 @@ impl MaybeDog {
impl Groom for cat {
fn shave(other: usize) {
whiskers -= other;
//~^ ERROR: unresolved name `whiskers`. Did you mean `self.whiskers`?
//~^ ERROR: unresolved name `whiskers`
//~| HELP this is an associated function
shave(4);
//~^ ERROR: unresolved name `shave`. Did you mean to call `Groom::shave`?
purr();
@ -77,7 +78,8 @@ impl cat {
pub fn grow_older(other:usize) {
whiskers = 4;
//~^ ERROR: unresolved name `whiskers`. Did you mean `self.whiskers`?
//~^ ERROR: unresolved name `whiskers`
//~| HELP this is an associated function
purr_louder();
//~^ ERROR: unresolved name `purr_louder`
}
@ -86,5 +88,6 @@ impl cat {
fn main() {
self += 1;
//~^ ERROR: unresolved name `self`
//~| HELP: Module
// it's a bug if this suggests a missing `self` as we're not in a method
}

View file

@ -0,0 +1,24 @@
// Copyright 2016 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.
fn f(_: bool) {}
struct Foo {
cx: bool,
}
impl Foo {
fn bar() {
f(cx); //~ ERROR E0425
//~| HELP this is an associated function
}
}
fn main() {}