Don't suggest using fields in a static method
This commit is contained in:
parent
e87cd7e380
commit
145747ebfc
3 changed files with 93 additions and 24 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
24
src/test/compile-fail/unresolved_static_type_field.rs
Normal file
24
src/test/compile-fail/unresolved_static_type_field.rs
Normal 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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue