Skip to content

Commit

Permalink
Move the lint for the stability lints to the method name only
Browse files Browse the repository at this point in the history
Closes #17337.
  • Loading branch information
ftxqxd committed Oct 3, 2014
1 parent f56c67b commit a667a69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,14 +1492,17 @@ 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) {
Some(&def) => def.def_id(),
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) => {
Expand Down Expand Up @@ -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());
}
}

Expand Down
23 changes: 23 additions & 0 deletions src/test/compile-fail/issue-17337.rs
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit a667a69

Please sign in to comment.