Auto merge of #5711 - flip1995:rustup, r=flip1995

Rustup

changelog: none
This commit is contained in:
bors 2020-06-23 00:27:02 +00:00
commit fa0f6a8dbf
62 changed files with 192 additions and 222 deletions

View file

@ -70,7 +70,7 @@ fn match_ordering_def_path(cx: &LateContext<'_, '_>, did: DefId, orderings: &[&s
fn check_atomic_load_store(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
if_chain! {
if let ExprKind::MethodCall(ref method_path, _, args) = &expr.kind;
if let ExprKind::MethodCall(ref method_path, _, args, _) = &expr.kind;
let method = method_path.ident.name.as_str();
if type_is_atomic(cx, &args[0]);
if method == "load" || method == "store";

View file

@ -247,7 +247,7 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<String> {
))
})
},
ExprKind::MethodCall(path, _, args) if args.len() == 1 => {
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
let type_of_receiver = cx.tables.expr_ty(&args[0]);
if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type))
&& !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type))

View file

@ -38,10 +38,10 @@ declare_lint_pass!(ByteCount => [NAIVE_BYTECOUNT]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
if_chain! {
if let ExprKind::MethodCall(ref count, _, ref count_args) = expr.kind;
if let ExprKind::MethodCall(ref count, _, ref count_args, _) = expr.kind;
if count.ident.name == sym!(count);
if count_args.len() == 1;
if let ExprKind::MethodCall(ref filter, _, ref filter_args) = count_args[0].kind;
if let ExprKind::MethodCall(ref filter, _, ref filter_args, _) = count_args[0].kind;
if filter.ident.name == sym!(filter);
if filter_args.len() == 2;
if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].kind;
@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).kind {
return;
}
let haystack = if let ExprKind::MethodCall(ref path, _, ref args) =
let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) =
filter_args[0].kind {
let p = path.ident.name;
if (p == sym!(iter) || p == sym!(iter_mut)) && args.len() == 1 {

View file

@ -88,7 +88,7 @@ fn double_check<'a>(cx: &LateContext<'_, '_>, left: &'a Expr<'_>, right: &'a Exp
let upper = check_upper_bound(l);
let lower = check_lower_bound(r);
transpose(upper, lower).and_then(|(l, r)| l.combine(r, cx))
upper.zip(lower).and_then(|(l, r)| l.combine(r, cx))
};
upper_lower(left, right).or_else(|| upper_lower(right, left))
@ -131,7 +131,10 @@ impl<'a> Conversion<'a> {
/// Checks if the to-type is the same (if there is a type constraint)
fn has_compatible_to_type(&self, other: &Self) -> bool {
transpose(self.to_type.as_ref(), other.to_type.as_ref()).map_or(true, |(l, r)| l == r)
match (self.to_type, other.to_type) {
(Some(l), Some(r)) => l == r,
_ => true,
}
}
/// Try to construct a new conversion if the conversion type is valid
@ -322,14 +325,6 @@ fn int_ty_to_sym<'tcx>(path: &QPath<'_>) -> Option<&'tcx str> {
}
}
/// (Option<T>, Option<U>) -> Option<(T, U)>
fn transpose<T, U>(lhs: Option<T>, rhs: Option<U>) -> Option<(T, U)> {
match (lhs, rhs) {
(Some(l), Some(r)) => Some((l, r)),
_ => None,
}
}
/// Will return the expressions as if they were expr1 <= expr2
fn normalize_le_ge<'a>(op: &BinOp, left: &'a Expr<'a>, right: &'a Expr<'a>) -> Option<(&'a Expr<'a>, &'a Expr<'a>)> {
match op.node {

View file

@ -254,11 +254,11 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
if let ["core", "num", int_impl, "max_value"] = *def_path;
then {
let value = match int_impl {
"<impl i8>" => i8::max_value() as u128,
"<impl i16>" => i16::max_value() as u128,
"<impl i32>" => i32::max_value() as u128,
"<impl i64>" => i64::max_value() as u128,
"<impl i128>" => i128::max_value() as u128,
"<impl i8>" => i8::MAX as u128,
"<impl i16>" => i16::MAX as u128,
"<impl i32>" => i32::MAX as u128,
"<impl i64>" => i64::MAX as u128,
"<impl i128>" => i128::MAX as u128,
_ => return None,
};
Some(Constant::Int(value))

View file

@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Dereferencing {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
if !expr.span.from_expansion();
if let ExprKind::MethodCall(ref method_name, _, ref args) = &expr.kind;
if let ExprKind::MethodCall(ref method_name, _, ref args, _) = &expr.kind;
if args.len() == 1;
then {

View file

@ -70,7 +70,7 @@ impl EarlyLintPass for DoubleParens {
}
}
},
ExprKind::MethodCall(_, ref params) => {
ExprKind::MethodCall(_, ref params, _) => {
if params.len() == 2 {
let param = &params[1];
if let ExprKind::Paren(_) = param.kind {

View file

@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, ref left, ref right) = expr.kind;
if let ExprKind::MethodCall(ref method_path, _ , ref args) = left.kind;
if let ExprKind::MethodCall(ref method_path, _ , ref args, _) = left.kind;
if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION);
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
then {

View file

@ -103,7 +103,7 @@ fn check_cond<'a, 'tcx, 'b>(
check: &'b Expr<'b>,
) -> Option<(&'static str, &'b Expr<'b>, &'b Expr<'b>)> {
if_chain! {
if let ExprKind::MethodCall(ref path, _, ref params) = check.kind;
if let ExprKind::MethodCall(ref path, _, ref params, _) = check.kind;
if params.len() >= 2;
if path.ident.name == sym!(contains_key);
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref key) = params[1].kind;
@ -140,7 +140,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if_chain! {
if let ExprKind::MethodCall(ref path, _, ref params) = expr.kind;
if let ExprKind::MethodCall(ref path, _, ref params, _) = expr.kind;
if params.len() == 3;
if path.ident.name == sym!(insert);
if get_item_name(self.cx, self.map) == get_item_name(self.cx, &params[0]);

View file

@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
continue;
}
},
ty::Uint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
ty::Uint(UintTy::Usize) if val > u128::from(u32::MAX) => {},
_ => continue,
}
span_lint(

View file

@ -6,7 +6,7 @@ use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::source_map::Span;
use rustc_target::abi::LayoutOf;
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
use crate::utils::span_lint;
@ -112,9 +112,9 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
}
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
fn consume(&mut self, cmt: &Place<'tcx>, mode: ConsumeMode) {
if cmt.projections.is_empty() {
if let PlaceBase::Local(lid) = cmt.base {
fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, mode: ConsumeMode) {
if cmt.place.projections.is_empty() {
if let PlaceBase::Local(lid) = cmt.place.base {
if let ConsumeMode::Move = mode {
// moved out or in. clearly can't be localized
self.set.remove(&lid);
@ -132,16 +132,16 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
}
}
fn borrow(&mut self, cmt: &Place<'tcx>, _: ty::BorrowKind) {
if cmt.projections.is_empty() {
if let PlaceBase::Local(lid) = cmt.base {
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: ty::BorrowKind) {
if cmt.place.projections.is_empty() {
if let PlaceBase::Local(lid) = cmt.place.base {
self.set.remove(&lid);
}
}
}
fn mutate(&mut self, cmt: &Place<'tcx>) {
if cmt.projections.is_empty() {
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>) {
if cmt.place.projections.is_empty() {
let map = &self.cx.tcx.hir();
if is_argument(*map, cmt.hir_id) {
// Skip closure arguments
@ -150,7 +150,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
return;
}
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
if is_non_trait_box(cmt.place.ty) && !self.is_large_box(cmt.place.ty) {
self.set.insert(cmt.hir_id);
}
return;

View file

@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaReduction {
}
match expr.kind {
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args) => {
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args, _) => {
for arg in args {
check_closure(cx, arg)
}
@ -120,7 +120,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
);
if_chain!(
if let ExprKind::MethodCall(ref path, _, ref args) = ex.kind;
if let ExprKind::MethodCall(ref path, _, ref args, _) = ex.kind;
// Not the same number of arguments, there is no way the closure is the same as the function return;
if args.len() == decl.inputs.len();

View file

@ -32,11 +32,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitWrite {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
// match call to unwrap
if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.kind;
if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args, _) = expr.kind;
if unwrap_fun.ident.name == sym!(unwrap);
// match call to write_fmt
if !unwrap_args.is_empty();
if let ExprKind::MethodCall(ref write_fun, _, write_args) =
if let ExprKind::MethodCall(ref write_fun, _, write_args, _) =
unwrap_args[0].kind;
if write_fun.ident.name == sym!(write_fmt);
// match calls to std::io::stdout() / std::io::stderr ()

View file

@ -301,7 +301,7 @@ fn check_expm1(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
if cx.tables.expr_ty(lhs).is_floating_point();
if let Some((value, _)) = constant(cx, cx.tables, rhs);
if F32(1.0) == value || F64(1.0) == value;
if let ExprKind::MethodCall(ref path, _, ref method_args) = lhs.kind;
if let ExprKind::MethodCall(ref path, _, ref method_args, _) = lhs.kind;
if cx.tables.expr_ty(&method_args[0]).is_floating_point();
if path.ident.name.as_str() == "exp";
then {
@ -481,7 +481,7 @@ fn check_custom_abs(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FloatingPointArithmetic {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if let ExprKind::MethodCall(ref path, _, args) = &expr.kind {
if let ExprKind::MethodCall(ref path, _, args, _) = &expr.kind {
let recv_ty = cx.tables.expr_ty(&args[0]);
if recv_ty.is_floating_point() {

View file

@ -104,7 +104,7 @@ fn on_argumentv1_new<'a, 'tcx>(
}
} else {
let snip = snippet(cx, format_args.span, "<arg>");
if let ExprKind::MethodCall(ref path, _, _) = format_args.kind {
if let ExprKind::MethodCall(ref path, _, _, _) = format_args.kind {
if path.ident.name == sym!(to_string) {
return Some(format!("{}", snip));
}

View file

@ -556,7 +556,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
}
}
},
hir::ExprKind::MethodCall(_, _, args) => {
hir::ExprKind::MethodCall(_, _, args, _) => {
let def_id = self.tables.type_dependent_def_id(expr.hir_id).unwrap();
let base_type = self.cx.tcx.type_of(def_id);
@ -610,7 +610,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
return;
}
match expr.kind {
Call(_, args) | MethodCall(_, _, args) => {
Call(_, args) | MethodCall(_, _, args, _) => {
let mut tys = FxHashSet::default();
for arg in args {
let def_id = arg.hir_id.owner.to_def_id();

View file

@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
// Is a method call
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
// Method name is "get"
if path.ident.name == sym!(get);
@ -69,7 +69,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
) = &get_index_arg.kind;
// LHS of subtraction is "x.len()"
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args) = &lhs.kind;
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args, _) = &lhs.kind;
if arg_lhs_path.ident.name == sym!(len);
if let Some(arg_lhs_struct) = lhs_args.get(0);

View file

@ -147,7 +147,7 @@ impl<'tcx, 'l> ArmVisitor<'tcx, 'l> {
fn is_mutex_lock_call<'a>(cx: &LateContext<'a, '_>, expr: &'a Expr<'_>) -> Option<&'a Expr<'a>> {
if_chain! {
if let ExprKind::MethodCall(path, _span, args) = &expr.kind;
if let ExprKind::MethodCall(path, _span, args, _) = &expr.kind;
if path.ident.to_string() == "lock";
let ty = cx.tables.expr_ty(&args[0]);
if is_type_diagnostic_item(cx, ty, sym!(mutex_type));

View file

@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OkIfLet {
if_chain! { //begin checking variables
if let ExprKind::Match(ref op, ref body, source) = expr.kind; //test if expr is a match
if let MatchSource::IfLetDesugar { .. } = source; //test if it is an If Let
if let ExprKind::MethodCall(_, ok_span, ref result_types) = op.kind; //check is expr.ok() has type Result<T,E>.ok()
if let ExprKind::MethodCall(_, ok_span, ref result_types, _) = op.kind; //check is expr.ok() has type Result<T,E>.ok(, _)
if let PatKind::TupleStruct(QPath::Resolved(_, ref x), ref y, _) = body[0].pat.kind; //get operation
if method_chain_args(op, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized;
if is_type_diagnostic_item(cx, cx.tables.expr_ty(&result_types[0]), sym!(result_type));

View file

@ -142,7 +142,7 @@ const HEURISTICS: [(&str, usize, Heuristic, Finiteness); 19] = [
fn is_infinite(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Finiteness {
match expr.kind {
ExprKind::MethodCall(ref method, _, ref args) => {
ExprKind::MethodCall(ref method, _, ref args, _) => {
for &(name, len, heuristic, cap) in &HEURISTICS {
if method.ident.name.as_str() == name && args.len() == len {
return (match heuristic {
@ -218,7 +218,7 @@ const INFINITE_COLLECTORS: [&[&str]; 8] = [
fn complete_infinite_iter(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Finiteness {
match expr.kind {
ExprKind::MethodCall(ref method, _, ref args) => {
ExprKind::MethodCall(ref method, _, ref args, _) => {
for &(name, len) in &COMPLETING_METHODS {
if method.ident.name.as_str() == name && args.len() == len {
return is_infinite(cx, &args[0]);

View file

@ -211,7 +211,8 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item<'_>, impl_items: &[Imp
}
fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>, op: &str, compare_to: u32) {
if let (&ExprKind::MethodCall(ref method_path, _, ref args), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
if let (&ExprKind::MethodCall(ref method_path, _, ref args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind)
{
// check if we are in an is_empty() method
if let Some(name) = get_item_name(cx, method) {
if name.as_str() == "is_empty" {

View file

@ -379,7 +379,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
TyKind::Path(ref path) => {
self.collect_anonymous_lifetimes(path, ty);
},
TyKind::Def(item, _) => {
TyKind::OpaqueDef(item, _) => {
let map = self.cx.tcx.hir();
if let ItemKind::OpaqueTy(ref exist_ty) = map.expect_item(item.id).kind {
for bound in exist_ty.bounds {

View file

@ -28,7 +28,7 @@ use rustc_middle::ty::{self, Ty, TyS};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use rustc_span::symbol::Symbol;
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
use std::iter::{once, Iterator};
use std::mem;
@ -526,7 +526,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops {
let pat = &arms[0].pat.kind;
if let (
&PatKind::TupleStruct(ref qpath, ref pat_args, _),
&ExprKind::MethodCall(ref method_path, _, ref method_args),
&ExprKind::MethodCall(ref method_path, _, ref method_args, _),
) = (pat, &match_expr.kind)
{
let iter_expr = &method_args[0];
@ -654,7 +654,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
| ExprKind::Struct(_, _, Some(ref e))
| ExprKind::Repeat(ref e, _)
| ExprKind::DropTemps(ref e) => never_loop_expr(e, main_loop_id),
ExprKind::Array(ref es) | ExprKind::MethodCall(_, _, ref es) | ExprKind::Tup(ref es) => {
ExprKind::Array(ref es) | ExprKind::MethodCall(_, _, ref es, _) | ExprKind::Tup(ref es) => {
never_loop_expr_all(&mut es.iter(), main_loop_id)
},
ExprKind::Call(ref e, ref es) => never_loop_expr_all(&mut once(&**e).chain(es.iter()), main_loop_id),
@ -806,7 +806,7 @@ fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
fn fetch_cloned_expr<'tcx>(expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
if_chain! {
if let ExprKind::MethodCall(method, _, args) = expr.kind;
if let ExprKind::MethodCall(method, _, args, _) = expr.kind;
if method.ident.name == sym!(clone);
if args.len() == 1;
if let Some(arg) = args.get(0);
@ -915,7 +915,7 @@ fn build_manual_memcpy_suggestion<'a, 'tcx>(
let print_limit = |end: &Expr<'_>, offset: Offset, var: &Expr<'_>| {
if_chain! {
if let ExprKind::MethodCall(method, _, len_args) = end.kind;
if let ExprKind::MethodCall(method, _, len_args, _) = end.kind;
if method.ident.name == sym!(len);
if len_args.len() == 1;
if let Some(arg) = len_args.get(0);
@ -1190,7 +1190,7 @@ fn check_for_loop_range<'a, 'tcx>(
fn is_len_call(expr: &Expr<'_>, var: Name) -> bool {
if_chain! {
if let ExprKind::MethodCall(ref method, _, ref len_args) = expr.kind;
if let ExprKind::MethodCall(ref method, _, ref len_args, _) = expr.kind;
if len_args.len() == 1;
if method.ident.name == sym!(len);
if let ExprKind::Path(QPath::Resolved(_, ref path)) = len_args[0].kind;
@ -1244,7 +1244,7 @@ fn lint_iter_method(cx: &LateContext<'_, '_>, args: &[Expr<'_>], arg: &Expr<'_>,
fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: &Expr<'_>) {
let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used
if let ExprKind::MethodCall(ref method, _, ref args) = arg.kind {
if let ExprKind::MethodCall(ref method, _, ref args, _) = arg.kind {
// just the receiver, no arguments
if args.len() == 1 {
let method_name = &*method.ident.as_str();
@ -1489,42 +1489,43 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
}
}
struct MutatePairDelegate {
struct MutatePairDelegate<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
hir_id_low: Option<HirId>,
hir_id_high: Option<HirId>,
span_low: Option<Span>,
span_high: Option<Span>,
}
impl<'tcx> Delegate<'tcx> for MutatePairDelegate {
fn consume(&mut self, _: &Place<'tcx>, _: ConsumeMode) {}
impl<'a, 'tcx> Delegate<'tcx> for MutatePairDelegate<'a, 'tcx> {
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: ConsumeMode) {}
fn borrow(&mut self, cmt: &Place<'tcx>, bk: ty::BorrowKind) {
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, bk: ty::BorrowKind) {
if let ty::BorrowKind::MutBorrow = bk {
if let PlaceBase::Local(id) = cmt.base {
if let PlaceBase::Local(id) = cmt.place.base {
if Some(id) == self.hir_id_low {
self.span_low = Some(cmt.span)
self.span_low = Some(self.cx.tcx.hir().span(cmt.hir_id))
}
if Some(id) == self.hir_id_high {
self.span_high = Some(cmt.span)
self.span_high = Some(self.cx.tcx.hir().span(cmt.hir_id))
}
}
}
}
fn mutate(&mut self, cmt: &Place<'tcx>) {
if let PlaceBase::Local(id) = cmt.base {
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>) {
if let PlaceBase::Local(id) = cmt.place.base {
if Some(id) == self.hir_id_low {
self.span_low = Some(cmt.span)
self.span_low = Some(self.cx.tcx.hir().span(cmt.hir_id))
}
if Some(id) == self.hir_id_high {
self.span_high = Some(cmt.span)
self.span_high = Some(self.cx.tcx.hir().span(cmt.hir_id))
}
}
}
}
impl<'tcx> MutatePairDelegate {
impl<'a, 'tcx> MutatePairDelegate<'a, 'tcx> {
fn mutation_span(&self) -> (Option<Span>, Option<Span>) {
(self.span_low, self.span_high)
}
@ -1579,12 +1580,13 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr<'_>) -> Option<Hi
None
}
fn check_for_mutation(
cx: &LateContext<'_, '_>,
fn check_for_mutation<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
body: &Expr<'_>,
bound_ids: &[Option<HirId>],
) -> (Option<Span>, Option<Span>) {
let mut delegate = MutatePairDelegate {
cx,
hir_id_low: bound_ids[0],
hir_id_high: bound_ids[1],
span_low: None,
@ -1718,7 +1720,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if_chain! {
// a range index op
if let ExprKind::MethodCall(ref meth, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref meth, _, ref args, _) = expr.kind;
if (meth.ident.name == sym!(index) && match_trait_method(self.cx, expr, &paths::INDEX))
|| (meth.ident.name == sym!(index_mut) && match_trait_method(self.cx, expr, &paths::INDEX_MUT));
if !self.check(&args[1], &args[0], expr);
@ -1776,7 +1778,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
self.visit_expr(expr);
}
},
ExprKind::MethodCall(_, _, args) => {
ExprKind::MethodCall(_, _, args, _) => {
let def_id = self.cx.tables.type_dependent_def_id(expr.hir_id).unwrap();
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
self.prefer_mutable = false;
@ -2369,8 +2371,8 @@ const NEEDLESS_COLLECT_MSG: &str = "avoid using `collect()` when not needed";
fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'a, 'tcx>) {
if_chain! {
if let ExprKind::MethodCall(ref method, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref chain_method, _, _) = args[0].kind;
if let ExprKind::MethodCall(ref method, _, ref args, _) = expr.kind;
if let ExprKind::MethodCall(ref chain_method, _, _, _) = args[0].kind;
if chain_method.ident.name == sym!(collect) && match_trait_method(cx, &args[0], &paths::ITERATOR);
if let Some(ref generic_args) = chain_method.args;
if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0);
@ -2437,7 +2439,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'a, '
fn shorten_span(expr: &Expr<'_>, target_fn_name: Symbol) -> Span {
let mut current_expr = expr;
while let ExprKind::MethodCall(ref path, ref span, ref args) = current_expr.kind {
while let ExprKind::MethodCall(ref path, ref span, ref args, _) = current_expr.kind {
if path.ident.name == target_fn_name {
return expr.span.with_lo(span.lo());
}

View file

@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ManualAsyncFn {
fn future_trait_ref<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &'tcx Ty<'tcx>) -> Option<&'tcx TraitRef<'tcx>> {
if_chain! {
if let TyKind::Def(item_id, _) = ty.kind;
if let TyKind::OpaqueDef(item_id, _) = ty.kind;
let item = cx.tcx.hir().item(item_id.id);
if let ItemKind::OpaqueTy(opaque) = &item.kind;
if opaque.bounds.len() == 1;

View file

@ -49,7 +49,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
}
if_chain! {
if let hir::ExprKind::MethodCall(ref method, _, ref args) = e.kind;
if let hir::ExprKind::MethodCall(ref method, _, ref args, _) = e.kind;
if args.len() == 2;
if method.ident.as_str() == "map";
let ty = cx.tables.expr_ty(&args[0]);
@ -75,7 +75,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone {
}
}
},
hir::ExprKind::MethodCall(ref method, _, ref obj) => {
hir::ExprKind::MethodCall(ref method, _, ref obj, _) => {
if ident_eq(name, &obj[0]) && method.ident.as_str() == "clone"
&& match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) {

View file

@ -125,7 +125,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a hir::Expr<'_>)
}
match expr.kind {
hir::ExprKind::Call(_, _) | hir::ExprKind::MethodCall(_, _, _) => {
hir::ExprKind::Call(_, _) | hir::ExprKind::MethodCall(_, _, _, _) => {
// Calls can't be reduced any more
Some(expr.span)
},

View file

@ -1429,7 +1429,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
}
match expr.kind {
hir::ExprKind::MethodCall(ref method_call, ref method_span, ref args) => {
hir::ExprKind::MethodCall(ref method_call, ref method_span, ref args, _) => {
lint_or_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
@ -1677,7 +1677,7 @@ fn lint_or_fun_call<'a, 'tcx>(
or_has_args: bool,
span: Span,
) {
if let hir::ExprKind::MethodCall(ref path, _, ref args) = &arg.kind {
if let hir::ExprKind::MethodCall(ref path, _, ref args, _) = &arg.kind {
if path.ident.as_str() == "len" {
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));
@ -1751,7 +1751,7 @@ fn lint_or_fun_call<'a, 'tcx>(
);
}
},
hir::ExprKind::MethodCall(_, span, ref or_args) => check_general_case(
hir::ExprKind::MethodCall(_, span, ref or_args, _) => check_general_case(
cx,
name,
method_span,
@ -1782,7 +1782,7 @@ fn lint_expect_fun_call(
loop {
arg_root = match &arg_root.kind {
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr) => expr,
hir::ExprKind::MethodCall(method_name, _, call_args) => {
hir::ExprKind::MethodCall(method_name, _, call_args, _) => {
if call_args.len() == 1
&& (method_name.ident.name == sym!(as_str) || method_name.ident.name == sym!(as_ref))
&& {
@ -2002,7 +2002,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, arg: &hir:
// &*x is a nop, &x.clone() is not
hir::ExprKind::AddrOf(..) => return,
// (*x).func() is useless, x.clone().func() can work in case func borrows mutably
hir::ExprKind::MethodCall(_, _, parent_args) if expr.hir_id == parent_args[0].hir_id => return,
hir::ExprKind::MethodCall(_, _, parent_args, _) if expr.hir_id == parent_args[0].hir_id => return,
_ => {},
},
@ -2478,7 +2478,7 @@ fn derefs_to_slice<'a, 'tcx>(
}
}
if let hir::ExprKind::MethodCall(ref path, _, ref args) = expr.kind {
if let hir::ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind {
if path.ident.name == sym!(iter) && may_slice(cx, cx.tables.expr_ty(&args[0])) {
Some(&args[0])
} else {
@ -3182,7 +3182,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, call_name: &str, a
// allow the `as_ref` or `as_mut` if it is followed by another method call
if_chain! {
if let Some(parent) = get_parent_expr(cx, expr);
if let hir::ExprKind::MethodCall(_, ref span, _) = parent.kind;
if let hir::ExprKind::MethodCall(_, ref span, _, _) = parent.kind;
if span != &expr.span;
then {
return;
@ -3310,7 +3310,7 @@ fn lint_option_as_ref_deref<'a, 'tcx>(
let closure_expr = remove_blocks(&closure_body.value);
match &closure_expr.kind {
hir::ExprKind::MethodCall(_, _, args) => {
hir::ExprKind::MethodCall(_, _, args, _) => {
if_chain! {
if args.len() == 1;
if let hir::ExprKind::Path(qpath) = &args[0].kind;

View file

@ -545,7 +545,7 @@ fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
}
if_chain! {
if let ExprKind::MethodCall(ref method_name, _, ref expressions) = expr.kind;
if let ExprKind::MethodCall(ref method_name, _, ref expressions, _) = expr.kind;
if sym!(signum) == method_name.ident.name;
// Check that the receiver of the signum() is a float (expressions[0] is the receiver of
// the method call)
@ -572,7 +572,7 @@ fn is_array(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr<'_>, other: &Expr<'_>) {
let (arg_ty, snip) = match expr.kind {
ExprKind::MethodCall(.., ref args) if args.len() == 1 => {
ExprKind::MethodCall(.., ref args, _) if args.len() == 1 => {
if match_trait_method(cx, expr, &paths::TO_STRING) || match_trait_method(cx, expr, &paths::TO_OWNED) {
(cx.tables.expr_ty_adjusted(&args[0]), snippet(cx, args[0].span, ".."))
} else {

View file

@ -187,7 +187,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
hir::ImplItemKind::Const(..) => "an associated constant",
hir::ImplItemKind::Fn(..) => "a method",
hir::ImplItemKind::TyAlias(_) => "an associated type",
hir::ImplItemKind::OpaqueTy(_) => "an existential type",
};
self.check_missing_docs_attrs(cx, &impl_item.attrs, impl_item.span, desc);
}

View file

@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
let desc = match impl_item.kind {
hir::ImplItemKind::Fn(..) => "a method",
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) | hir::ImplItemKind::OpaqueTy(_) => return,
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) => return,
};
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);

View file

@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
);
}
},
ExprKind::MethodCall(ref path, _, ref arguments) => {
ExprKind::MethodCall(ref path, _, ref arguments, _) => {
let def_id = cx.tables.type_dependent_def_id(e.hir_id).unwrap();
let substs = cx.tables.node_substs(e.hir_id);
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);

View file

@ -319,21 +319,21 @@ struct MovedVariablesCtxt {
}
impl MovedVariablesCtxt {
fn move_common(&mut self, cmt: &euv::Place<'_>) {
if let euv::PlaceBase::Local(vid) = cmt.base {
fn move_common(&mut self, cmt: &euv::PlaceWithHirId<'_>) {
if let euv::PlaceBase::Local(vid) = cmt.place.base {
self.moved_vars.insert(vid);
}
}
}
impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
fn consume(&mut self, cmt: &euv::Place<'tcx>, mode: euv::ConsumeMode) {
fn consume(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, mode: euv::ConsumeMode) {
if let euv::ConsumeMode::Move = mode {
self.move_common(cmt);
}
}
fn borrow(&mut self, _: &euv::Place<'tcx>, _: ty::BorrowKind) {}
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: ty::BorrowKind) {}
fn mutate(&mut self, _: &euv::Place<'tcx>) {}
fn mutate(&mut self, _: &euv::PlaceWithHirId<'tcx>) {}
}

View file

@ -29,7 +29,7 @@ declare_lint_pass!(OpenOptions => [NONSENSICAL_OPEN_OPTIONS]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OpenOptions {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
if let ExprKind::MethodCall(ref path, _, ref arguments) = e.kind {
if let ExprKind::MethodCall(ref path, _, ref arguments, _) = e.kind {
let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(&arguments[0]));
if path.ident.name == sym!(open) && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
let mut options = Vec::new();
@ -57,7 +57,7 @@ enum OpenOption {
}
fn get_open_options(cx: &LateContext<'_, '_>, argument: &Expr<'_>, options: &mut Vec<(OpenOption, Argument)>) {
if let ExprKind::MethodCall(ref path, _, ref arguments) = argument.kind {
if let ExprKind::MethodCall(ref path, _, ref arguments, _) = argument.kind {
let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(&arguments[0]));
// Only proceed if this is a call on some object of type std::fs::OpenOptions

View file

@ -35,7 +35,7 @@ declare_lint_pass!(OptionEnvUnwrap => [OPTION_ENV_UNWRAP]);
impl EarlyLintPass for OptionEnvUnwrap {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if_chain! {
if let ExprKind::MethodCall(path_segment, args) = &expr.kind;
if let ExprKind::MethodCall(path_segment, args, _) = &expr.kind;
let method_name = path_segment.ident.as_str();
if method_name == "expect" || method_name == "unwrap";
if let ExprKind::Call(caller, _) = &args[0].kind;

View file

@ -43,7 +43,7 @@ declare_lint_pass!(PathBufPushOverwrite => [PATH_BUF_PUSH_OVERWRITE]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathBufPushOverwrite {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
if path.ident.name == sym!(push);
if args.len() == 2;
if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::PATH_BUF);

View file

@ -103,7 +103,7 @@ impl EarlyLintPass for Precedence {
}
if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.kind {
if let ExprKind::MethodCall(ref path_segment, ref args) = rhs.kind {
if let ExprKind::MethodCall(ref path_segment, ref args, _) = rhs.kind {
let path_segment_str = path_segment.ident.name.as_str();
if let Some(slf) = args.first() {
if let ExprKind::Lit(ref lit) = slf.kind {

View file

@ -90,7 +90,7 @@ fn expr_as_ptr_offset_call<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
expr: &'tcx Expr<'_>,
) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, Method)> {
if let ExprKind::MethodCall(ref path_segment, _, ref args) = expr.kind {
if let ExprKind::MethodCall(ref path_segment, _, ref args, _) = expr.kind {
if is_expr_ty_raw_ptr(cx, &args[0]) {
if path_segment.ident.name == sym!(offset) {
return Some((&args[0], &args[1], Method::Offset));

View file

@ -50,7 +50,7 @@ impl QuestionMark {
fn check_is_none_and_early_return_none(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
if_chain! {
if let Some((if_expr, body, else_)) = higher::if_block(&expr);
if let ExprKind::MethodCall(segment, _, args) = &if_expr.kind;
if let ExprKind::MethodCall(segment, _, args, _) = &if_expr.kind;
if segment.ident.name == sym!(is_none);
if Self::expression_returns_none(cx, body);
if let Some(subject) = args.get(0);

View file

@ -129,20 +129,20 @@ declare_lint_pass!(Ranges => [
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind {
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind {
let name = path.ident.as_str();
if name == "zip" && args.len() == 2 {
let iter = &args[0].kind;
let zip_arg = &args[1];
if_chain! {
// `.iter()` call
if let ExprKind::MethodCall(ref iter_path, _, ref iter_args ) = *iter;
if let ExprKind::MethodCall(ref iter_path, _, ref iter_args , _) = *iter;
if iter_path.ident.name == sym!(iter);
// range expression in `.zip()` call: `0..x.len()`
if let Some(higher::Range { start: Some(start), end: Some(end), .. }) = higher::range(cx, zip_arg);
if is_integer_const(cx, start, 0);
// `.len()` call
if let ExprKind::MethodCall(ref len_path, _, ref len_args) = end.kind;
if let ExprKind::MethodCall(ref len_path, _, ref len_args, _) = end.kind;
if len_path.ident.name == sym!(len) && len_args.len() == 1;
// `.iter()` and `.len()` called on same `Path`
if let ExprKind::Path(QPath::Resolved(_, ref iter_path)) = iter_args[0].kind;

View file

@ -89,7 +89,7 @@ fn find_sugg_for_if_let<'a, 'tcx>(
// check that `while_let_on_iterator` lint does not trigger
if_chain! {
if keyword == "while";
if let ExprKind::MethodCall(method_path, _, _) = op.kind;
if let ExprKind::MethodCall(method_path, _, _, _) = op.kind;
if method_path.ident.name == sym!(next);
if match_trait_method(cx, op, &paths::ITERATOR);
then {

View file

@ -207,7 +207,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> {
fn search_slow_extend_filling(&mut self, expr: &'tcx Expr<'_>) {
if_chain! {
if self.initialization_found;
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
if let ExprKind::Path(ref qpath_subj) = args[0].kind;
if match_qpath(&qpath_subj, &[&*self.vec_alloc.variable_name.as_str()]);
if path.ident.name == sym!(extend);
@ -224,7 +224,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> {
fn search_slow_resize_filling(&mut self, expr: &'tcx Expr<'_>) {
if_chain! {
if self.initialization_found;
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
if let ExprKind::Path(ref qpath_subj) = args[0].kind;
if match_qpath(&qpath_subj, &[&*self.vec_alloc.variable_name.as_str()]);
if path.ident.name == sym!(resize);
@ -246,7 +246,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> {
/// Returns `true` if give expression is `repeat(0).take(...)`
fn is_repeat_take(&self, expr: &Expr<'_>) -> bool {
if_chain! {
if let ExprKind::MethodCall(ref take_path, _, ref take_args) = expr.kind;
if let ExprKind::MethodCall(ref take_path, _, ref take_args, _) = expr.kind;
if take_path.ident.name == sym!(take);
// Check that take is applied to `repeat(0)`

View file

@ -164,7 +164,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
use rustc_ast::ast::LitKind;
if_chain! {
if let ExprKind::MethodCall(path, _, args) = &e.kind;
if let ExprKind::MethodCall(path, _, args, _) = &e.kind;
if path.ident.name == sym!(as_bytes);
if let ExprKind::Lit(lit) = &args[0].kind;
if let LitKind::Str(lit_content, _) = &lit.node;

View file

@ -34,12 +34,12 @@ declare_lint_pass!(ToDigitIsSome => [TO_DIGIT_IS_SOME]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ToDigitIsSome {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'_>) {
if_chain! {
if let hir::ExprKind::MethodCall(is_some_path, _, is_some_args) = &expr.kind;
if let hir::ExprKind::MethodCall(is_some_path, _, is_some_args, _) = &expr.kind;
if is_some_path.ident.name.as_str() == "is_some";
if let [to_digit_expr] = &**is_some_args;
then {
let match_result = match &to_digit_expr.kind {
hir::ExprKind::MethodCall(to_digits_path, _, to_digit_args) => {
hir::ExprKind::MethodCall(to_digits_path, _, to_digit_args, _) => {
if_chain! {
if let [char_arg, radix_arg] = &**to_digit_args;
if to_digits_path.ident.name.as_str() == "to_digit";

View file

@ -778,7 +778,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg {
}
match expr.kind {
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args) => {
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args, _) => {
let args_to_recover = args
.iter()
.filter(|arg| {
@ -1262,14 +1262,14 @@ fn check_loss_of_sign(cx: &LateContext<'_, '_>, expr: &Expr<'_>, op: &Expr<'_>,
}
// don't lint for the result of methods that always return non-negative values
if let ExprKind::MethodCall(ref path, _, _) = op.kind {
if let ExprKind::MethodCall(ref path, _, _, _) = op.kind {
let mut method_name = path.ident.name.as_str();
let whitelisted_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"];
if_chain! {
if method_name == "unwrap";
if let Some(arglist) = method_chain_args(op, &["unwrap"]);
if let ExprKind::MethodCall(ref inner_path, _, _) = &arglist[0][0].kind;
if let ExprKind::MethodCall(ref inner_path, _, _, _) = &arglist[0][0].kind;
then {
method_name = inner_path.ident.name.as_str();
}
@ -1945,19 +1945,15 @@ fn detect_extreme_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_
let which = match (&ty.kind, cv) {
(&ty::Bool, Constant::Bool(false)) | (&ty::Uint(_), Constant::Int(0)) => Minimum,
(&ty::Int(ity), Constant::Int(i))
if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) =>
{
(&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MIN >> (128 - int_bits(cx.tcx, ity)), ity) => {
Minimum
},
(&ty::Bool, Constant::Bool(true)) => Maximum,
(&ty::Int(ity), Constant::Int(i))
if i == unsext(cx.tcx, i128::max_value() >> (128 - int_bits(cx.tcx, ity)), ity) =>
{
(&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MAX >> (128 - int_bits(cx.tcx, ity)), ity) => {
Maximum
},
(&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::max_value(), uty) == i => Maximum,
(&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::MAX, uty) == i => Maximum,
_ => return None,
};
@ -2039,7 +2035,7 @@ impl FullInt {
fn cmp_s_u(s: i128, u: u128) -> Ordering {
if s < 0 {
Ordering::Less
} else if u > (i128::max_value() as u128) {
} else if u > (i128::MAX as u128) {
Ordering::Greater
} else {
(s as u128).cmp(&u)
@ -2083,50 +2079,20 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr<'_>)
}
match pre_cast_ty.kind {
ty::Int(int_ty) => Some(match int_ty {
IntTy::I8 => (
FullInt::S(i128::from(i8::min_value())),
FullInt::S(i128::from(i8::max_value())),
),
IntTy::I16 => (
FullInt::S(i128::from(i16::min_value())),
FullInt::S(i128::from(i16::max_value())),
),
IntTy::I32 => (
FullInt::S(i128::from(i32::min_value())),
FullInt::S(i128::from(i32::max_value())),
),
IntTy::I64 => (
FullInt::S(i128::from(i64::min_value())),
FullInt::S(i128::from(i64::max_value())),
),
IntTy::I128 => (FullInt::S(i128::min_value()), FullInt::S(i128::max_value())),
IntTy::Isize => (
FullInt::S(isize::min_value() as i128),
FullInt::S(isize::max_value() as i128),
),
IntTy::I8 => (FullInt::S(i128::from(i8::MIN)), FullInt::S(i128::from(i8::MAX))),
IntTy::I16 => (FullInt::S(i128::from(i16::MIN)), FullInt::S(i128::from(i16::MAX))),
IntTy::I32 => (FullInt::S(i128::from(i32::MIN)), FullInt::S(i128::from(i32::MAX))),
IntTy::I64 => (FullInt::S(i128::from(i64::MIN)), FullInt::S(i128::from(i64::MAX))),
IntTy::I128 => (FullInt::S(i128::MIN), FullInt::S(i128::MAX)),
IntTy::Isize => (FullInt::S(isize::MIN as i128), FullInt::S(isize::MAX as i128)),
}),
ty::Uint(uint_ty) => Some(match uint_ty {
UintTy::U8 => (
FullInt::U(u128::from(u8::min_value())),
FullInt::U(u128::from(u8::max_value())),
),
UintTy::U16 => (
FullInt::U(u128::from(u16::min_value())),
FullInt::U(u128::from(u16::max_value())),
),
UintTy::U32 => (
FullInt::U(u128::from(u32::min_value())),
FullInt::U(u128::from(u32::max_value())),
),
UintTy::U64 => (
FullInt::U(u128::from(u64::min_value())),
FullInt::U(u128::from(u64::max_value())),
),
UintTy::U128 => (FullInt::U(u128::min_value()), FullInt::U(u128::max_value())),
UintTy::Usize => (
FullInt::U(usize::min_value() as u128),
FullInt::U(usize::max_value() as u128),
),
UintTy::U8 => (FullInt::U(u128::from(u8::MIN)), FullInt::U(u128::from(u8::MAX))),
UintTy::U16 => (FullInt::U(u128::from(u16::MIN)), FullInt::U(u128::from(u16::MAX))),
UintTy::U32 => (FullInt::U(u128::from(u32::MIN)), FullInt::U(u128::from(u32::MAX))),
UintTy::U64 => (FullInt::U(u128::from(u64::MIN)), FullInt::U(u128::from(u64::MAX))),
UintTy::U128 => (FullInt::U(u128::MIN), FullInt::U(u128::MAX)),
UintTy::Usize => (FullInt::U(usize::MIN as u128), FullInt::U(usize::MAX as u128)),
}),
_ => None,
}

View file

@ -95,7 +95,10 @@ fn mirrored_exprs(
// The two exprs are method calls.
// Check to see that the function is the same and the arguments are mirrored
// This is enough because the receiver of the method is listed in the arguments
(ExprKind::MethodCall(left_segment, _, left_args), ExprKind::MethodCall(right_segment, _, right_args)) => {
(
ExprKind::MethodCall(left_segment, _, left_args, _),
ExprKind::MethodCall(right_segment, _, right_args, _),
) => {
left_segment.ident == right_segment.ident
&& left_args
.iter()
@ -170,7 +173,7 @@ fn mirrored_exprs(
fn detect_lint(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<LintTrigger> {
if_chain! {
if let ExprKind::MethodCall(name_ident, _, args) = &expr.kind;
if let ExprKind::MethodCall(name_ident, _, args, _) = &expr.kind;
if let name = name_ident.ident.name.to_ident_string();
if name == "sort_by" || name == "sort_unstable_by";
if let [vec, Expr { kind: ExprKind::Closure(_, _, closure_body_id, _, _), .. }] = args;
@ -180,7 +183,7 @@ fn detect_lint(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<LintTrigger>
Param { pat: Pat { kind: PatKind::Binding(_, _, left_ident, _), .. }, ..},
Param { pat: Pat { kind: PatKind::Binding(_, _, right_ident, _), .. }, .. }
] = &closure_body.params;
if let ExprKind::MethodCall(method_path, _, [ref left_expr, ref right_expr]) = &closure_body.value.kind;
if let ExprKind::MethodCall(method_path, _, [ref left_expr, ref right_expr], _) = &closure_body.value.kind;
if method_path.ident.name.to_ident_string() == "cmp";
then {
let (closure_body, closure_arg, reverse) = if mirrored_exprs(

View file

@ -52,7 +52,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
}
},
hir::ExprKind::MethodCall(ref path, _, ref args) => match &*path.ident.as_str() {
hir::ExprKind::MethodCall(ref path, _, ref args, _) => match &*path.ident.as_str() {
"expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => {
check_method_call(cx, &args[0], expr);
},
@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
}
fn check_method_call(cx: &LateContext<'_, '_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>) {
if let hir::ExprKind::MethodCall(ref path, _, _) = call.kind {
if let hir::ExprKind::MethodCall(ref path, _, _, _) = call.kind {
let symbol = &*path.ident.as_str();
let read_trait = match_trait_method(cx, call, &paths::IO_READ);
let write_trait = match_trait_method(cx, call, &paths::IO_WRITE);

View file

@ -112,7 +112,7 @@ fn collect_unwrap_info<'a, 'tcx>(
return collect_unwrap_info(cx, expr, branch, !invert);
} else {
if_chain! {
if let ExprKind::MethodCall(method_name, _, args) = &expr.kind;
if let ExprKind::MethodCall(method_name, _, args, _) = &expr.kind;
if let ExprKind::Path(QPath::Resolved(None, path)) = &args[0].kind;
let ty = cx.tables.expr_ty(&args[0]);
let name = method_name.ident.as_str();
@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
} else {
// find `unwrap[_err]()` calls:
if_chain! {
if let ExprKind::MethodCall(ref method_name, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref method_name, _, ref args, _) = expr.kind;
if let ExprKind::Path(QPath::Resolved(None, ref path)) = args[0].kind;
if [sym!(unwrap), sym!(unwrap_err)].contains(&method_name.ident.name);
let call_to_unwrap = method_name.ident.name == sym!(unwrap);

View file

@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessConversion {
}
},
ExprKind::MethodCall(ref name, .., ref args) => {
ExprKind::MethodCall(ref name, .., ref args, _) => {
if match_trait_method(cx, e, &paths::INTO) && &*name.ident.as_str() == "into" {
let a = cx.tables.expr_ty(e);
let b = cx.tables.expr_ty(&args[0]);

View file

@ -120,7 +120,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
(Array(l), Array(r)) | (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)),
(Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value),
(Call(lc, la), Call(rc, ra)) => eq_expr(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
(MethodCall(lc, la), MethodCall(rc, ra)) => eq_path_seg(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
(MethodCall(lc, la, _), MethodCall(rc, ra, _)) => eq_path_seg(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
(Binary(lo, ll, lr), Binary(ro, rl, rr)) => lo.node == ro.node && eq_expr(ll, rl) && eq_expr(lr, rr),
(Unary(lo, l), Unary(ro, r)) => mem::discriminant(lo) == mem::discriminant(ro) && eq_expr(l, r),
(Lit(l), Lit(r)) => l.kind == r.kind,

View file

@ -250,8 +250,11 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
self.visit_expr(arg);
}
},
ExprKind::MethodCall(ref _method_name, ref _generics, ref _args) => {
println!("MethodCall(ref method_name, ref generics, ref args) = {};", current);
ExprKind::MethodCall(ref _method_name, ref _generics, ref _args, ref _fn_span) => {
println!(
"MethodCall(ref method_name, ref generics, ref args, ref fn_span) = {};",
current
);
println!(" // unimplemented: `ExprKind::MethodCall` is not further destructured at the moment");
},
ExprKind::Tup(ref elements) => {

View file

@ -132,7 +132,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
&& self.eq_pat(&l.pat, &r.pat)
})
},
(&ExprKind::MethodCall(l_path, _, l_args), &ExprKind::MethodCall(r_path, _, r_args)) => {
(&ExprKind::MethodCall(l_path, _, l_args, _), &ExprKind::MethodCall(r_path, _, r_args, _)) => {
!self.ignore_fn && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args)
},
(&ExprKind::Repeat(ref le, ref ll_id), &ExprKind::Repeat(ref re, ref rl_id)) => {
@ -539,7 +539,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
s.hash(&mut self.s);
},
ExprKind::MethodCall(ref path, ref _tys, args) => {
ExprKind::MethodCall(ref path, ref _tys, args, ref _fn_span) => {
self.hash_name(path.ident.name);
self.hash_exprs(args);
},
@ -707,7 +707,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
segment.ident.name.hash(&mut self.s);
},
},
TyKind::Def(_, arg_list) => {
TyKind::OpaqueDef(_, arg_list) => {
for arg in *arg_list {
match arg {
GenericArg::Lifetime(ref l) => self.hash_lifetime(l),

View file

@ -63,7 +63,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector {
},
hir::ImplItemKind::Fn(..) => println!("method"),
hir::ImplItemKind::TyAlias(_) => println!("associated type"),
hir::ImplItemKind::OpaqueTy(_) => println!("existential type"),
}
}
// fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx
@ -167,7 +166,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, indent: usize) {
print_expr(cx, arg, indent + 1);
}
},
hir::ExprKind::MethodCall(ref path, _, args) => {
hir::ExprKind::MethodCall(ref path, _, args, _) => {
println!("{}MethodCall", ind);
println!("{}method name: {}", ind, path.ident.name);
for arg in args {

View file

@ -402,7 +402,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions {
}
if_chain! {
if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind;
if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
let fn_name = path.ident;
if let Some(sugg) = self.map.get(&*fn_name.as_str());
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));
@ -491,7 +491,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CollapsibleCalls {
let stmts = &block.stmts;
if stmts.len() == 1 && block.expr.is_none();
if let StmtKind::Semi(only_expr) = &stmts[0].kind;
if let ExprKind::MethodCall(ref ps, _, ref span_call_args) = &only_expr.kind;
if let ExprKind::MethodCall(ref ps, _, ref span_call_args, _) = &only_expr.kind;
let and_then_snippets = get_and_then_snippets(cx, and_then_args);
let mut sle = SpanlessEq::new(cx).ignore_fn();
then {

View file

@ -379,7 +379,7 @@ pub fn method_calls<'tcx>(
let mut current = expr;
for _ in 0..max_depth {
if let ExprKind::MethodCall(path, span, args) = &current.kind {
if let ExprKind::MethodCall(path, span, args, _) = &current.kind {
if args.iter().any(|e| e.span.from_expansion()) {
break;
}
@ -406,7 +406,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec
let mut matched = Vec::with_capacity(methods.len());
for method_name in methods.iter().rev() {
// method chains are stored last -> first
if let ExprKind::MethodCall(ref path, _, ref args) = current.kind {
if let ExprKind::MethodCall(ref path, _, ref args, _) = current.kind {
if path.ident.name.as_str() == *method_name {
if args.iter().any(|e| e.span.from_expansion()) {
return None;
@ -1324,7 +1324,7 @@ pub fn is_must_use_func_call(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool
None
}
},
ExprKind::MethodCall(_, _, _) => cx.tables.type_dependent_def_id(expr.hir_id),
ExprKind::MethodCall(_, _, _, _) => cx.tables.type_dependent_def_id(expr.hir_id),
_ => None,
};

View file

@ -58,7 +58,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> {
if self.abort {
return;
}
if let ExprKind::MethodCall(ref seg, _, ref args) = expr.kind {
if let ExprKind::MethodCall(ref seg, _, ref args, _) = expr.kind {
if args.len() == 1 && match_var(&args[0], self.name) {
if seg.ident.name.as_str() == "capacity" {
self.abort = true;

View file

@ -8,7 +8,7 @@ use rustc_lint::LateContext;
use rustc_middle::hir::map::Map;
use rustc_middle::ty;
use rustc_span::symbol::{Ident, Symbol};
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<HirId>> {
@ -46,8 +46,8 @@ struct MutVarsDelegate {
impl<'tcx> MutVarsDelegate {
#[allow(clippy::similar_names)]
fn update(&mut self, cat: &Place<'tcx>) {
match cat.base {
fn update(&mut self, cat: &PlaceWithHirId<'tcx>) {
match cat.place.base {
PlaceBase::Local(id) => {
self.used_mutably.insert(id);
},
@ -63,15 +63,15 @@ impl<'tcx> MutVarsDelegate {
}
impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
fn consume(&mut self, _: &Place<'tcx>, _: ConsumeMode) {}
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: ConsumeMode) {}
fn borrow(&mut self, cmt: &Place<'tcx>, bk: ty::BorrowKind) {
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, bk: ty::BorrowKind) {
if let ty::BorrowKind::MutBorrow = bk {
self.update(&cmt)
}
}
fn mutate(&mut self, cmt: &Place<'tcx>) {
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>) {
self.update(&cmt)
}
}

View file

@ -31,7 +31,7 @@ declare_lint_pass!(VecResizeToZero => [VEC_RESIZE_TO_ZERO]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VecResizeToZero {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
if let hir::ExprKind::MethodCall(path_segment, _, ref args) = expr.kind;
if let hir::ExprKind::MethodCall(path_segment, _, ref args, _) = expr.kind;
if let Some(method_def_id) = cx.tables.type_dependent_def_id(expr.hir_id);
if match_def_path(cx, method_def_id, &paths::VEC_RESIZE) && args.len() == 3;
if let ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = args[1].kind;

View file

@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VerboseFileReads {
fn is_file_read_to_end<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
if_chain! {
if let ExprKind::MethodCall(method_name, _, exprs) = expr.kind;
if let ExprKind::MethodCall(method_name, _, exprs, _) = expr.kind;
if method_name.ident.as_str() == "read_to_end";
if let ExprKind::Path(QPath::Resolved(None, _)) = &exprs[0].kind;
let ty = cx.tables.expr_ty(&exprs[0]);
@ -73,7 +73,7 @@ fn is_file_read_to_end<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'t
fn is_file_read_to_string<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
if_chain! {
if let ExprKind::MethodCall(method_name, _, exprs) = expr.kind;
if let ExprKind::MethodCall(method_name, _, exprs, _) = expr.kind;
if method_name.ident.as_str() == "read_to_string";
if let ExprKind::Path(QPath::Resolved(None, _)) = &exprs[0].kind;
let ty = cx.tables.expr_ty(&exprs[0]);

View file

@ -49,7 +49,9 @@ fn third_party_crates() -> String {
if let Some(name) = path.file_name().and_then(OsStr::to_str) {
for dep in CRATES {
if name.starts_with(&format!("lib{}-", dep)) && name.ends_with(".rlib") {
crates.entry(dep).or_insert(path);
if let Some(old) = crates.insert(dep, path.clone()) {
panic!("Found multiple rlibs for crate `{}`: `{:?}` and `{:?}", dep, old, path);
}
break;
}
}

View file

@ -37,11 +37,11 @@ fn main() {
1isize as usize;
-1isize as usize;
0i8 as u8;
i8::max_value() as u8;
i16::max_value() as u16;
i32::max_value() as u32;
i64::max_value() as u64;
i128::max_value() as u128;
i8::MAX as u8;
i16::MAX as u16;
i32::MAX as u32;
i64::MAX as u64;
i128::MAX as u128;
(-1i8).abs() as u8;
(-1i16).abs() as u16;

View file

@ -110,7 +110,7 @@ fn main() {
}
// Lint
if i_8 > i8::min_value() {
if i_8 > i8::MIN {
i_8 -= 1;
}
@ -120,7 +120,7 @@ fn main() {
}
// Lint
if i_8 != i8::min_value() {
if i_8 != i8::MIN {
i_8 -= 1;
}
@ -135,7 +135,7 @@ fn main() {
}
// Lint
if i_16 > i16::min_value() {
if i_16 > i16::MIN {
i_16 -= 1;
}
@ -145,7 +145,7 @@ fn main() {
}
// Lint
if i_16 != i16::min_value() {
if i_16 != i16::MIN {
i_16 -= 1;
}
@ -160,7 +160,7 @@ fn main() {
}
// Lint
if i_32 > i32::min_value() {
if i_32 > i32::MIN {
i_32 -= 1;
}
@ -170,7 +170,7 @@ fn main() {
}
// Lint
if i_32 != i32::min_value() {
if i_32 != i32::MIN {
i_32 -= 1;
}
@ -180,7 +180,7 @@ fn main() {
let mut i_64: i64 = endi_64 - starti_64;
// Lint
if i64::min_value() < i_64 {
if i64::MIN < i_64 {
i_64 -= 1;
}

View file

@ -75,7 +75,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:113:5
|
LL | / if i_8 > i8::min_value() {
LL | / if i_8 > i8::MIN {
LL | | i_8 -= 1;
LL | | }
| |_____^ help: try: `i_8 = i_8.saturating_sub(1);`
@ -91,7 +91,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:123:5
|
LL | / if i_8 != i8::min_value() {
LL | / if i_8 != i8::MIN {
LL | | i_8 -= 1;
LL | | }
| |_____^ help: try: `i_8 = i_8.saturating_sub(1);`
@ -107,7 +107,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:138:5
|
LL | / if i_16 > i16::min_value() {
LL | / if i_16 > i16::MIN {
LL | | i_16 -= 1;
LL | | }
| |_____^ help: try: `i_16 = i_16.saturating_sub(1);`
@ -123,7 +123,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:148:5
|
LL | / if i_16 != i16::min_value() {
LL | / if i_16 != i16::MIN {
LL | | i_16 -= 1;
LL | | }
| |_____^ help: try: `i_16 = i_16.saturating_sub(1);`
@ -139,7 +139,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:163:5
|
LL | / if i_32 > i32::min_value() {
LL | / if i_32 > i32::MIN {
LL | | i_32 -= 1;
LL | | }
| |_____^ help: try: `i_32 = i_32.saturating_sub(1);`
@ -155,7 +155,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:173:5
|
LL | / if i_32 != i32::min_value() {
LL | / if i_32 != i32::MIN {
LL | | i_32 -= 1;
LL | | }
| |_____^ help: try: `i_32 = i_32.saturating_sub(1);`
@ -163,7 +163,7 @@ LL | | }
error: Implicitly performing saturating subtraction
--> $DIR/implicit_saturating_sub.rs:183:5
|
LL | / if i64::min_value() < i_64 {
LL | / if i64::MIN < i_64 {
LL | | i_64 -= 1;
LL | | }
| |_____^ help: try: `i_64 = i_64.saturating_sub(1);`