mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Reduce span to function name in unreachable calls
This commit is contained in:
parent
618768492f
commit
e1d27eb73c
@ -161,6 +161,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Warn for non-block expressions with diverging children.
|
||||
match expr.node {
|
||||
ExprKind::Block(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {},
|
||||
ExprKind::Call(ref callee, _) =>
|
||||
self.warn_if_unreachable(expr.hir_id, callee.span, "call"),
|
||||
ExprKind::MethodCall(_, ref span, _) =>
|
||||
self.warn_if_unreachable(expr.hir_id, *span, "call"),
|
||||
_ => self.warn_if_unreachable(expr.hir_id, expr.span, "expression"),
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,11 @@ LL | #![warn(unused)]
|
||||
| ^^^^^^
|
||||
= note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unreachable expression
|
||||
warning: unreachable call
|
||||
--> $DIR/never-assign-dead-code.rs:10:5
|
||||
|
|
||||
LL | drop(x);
|
||||
| ^^^^^^^
|
||||
| ^^^^
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/never-assign-dead-code.rs:9:9
|
||||
|
@ -10,11 +10,11 @@ note: lint level defined here
|
||||
LL | #![deny(unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable expression
|
||||
error: unreachable call
|
||||
--> $DIR/expr_call.rs:18:5
|
||||
|
|
||||
LL | bar(return);
|
||||
| ^^^^^^^^^^^
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -10,11 +10,11 @@ note: lint level defined here
|
||||
LL | #![deny(unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable expression
|
||||
--> $DIR/expr_method.rs:21:5
|
||||
error: unreachable call
|
||||
--> $DIR/expr_method.rs:21:9
|
||||
|
|
||||
LL | Foo.bar(return);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -14,7 +14,7 @@ fn diverge_first() {
|
||||
get_u8()); //~ ERROR unreachable expression
|
||||
}
|
||||
fn diverge_second() {
|
||||
call( //~ ERROR unreachable expression
|
||||
call( //~ ERROR unreachable call
|
||||
get_u8(),
|
||||
diverge());
|
||||
}
|
||||
|
@ -10,13 +10,11 @@ note: lint level defined here
|
||||
LL | #![deny(unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable expression
|
||||
error: unreachable call
|
||||
--> $DIR/unreachable-in-call.rs:17:5
|
||||
|
|
||||
LL | / call(
|
||||
LL | | get_u8(),
|
||||
LL | | diverge());
|
||||
| |__________________^
|
||||
LL | call(
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user