then {
let body = cx.tcx.hir().body(body_id);
if_chain! {
- if body.arguments.len() == 1;
- if let Some(argname) = get_pat_name(&body.arguments[0].pat);
+ if body.params.len() == 1;
+ if let Some(argname) = get_pat_name(&body.params[0].pat);
if let ExprKind::Binary(ref op, ref l, ref r) = body.value.node;
if op.node == BinOpKind::Eq;
if match_type(cx,
}
match map.find(map.get_parent_node(id)) {
- Some(Node::Arg(_)) => true,
+ Some(Node::Param(_)) => true,
_ => false,
}
}
}
}
-fn compare_inputs(closure_inputs: &mut dyn Iterator<Item = &Arg>, call_args: &mut dyn Iterator<Item = &Expr>) -> bool {
+fn compare_inputs(
+ closure_inputs: &mut dyn Iterator<Item = &Param>,
+ call_args: &mut dyn Iterator<Item = &Expr>,
+) -> bool {
for (closure_input, function_arg) in closure_inputs.zip(call_args) {
if let PatKind::Binding(_, _, ident, _) = closure_input.pat.node {
// XXXManishearth Should I be checking the binding mode here?
}
}
-fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<hir::HirId> {
+fn raw_ptr_arg(arg: &hir::Param, ty: &hir::Ty) -> Option<hir::HirId> {
if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) {
Some(id)
} else {
let closure_body = cx.tcx.hir().body(body_id);
let closure_expr = remove_blocks(&closure_body.value);
then {
- match closure_body.arguments[0].pat.node {
+ match closure_body.params[0].pat.node {
hir::PatKind::Ref(ref inner, _) => if let hir::PatKind::Binding(
hir::BindingAnnotation::Unannotated, .., name, None
) = inner.node {
}
}
-fn unit_closure<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'a hir::Expr) -> Option<(&'tcx hir::Arg, &'a hir::Expr)> {
+fn unit_closure<'a, 'tcx>(
+ cx: &LateContext<'a, 'tcx>,
+ expr: &'a hir::Expr,
+) -> Option<(&'tcx hir::Param, &'a hir::Expr)> {
if let hir::ExprKind::Closure(_, ref decl, inner_expr_id, _, _) = expr.node {
let body = cx.tcx.hir().body(inner_expr_id);
let body_expr = &body.value;
if bin_op.node == op;
// Extract the names of the two arguments to the closure
- if let Some(first_arg_ident) = get_arg_name(&closure_body.arguments[0].pat);
- if let Some(second_arg_ident) = get_arg_name(&closure_body.arguments[1].pat);
+ if let Some(first_arg_ident) = get_arg_name(&closure_body.params[0].pat);
+ if let Some(second_arg_ident) = get_arg_name(&closure_body.params[1].pat);
if match_var(&*left_expr, first_arg_ident);
if replacement_has_args || match_var(&*right_expr, second_arg_ident);
if let hir::ExprKind::Closure(_, _, body_id, _, _) = arg_node;
let body = cx.tcx.hir().body(*body_id);
- if let hir::PatKind::Binding(_, _, binding_ident, _) = body.arguments[0].pat.node;
+ if let hir::PatKind::Binding(_, _, binding_ident, _) = body.params[0].pat.node;
if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = body.value.node;
if path.segments.len() == 1;
if search_method == "find";
if let hir::ExprKind::Closure(_, _, body_id, ..) = search_args[1].node;
let closure_body = cx.tcx.hir().body(body_id);
- if let Some(closure_arg) = closure_body.arguments.get(0);
+ if let Some(closure_arg) = closure_body.params.get(0);
if let hir::PatKind::Ref(..) = closure_arg.pat.node;
then {
Some(search_snippet.replacen('&', "", 1))
if let hir::ExprKind::Closure(_, _, body_id, ..) = args[1].node {
let body = cx.tcx.hir().body(body_id);
- let arg_id = body.arguments[0].pat.hir_id;
+ let arg_id = body.params[0].pat.hir_id;
let mutates_arg = match mutated_variables(&body.value, cx) {
Some(used_mutably) => used_mutably.contains(&arg_id),
None => true,
let fn_sig = cx.tcx.fn_sig(fn_def_id);
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
- for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(&body.arguments).enumerate() {
+ for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(&body.params).enumerate() {
// All spans generated from a proc-macro invocation are the same...
if span == input.span {
return;
continue;
}
let generics_suggestion_span = generics.span.substitute_dummy({
- let pos = snippet_opt(cx, item.span.until(body.arguments[0].pat.span))
+ let pos = snippet_opt(cx, item.span.until(body.params[0].pat.span))
.and_then(|snip| {
let i = snip.find("fn")?;
Some(item.span.lo() + BytePos((i + (&snip[i..]).find('(')?) as u32))
}
}
-pub fn is_self(slf: &Arg) -> bool {
+pub fn is_self(slf: &Param) -> bool {
if let PatKind::Binding(.., name, _) = slf.pat.node {
name.name == kw::SelfLower
} else {
false
}
-pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<Item = &'tcx Arg> {
- (0..decl.inputs.len()).map(move |i| &body.arguments[i])
+pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<Item = &'tcx Param> {
+ (0..decl.inputs.len()).map(move |i| &body.params[i])
}
/// Checks if a given expression is a match expression expanded from the `?`
replacements: &[(&'static str, &'static str)],
) -> Option<Vec<(Span, Cow<'static, str>)>> {
if let Some(body) = opt_body_id.map(|id| cx.tcx.hir().body(id)) {
- get_binding_name(&body.arguments[idx]).map_or_else(
+ get_binding_name(&body.params[idx]).map_or_else(
|| Some(vec![]),
|name| extract_clone_suggestions(cx, name, replacements, body),
)
}
}
-fn get_binding_name(arg: &Arg) -> Option<Name> {
+fn get_binding_name(arg: &Param) -> Option<Name> {
get_pat_name(&arg.pat)
}
Once we are satisfied with the output, we need to run
`tests/ui/update-all-references.sh` to update the `.stderr` file for our lint.
+Please note that, we should run `TESTNAME=ui/foo_functions cargo uitest`
+every time before running `tests/ui/update-all-references.sh`.
Running `TESTNAME=ui/foo_functions cargo uitest` should pass then. When we
commit our lint, we need to commit the generated `.stderr` files, too.