Run nightly rustfmt
This commit is contained in:
@@ -7,12 +7,12 @@ use rustc::ty;
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc_const_eval::ConstContext;
|
||||
use rustc_const_math::ConstFloat;
|
||||
use syntax::codemap::{Span, ExpnFormat};
|
||||
use utils::{get_item_name, get_parent_expr, implements_trait, in_macro, is_integer_literal, match_qpath, snippet,
|
||||
span_lint, span_lint_and_then, walk_ptrs_ty, last_path_segment, iter_input_pats, in_constant,
|
||||
match_trait_method, paths};
|
||||
use syntax::codemap::{ExpnFormat, Span};
|
||||
use utils::{get_item_name, get_parent_expr, implements_trait, in_constant, in_macro, is_integer_literal,
|
||||
iter_input_pats, last_path_segment, match_qpath, match_trait_method, paths, snippet, span_lint,
|
||||
span_lint_and_then, walk_ptrs_ty};
|
||||
use utils::sugg::Sugg;
|
||||
use syntax::ast::{LitKind, CRATE_NODE_ID, FloatTy};
|
||||
use syntax::ast::{FloatTy, LitKind, CRATE_NODE_ID};
|
||||
|
||||
/// **What it does:** Checks for function arguments and let bindings denoted as
|
||||
/// `ref`.
|
||||
@@ -242,7 +242,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
TOPLEVEL_REF_ARG,
|
||||
arg.pat.span,
|
||||
"`ref` directly on a function argument is ignored. Consider using a reference type \
|
||||
instead.",
|
||||
instead.",
|
||||
);
|
||||
},
|
||||
_ => {},
|
||||
@@ -385,7 +385,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
expr.span,
|
||||
&format!(
|
||||
"used binding `{}` which is prefixed with an underscore. A leading \
|
||||
underscore signals that a binding will not be used.",
|
||||
underscore signals that a binding will not be used.",
|
||||
binding
|
||||
),
|
||||
);
|
||||
@@ -484,16 +484,14 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
ExprCall(ref path, ref v) if v.len() == 1 => {
|
||||
if let ExprPath(ref path) = path.node {
|
||||
if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"]) {
|
||||
(cx.tables.expr_ty_adjusted(&v[0]), snippet(cx, v[0].span, ".."))
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
ExprCall(ref path, ref v) if v.len() == 1 => if let ExprPath(ref path) = path.node {
|
||||
if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"]) {
|
||||
(cx.tables.expr_ty_adjusted(&v[0]), snippet(cx, v[0].span, ".."))
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
},
|
||||
_ => return,
|
||||
};
|
||||
@@ -554,8 +552,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
|
||||
fn is_used(cx: &LateContext, expr: &Expr) -> bool {
|
||||
if let Some(parent) = get_parent_expr(cx, expr) {
|
||||
match parent.node {
|
||||
ExprAssign(_, ref rhs) |
|
||||
ExprAssignOp(_, _, ref rhs) => **rhs == *expr,
|
||||
ExprAssign(_, ref rhs) | ExprAssignOp(_, _, ref rhs) => **rhs == *expr,
|
||||
_ => is_used(cx, parent),
|
||||
}
|
||||
} else {
|
||||
@@ -567,20 +564,21 @@ fn is_used(cx: &LateContext, expr: &Expr) -> bool {
|
||||
/// generated by
|
||||
/// `#[derive(...)`] or the like).
|
||||
fn in_attributes_expansion(expr: &Expr) -> bool {
|
||||
expr.span.ctxt().outer().expn_info().map_or(
|
||||
false,
|
||||
|info| matches!(info.callee.format, ExpnFormat::MacroAttribute(_)),
|
||||
)
|
||||
expr.span
|
||||
.ctxt()
|
||||
.outer()
|
||||
.expn_info()
|
||||
.map_or(false, |info| matches!(info.callee.format, ExpnFormat::MacroAttribute(_)))
|
||||
}
|
||||
|
||||
/// Test whether `def` is a variable defined outside a macro.
|
||||
fn non_macro_local(cx: &LateContext, def: &def::Def) -> bool {
|
||||
match *def {
|
||||
def::Def::Local(def_id) |
|
||||
def::Def::Upvar(def_id, _, _) => {
|
||||
let id = cx.tcx.hir.as_local_node_id(def_id).expect(
|
||||
"local variables should be found in the same crate",
|
||||
);
|
||||
def::Def::Local(def_id) | def::Def::Upvar(def_id, _, _) => {
|
||||
let id = cx.tcx
|
||||
.hir
|
||||
.as_local_node_id(def_id)
|
||||
.expect("local variables should be found in the same crate");
|
||||
!in_macro(cx.tcx.hir.span(id))
|
||||
},
|
||||
_ => false,
|
||||
|
||||
Reference in New Issue
Block a user