Move the lint for the stability lints to the method name only

Closes #17337.
This commit is contained in:
P1start 2014-09-17 22:34:18 +12:00
parent f56c67ba86
commit a667a6917b
2 changed files with 28 additions and 2 deletions

View File

@ -1492,6 +1492,8 @@ impl LintPass for Stability {
});
if skip { return; }
let mut span = e.span;
let id = match e.node {
ast::ExprPath(..) | ast::ExprStruct(..) => {
match cx.tcx.def_map.borrow().find(&e.id) {
@ -1499,7 +1501,8 @@ impl LintPass for Stability {
None => return
}
}
ast::ExprMethodCall(..) => {
ast::ExprMethodCall(i, _, _) => {
span = i.span;
let method_call = typeck::MethodCall::expr(e.id);
match cx.tcx.method_map.borrow().find(&method_call) {
Some(method) => {
@ -1556,7 +1559,7 @@ impl LintPass for Stability {
_ => format!("use of {} item", label)
};
cx.span_lint(lint, e.span, msg.as_slice());
cx.span_lint(lint, span, msg.as_slice());
}
}

View File

@ -0,0 +1,23 @@
// Copyright 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.
#![deny(deprecated)]
struct Foo;
impl Foo {
#[deprecated]
fn foo(self) {}
}
fn main() {
Foo
.foo(); //~ ERROR use of deprecated item
}