From a667a6917b2be3bad44a625badcc11293a97910b Mon Sep 17 00:00:00 2001 From: P1start Date: Wed, 17 Sep 2014 22:34:18 +1200 Subject: [PATCH] Move the lint for the stability lints to the method name only Closes #17337. --- src/librustc/lint/builtin.rs | 7 +++++-- src/test/compile-fail/issue-17337.rs | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/issue-17337.rs diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index ea647fda8482..4c147517a7f0 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -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()); } } diff --git a/src/test/compile-fail/issue-17337.rs b/src/test/compile-fail/issue-17337.rs new file mode 100644 index 000000000000..e0f655084ff7 --- /dev/null +++ b/src/test/compile-fail/issue-17337.rs @@ -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 or the MIT license +// , 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 +}