Skip to content

Commit b9146ad

Browse files
committed
Move the lint for the stability lints to the method name only
Closes #17337.
1 parent 44d1b1d commit b9146ad

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/librustc/lint/builtin.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ impl LintPass for Stability {
14961496
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
14971497
// if the expression was produced by a macro expansion,
14981498
if e.span.expn_id != NO_EXPANSION { return }
1499+
let mut span = e.span;
14991500

15001501
let id = match e.node {
15011502
ast::ExprPath(..) | ast::ExprStruct(..) => {
@@ -1504,7 +1505,8 @@ impl LintPass for Stability {
15041505
None => return
15051506
}
15061507
}
1507-
ast::ExprMethodCall(..) => {
1508+
ast::ExprMethodCall(i, _, _) => {
1509+
span = i.span;
15081510
let method_call = typeck::MethodCall::expr(e.id);
15091511
match cx.tcx.method_map.borrow().find(&method_call) {
15101512
Some(method) => {
@@ -1561,7 +1563,7 @@ impl LintPass for Stability {
15611563
_ => format!("use of {} item", label)
15621564
};
15631565

1564-
cx.span_lint(lint, e.span, msg.as_slice());
1566+
cx.span_lint(lint, span, msg.as_slice());
15651567
}
15661568
}
15671569

src/test/compile-fail/issue-17337.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(deprecated)]
12+
13+
struct Foo;
14+
15+
impl Foo {
16+
#[deprecated]
17+
fn foo(self) {}
18+
}
19+
20+
fn main() {
21+
Foo
22+
.foo(); //~ ERROR use of deprecated item
23+
}

0 commit comments

Comments
 (0)