mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Auto merge of #4788 - Manishearth:rustup, r=flip1995
Rustup to rustc 1.40.0-nightly (50f8aadd 2019-11-07) changelog: Deprecate [`into_iter_on_array`] lint r? @phansch @oli-obk
This commit is contained in:
commit
7531a08eed
27 changed files with 124 additions and 166 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
|
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
|
||||||
|
|
||||||
[There are 332 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
|
[There are 331 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
|
||||||
|
|
||||||
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
|
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustc::hir::*;
|
||||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||||
use rustc::{declare_lint_pass, declare_tool_lint};
|
use rustc::{declare_lint_pass, declare_tool_lint};
|
||||||
use std::f64::consts as f64;
|
use std::f64::consts as f64;
|
||||||
use syntax::ast::{FloatTy, LitKind};
|
use syntax::ast::{FloatTy, LitFloatType, LitKind};
|
||||||
use syntax::symbol;
|
use syntax::symbol;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -62,9 +62,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ApproxConstant {
|
||||||
|
|
||||||
fn check_lit(cx: &LateContext<'_, '_>, lit: &LitKind, e: &Expr) {
|
fn check_lit(cx: &LateContext<'_, '_>, lit: &LitKind, e: &Expr) {
|
||||||
match *lit {
|
match *lit {
|
||||||
LitKind::Float(s, FloatTy::F32) => check_known_consts(cx, e, s, "f32"),
|
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
|
||||||
LitKind::Float(s, FloatTy::F64) => check_known_consts(cx, e, s, "f64"),
|
FloatTy::F32 => check_known_consts(cx, e, s, "f32"),
|
||||||
LitKind::FloatUnsuffixed(s) => check_known_consts(cx, e, s, "f{32, 64}"),
|
FloatTy::F64 => check_known_consts(cx, e, s, "f64"),
|
||||||
|
},
|
||||||
|
LitKind::Float(s, LitFloatType::Unsuffixed) => check_known_consts(cx, e, s, "f{32, 64}"),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use rustc::ty;
|
||||||
use rustc::{declare_lint_pass, declare_tool_lint};
|
use rustc::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
use syntax::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
||||||
use syntax::source_map::Span;
|
use syntax::source_map::Span;
|
||||||
use syntax_pos::symbol::Symbol;
|
use syntax_pos::symbol::Symbol;
|
||||||
|
|
||||||
|
@ -417,11 +417,14 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
|
||||||
}
|
}
|
||||||
|
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
if attr.is_sugared_doc {
|
let attr_item = if let AttrKind::Normal(ref attr) = attr.kind {
|
||||||
return;
|
attr
|
||||||
}
|
} else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
if attr.style == AttrStyle::Outer {
|
if attr.style == AttrStyle::Outer {
|
||||||
if attr.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
|
if attr_item.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,9 +161,11 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
|
||||||
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
|
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
|
||||||
LitKind::Char(c) => Constant::Char(c),
|
LitKind::Char(c) => Constant::Char(c),
|
||||||
LitKind::Int(n, _) => Constant::Int(n),
|
LitKind::Int(n, _) => Constant::Int(n),
|
||||||
LitKind::Float(ref is, FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
|
||||||
LitKind::Float(ref is, FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
|
||||||
LitKind::FloatUnsuffixed(ref is) => match ty.expect("type of float is known").kind {
|
FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
|
||||||
|
},
|
||||||
|
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind {
|
||||||
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
||||||
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
|
|
|
@ -130,3 +130,12 @@ declare_deprecated_lint! {
|
||||||
pub UNUSED_COLLECT,
|
pub UNUSED_COLLECT,
|
||||||
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
|
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_deprecated_lint! {
|
||||||
|
/// **What it does:** Nothing. This lint has been deprecated.
|
||||||
|
///
|
||||||
|
/// **Deprecation reason:** This lint has been uplifted to rustc and is now called
|
||||||
|
/// `array_into_iter`.
|
||||||
|
pub INTO_ITER_ON_ARRAY,
|
||||||
|
"this lint has been uplifted to rustc and is now called `array_into_iter`"
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||||
use rustc::{declare_tool_lint, impl_lint_pass};
|
use rustc::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use syntax::ast::Attribute;
|
use syntax::ast::{AttrKind, Attribute};
|
||||||
use syntax::source_map::{BytePos, Span};
|
use syntax::source_map::{BytePos, Span};
|
||||||
use syntax_pos::Pos;
|
use syntax_pos::Pos;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -247,13 +247,11 @@ pub fn check_attrs<'a>(cx: &LateContext<'_, '_>, valid_idents: &FxHashSet<String
|
||||||
let mut spans = vec![];
|
let mut spans = vec![];
|
||||||
|
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
if attr.is_sugared_doc {
|
if let AttrKind::DocComment(ref comment) = attr.kind {
|
||||||
if let Some(ref current) = attr.value_str() {
|
let comment = comment.to_string();
|
||||||
let current = current.to_string();
|
let (comment, current_spans) = strip_doc_comment_decoration(&comment, attr.span);
|
||||||
let (current, current_spans) = strip_doc_comment_decoration(¤t, attr.span);
|
spans.extend_from_slice(¤t_spans);
|
||||||
spans.extend_from_slice(¤t_spans);
|
doc.push_str(&comment);
|
||||||
doc.push_str(¤t);
|
|
||||||
}
|
|
||||||
} else if attr.check_name(sym!(doc)) {
|
} else if attr.check_name(sym!(doc)) {
|
||||||
// ignore mix of sugared and non-sugared doc
|
// ignore mix of sugared and non-sugared doc
|
||||||
return true; // don't trigger the safety check
|
return true; // don't trigger the safety check
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
|
||||||
let ty = cx.tables.expr_ty(expr);
|
let ty = cx.tables.expr_ty(expr);
|
||||||
if let ty::Float(fty) = ty.kind;
|
if let ty::Float(fty) = ty.kind;
|
||||||
if let hir::ExprKind::Lit(ref lit) = expr.kind;
|
if let hir::ExprKind::Lit(ref lit) = expr.kind;
|
||||||
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
|
if let LitKind::Float(sym, _) = lit.node;
|
||||||
if let Some(sugg) = Self::check(sym, fty);
|
if let Some(sugg) = Self::check(sym, fty);
|
||||||
then {
|
then {
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
|
|
|
@ -430,6 +430,10 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
|
||||||
"clippy::unused_collect",
|
"clippy::unused_collect",
|
||||||
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint",
|
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint",
|
||||||
);
|
);
|
||||||
|
store.register_removed(
|
||||||
|
"clippy::into_iter_on_array",
|
||||||
|
"this lint has been uplifted to rustc and is now called `array_into_iter`",
|
||||||
|
);
|
||||||
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
|
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
|
||||||
|
|
||||||
// begin register lints, do not remove this comment, it’s used in `update_lints`
|
// begin register lints, do not remove this comment, it’s used in `update_lints`
|
||||||
|
@ -584,7 +588,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
|
||||||
&methods::FLAT_MAP_IDENTITY,
|
&methods::FLAT_MAP_IDENTITY,
|
||||||
&methods::GET_UNWRAP,
|
&methods::GET_UNWRAP,
|
||||||
&methods::INEFFICIENT_TO_STRING,
|
&methods::INEFFICIENT_TO_STRING,
|
||||||
&methods::INTO_ITER_ON_ARRAY,
|
|
||||||
&methods::INTO_ITER_ON_REF,
|
&methods::INTO_ITER_ON_REF,
|
||||||
&methods::ITER_CLONED_COLLECT,
|
&methods::ITER_CLONED_COLLECT,
|
||||||
&methods::ITER_NTH,
|
&methods::ITER_NTH,
|
||||||
|
@ -1142,7 +1145,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
|
||||||
LintId::of(&methods::FILTER_NEXT),
|
LintId::of(&methods::FILTER_NEXT),
|
||||||
LintId::of(&methods::FLAT_MAP_IDENTITY),
|
LintId::of(&methods::FLAT_MAP_IDENTITY),
|
||||||
LintId::of(&methods::INEFFICIENT_TO_STRING),
|
LintId::of(&methods::INEFFICIENT_TO_STRING),
|
||||||
LintId::of(&methods::INTO_ITER_ON_ARRAY),
|
|
||||||
LintId::of(&methods::INTO_ITER_ON_REF),
|
LintId::of(&methods::INTO_ITER_ON_REF),
|
||||||
LintId::of(&methods::ITER_CLONED_COLLECT),
|
LintId::of(&methods::ITER_CLONED_COLLECT),
|
||||||
LintId::of(&methods::ITER_NTH),
|
LintId::of(&methods::ITER_NTH),
|
||||||
|
@ -1481,7 +1483,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
|
||||||
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
|
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
|
||||||
LintId::of(&mem_replace::MEM_REPLACE_WITH_UNINIT),
|
LintId::of(&mem_replace::MEM_REPLACE_WITH_UNINIT),
|
||||||
LintId::of(&methods::CLONE_DOUBLE_REF),
|
LintId::of(&methods::CLONE_DOUBLE_REF),
|
||||||
LintId::of(&methods::INTO_ITER_ON_ARRAY),
|
|
||||||
LintId::of(&methods::TEMPORARY_CSTRING_AS_PTR),
|
LintId::of(&methods::TEMPORARY_CSTRING_AS_PTR),
|
||||||
LintId::of(&methods::UNINIT_ASSUMED_INIT),
|
LintId::of(&methods::UNINIT_ASSUMED_INIT),
|
||||||
LintId::of(&minmax::MIN_MAX),
|
LintId::of(&minmax::MIN_MAX),
|
||||||
|
|
|
@ -373,7 +373,7 @@ impl LiteralDigitGrouping {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => {
|
LitKind::Float(..) => {
|
||||||
// Lint floating-point literals.
|
// Lint floating-point literals.
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let Some(src) = snippet_opt(cx, lit.span);
|
if let Some(src) = snippet_opt(cx, lit.span);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use rustc::hir::{Crate, Expr, ExprKind, QPath};
|
use rustc::hir::{Crate, Expr, ExprKind, QPath};
|
||||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||||
use rustc::{declare_tool_lint, impl_lint_pass};
|
use rustc::{declare_tool_lint, impl_lint_pass};
|
||||||
|
use syntax::ast::AttrKind;
|
||||||
use syntax::symbol::sym;
|
use syntax::symbol::sym;
|
||||||
|
|
||||||
use crate::utils::{is_entrypoint_fn, snippet, span_help_and_lint};
|
use crate::utils::{is_entrypoint_fn, snippet, span_help_and_lint};
|
||||||
|
@ -34,7 +35,13 @@ impl_lint_pass!(MainRecursion => [MAIN_RECURSION]);
|
||||||
|
|
||||||
impl LateLintPass<'_, '_> for MainRecursion {
|
impl LateLintPass<'_, '_> for MainRecursion {
|
||||||
fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) {
|
fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) {
|
||||||
self.has_no_std_attr = krate.attrs.iter().any(|attr| attr.path == sym::no_std);
|
self.has_no_std_attr = krate.attrs.iter().any(|attr| {
|
||||||
|
if let AttrKind::Normal(ref attr) = attr.kind {
|
||||||
|
attr.path == sym::no_std
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_expr_post(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) {
|
fn check_expr_post(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) {
|
||||||
|
|
|
@ -968,34 +968,6 @@ declare_clippy_lint! {
|
||||||
"using `filter_map` when a more succinct alternative exists"
|
"using `filter_map` when a more succinct alternative exists"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_clippy_lint! {
|
|
||||||
/// **What it does:** Checks for `into_iter` calls on types which should be replaced by `iter` or
|
|
||||||
/// `iter_mut`.
|
|
||||||
///
|
|
||||||
/// **Why is this bad?** Arrays and `PathBuf` do not yet have an `into_iter` method which move out
|
|
||||||
/// their content into an iterator. Auto-referencing resolves the `into_iter` call to its reference
|
|
||||||
/// instead, like `<&[T; N] as IntoIterator>::into_iter`, which just iterates over item references
|
|
||||||
/// like calling `iter` would. Furthermore, when the standard library actually
|
|
||||||
/// [implements the `into_iter` method](https://github.com/rust-lang/rust/issues/25725) which moves
|
|
||||||
/// the content out of the array, the original use of `into_iter` got inferred with the wrong type
|
|
||||||
/// and the code will be broken.
|
|
||||||
///
|
|
||||||
/// **Known problems:** None
|
|
||||||
///
|
|
||||||
/// **Example:**
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// let _ = [1, 2, 3].into_iter().map(|x| *x).collect::<Vec<u32>>();
|
|
||||||
/// ```
|
|
||||||
/// Could be written as:
|
|
||||||
/// ```rust
|
|
||||||
/// let _ = [1, 2, 3].iter().map(|x| *x).collect::<Vec<u32>>();
|
|
||||||
/// ```
|
|
||||||
pub INTO_ITER_ON_ARRAY,
|
|
||||||
correctness,
|
|
||||||
"using `.into_iter()` on an array"
|
|
||||||
}
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Checks for `into_iter` calls on references which should be replaced by `iter`
|
/// **What it does:** Checks for `into_iter` calls on references which should be replaced by `iter`
|
||||||
/// or `iter_mut`.
|
/// or `iter_mut`.
|
||||||
|
@ -1133,7 +1105,6 @@ declare_lint_pass!(Methods => [
|
||||||
USELESS_ASREF,
|
USELESS_ASREF,
|
||||||
UNNECESSARY_FOLD,
|
UNNECESSARY_FOLD,
|
||||||
UNNECESSARY_FILTER_MAP,
|
UNNECESSARY_FILTER_MAP,
|
||||||
INTO_ITER_ON_ARRAY,
|
|
||||||
INTO_ITER_ON_REF,
|
INTO_ITER_ON_REF,
|
||||||
SUSPICIOUS_MAP,
|
SUSPICIOUS_MAP,
|
||||||
UNINIT_ASSUMED_INIT,
|
UNINIT_ASSUMED_INIT,
|
||||||
|
@ -2786,16 +2757,8 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_has_iter_method(
|
fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: Ty<'_>) -> Option<(&'static str, &'static str)> {
|
||||||
cx: &LateContext<'_, '_>,
|
|
||||||
self_ref_ty: Ty<'_>,
|
|
||||||
) -> Option<(&'static Lint, &'static str, &'static str)> {
|
|
||||||
has_iter_method(cx, self_ref_ty).map(|ty_name| {
|
has_iter_method(cx, self_ref_ty).map(|ty_name| {
|
||||||
let lint = if ty_name == "array" || ty_name == "PathBuf" {
|
|
||||||
INTO_ITER_ON_ARRAY
|
|
||||||
} else {
|
|
||||||
INTO_ITER_ON_REF
|
|
||||||
};
|
|
||||||
let mutbl = match self_ref_ty.kind {
|
let mutbl = match self_ref_ty.kind {
|
||||||
ty::Ref(_, _, mutbl) => mutbl,
|
ty::Ref(_, _, mutbl) => mutbl,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -2804,7 +2767,7 @@ fn ty_has_iter_method(
|
||||||
hir::MutImmutable => "iter",
|
hir::MutImmutable => "iter",
|
||||||
hir::MutMutable => "iter_mut",
|
hir::MutMutable => "iter_mut",
|
||||||
};
|
};
|
||||||
(lint, ty_name, method_name)
|
(ty_name, method_name)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2812,10 +2775,10 @@ fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_
|
||||||
if !match_trait_method(cx, expr, &paths::INTO_ITERATOR) {
|
if !match_trait_method(cx, expr, &paths::INTO_ITERATOR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some((lint, kind, method_name)) = ty_has_iter_method(cx, self_ref_ty) {
|
if let Some((kind, method_name)) = ty_has_iter_method(cx, self_ref_ty) {
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
lint,
|
INTO_ITER_ON_REF,
|
||||||
method_span,
|
method_span,
|
||||||
&format!(
|
&format!(
|
||||||
"this .into_iter() call is equivalent to .{}() and will not move the {}",
|
"this .into_iter() call is equivalent to .{}() and will not move the {}",
|
||||||
|
|
|
@ -482,8 +482,8 @@ impl MiscEarlyLints {
|
||||||
|
|
||||||
if let LitKind::Int(value, lit_int_type) = lit.kind {
|
if let LitKind::Int(value, lit_int_type) = lit.kind {
|
||||||
let suffix = match lit_int_type {
|
let suffix = match lit_int_type {
|
||||||
LitIntType::Signed(ty) => ty.ty_to_string(),
|
LitIntType::Signed(ty) => ty.name_str(),
|
||||||
LitIntType::Unsigned(ty) => ty.ty_to_string(),
|
LitIntType::Unsigned(ty) => ty.name_str(),
|
||||||
LitIntType::Unsuffixed => "",
|
LitIntType::Unsuffixed => "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -543,8 +543,8 @@ impl MiscEarlyLints {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if let LitKind::Float(_, float_ty) = lit.kind {
|
} else if let LitKind::Float(_, LitFloatType::Suffixed(float_ty)) = lit.kind {
|
||||||
let suffix = float_ty.ty_to_string();
|
let suffix = float_ty.name_str();
|
||||||
let maybe_last_sep_idx = lit_snip.len() - suffix.len() - 1;
|
let maybe_last_sep_idx = lit_snip.len() - suffix.len() - 1;
|
||||||
if lit_snip.as_bytes()[maybe_last_sep_idx] != b'_' {
|
if lit_snip.as_bytes()[maybe_last_sep_idx] != b'_' {
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl EarlyLintPass for Precedence {
|
||||||
if let Some(slf) = args.first() {
|
if let Some(slf) = args.first() {
|
||||||
if let ExprKind::Lit(ref lit) = slf.kind {
|
if let ExprKind::Lit(ref lit) = slf.kind {
|
||||||
match lit.kind {
|
match lit.kind {
|
||||||
LitKind::Int(..) | LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => {
|
LitKind::Int(..) | LitKind::Float(..) => {
|
||||||
let mut applicability = Applicability::MachineApplicable;
|
let mut applicability = Applicability::MachineApplicable;
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
|
|
|
@ -390,7 +390,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
||||||
|db| {
|
|db| {
|
||||||
let arg = sugg::Sugg::hir(cx, &args[0], "..");
|
let arg = sugg::Sugg::hir(cx, &args[0], "..");
|
||||||
let arg = if let ty::Int(_) = from_ty.kind {
|
let arg = if let ty::Int(_) = from_ty.kind {
|
||||||
arg.as_ty(ast::UintTy::U32)
|
arg.as_ty(ast::UintTy::U32.name_str())
|
||||||
} else {
|
} else {
|
||||||
arg
|
arg
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ use rustc::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_typeck::hir_ty_to_ty;
|
use rustc_typeck::hir_ty_to_ty;
|
||||||
use syntax::ast::{FloatTy, IntTy, LitIntType, LitKind, UintTy};
|
use syntax::ast::{FloatTy, IntTy, LitFloatType, LitIntType, LitKind, UintTy};
|
||||||
use syntax::errors::DiagnosticBuilder;
|
use syntax::errors::DiagnosticBuilder;
|
||||||
use syntax::source_map::Span;
|
use syntax::source_map::Span;
|
||||||
use syntax::symbol::{sym, Symbol};
|
use syntax::symbol::{sym, Symbol};
|
||||||
|
@ -1186,7 +1186,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match lit.node {
|
match lit.node {
|
||||||
LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::FloatUnsuffixed(_) => {},
|
LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed) => {},
|
||||||
_ => {
|
_ => {
|
||||||
if cast_from.kind == cast_to.kind && !in_external_macro(cx.sess(), expr.span) {
|
if cast_from.kind == cast_to.kind && !in_external_macro(cx.sess(), expr.span) {
|
||||||
span_lint(
|
span_lint(
|
||||||
|
|
|
@ -57,6 +57,11 @@ pub fn get_attr<'a>(
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
) -> impl Iterator<Item = &'a ast::Attribute> {
|
) -> impl Iterator<Item = &'a ast::Attribute> {
|
||||||
attrs.iter().filter(move |attr| {
|
attrs.iter().filter(move |attr| {
|
||||||
|
let attr = if let ast::AttrKind::Normal(ref attr) = attr.kind {
|
||||||
|
attr
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
let attr_segments = &attr.path.segments;
|
let attr_segments = &attr.path.segments;
|
||||||
if attr_segments.len() == 2 && attr_segments[0].ident.to_string() == "clippy" {
|
if attr_segments.len() == 2 && attr_segments[0].ident.to_string() == "clippy" {
|
||||||
if let Some(deprecation_status) =
|
if let Some(deprecation_status) =
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::{declare_lint_pass, declare_tool_lint};
|
use rustc::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use syntax::ast::{Attribute, LitKind};
|
use syntax::ast::{Attribute, LitFloatType, LitKind};
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// **What it does:** Generates clippy code that detects the offending pattern
|
/// **What it does:** Generates clippy code that detects the offending pattern
|
||||||
|
@ -288,10 +288,14 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
||||||
LitKind::Byte(b) => println!(" if let LitKind::Byte({}) = {}.node;", b, lit_pat),
|
LitKind::Byte(b) => println!(" if let LitKind::Byte({}) = {}.node;", b, lit_pat),
|
||||||
// FIXME: also check int type
|
// FIXME: also check int type
|
||||||
LitKind::Int(i, _) => println!(" if let LitKind::Int({}, _) = {}.node;", i, lit_pat),
|
LitKind::Int(i, _) => println!(" if let LitKind::Int({}, _) = {}.node;", i, lit_pat),
|
||||||
LitKind::Float(..) => println!(" if let LitKind::Float(..) = {}.node;", lit_pat),
|
LitKind::Float(_, LitFloatType::Suffixed(_)) => println!(
|
||||||
LitKind::FloatUnsuffixed(_) => {
|
" if let LitKind::Float(_, LitFloatType::Suffixed(_)) = {}.node;",
|
||||||
println!(" if let LitKind::FloatUnsuffixed(_) = {}.node;", lit_pat)
|
lit_pat
|
||||||
},
|
),
|
||||||
|
LitKind::Float(_, LitFloatType::Unsuffixed) => println!(
|
||||||
|
" if let LitKind::Float(_, LitFloatType::Unsuffixed) = {}.node;",
|
||||||
|
lit_pat
|
||||||
|
),
|
||||||
LitKind::ByteStr(ref vec) => {
|
LitKind::ByteStr(ref vec) => {
|
||||||
let vec_pat = self.next("vec");
|
let vec_pat = self.next("vec");
|
||||||
println!(" if let LitKind::ByteStr(ref {}) = {}.node;", vec_pat, lit_pat);
|
println!(" if let LitKind::ByteStr(ref {}) = {}.node;", vec_pat, lit_pat);
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub use lint::Lint;
|
||||||
pub use lint::LINT_LEVELS;
|
pub use lint::LINT_LEVELS;
|
||||||
|
|
||||||
// begin lint list, do not remove this comment, it’s used in `update_lints`
|
// begin lint list, do not remove this comment, it’s used in `update_lints`
|
||||||
pub const ALL_LINTS: [Lint; 332] = [
|
pub const ALL_LINTS: [Lint; 331] = [
|
||||||
Lint {
|
Lint {
|
||||||
name: "absurd_extreme_comparisons",
|
name: "absurd_extreme_comparisons",
|
||||||
group: "correctness",
|
group: "correctness",
|
||||||
|
@ -812,13 +812,6 @@ pub const ALL_LINTS: [Lint; 332] = [
|
||||||
deprecation: None,
|
deprecation: None,
|
||||||
module: "integer_division",
|
module: "integer_division",
|
||||||
},
|
},
|
||||||
Lint {
|
|
||||||
name: "into_iter_on_array",
|
|
||||||
group: "correctness",
|
|
||||||
desc: "using `.into_iter()` on an array",
|
|
||||||
deprecation: None,
|
|
||||||
module: "methods",
|
|
||||||
},
|
|
||||||
Lint {
|
Lint {
|
||||||
name: "into_iter_on_ref",
|
name: "into_iter_on_ref",
|
||||||
group: "style",
|
group: "style",
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
#[warn(clippy::misaligned_transmute)]
|
#[warn(clippy::misaligned_transmute)]
|
||||||
#[warn(clippy::unused_collect)]
|
#[warn(clippy::unused_collect)]
|
||||||
#[warn(clippy::invalid_ref)]
|
#[warn(clippy::invalid_ref)]
|
||||||
|
#[warn(clippy::into_iter_on_array)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -42,11 +42,17 @@ error: lint `clippy::invalid_ref` has been removed: `superseded by rustc lint `i
|
||||||
LL | #[warn(clippy::invalid_ref)]
|
LL | #[warn(clippy::invalid_ref)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: lint `clippy::into_iter_on_array` has been removed: `this lint has been uplifted to rustc and is now called `array_into_iter``
|
||||||
|
--> $DIR/deprecated.rs:8:8
|
||||||
|
|
|
||||||
|
LL | #[warn(clippy::into_iter_on_array)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
|
error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
|
||||||
--> $DIR/deprecated.rs:1:8
|
--> $DIR/deprecated.rs:1:8
|
||||||
|
|
|
|
||||||
LL | #[warn(clippy::str_to_string)]
|
LL | #[warn(clippy::str_to_string)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 9 previous errors
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Unrelated {
|
||||||
clippy::cognitive_complexity,
|
clippy::cognitive_complexity,
|
||||||
clippy::similar_names
|
clippy::similar_names
|
||||||
)]
|
)]
|
||||||
#[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)]
|
#[allow(clippy::many_single_char_names, unused_variables)]
|
||||||
fn main() {
|
fn main() {
|
||||||
const MAX_LEN: usize = 42;
|
const MAX_LEN: usize = 42;
|
||||||
let mut vec = vec![1, 2, 3, 4];
|
let mut vec = vec![1, 2, 3, 4];
|
||||||
|
@ -102,9 +102,6 @@ fn main() {
|
||||||
let out_vec = vec![1, 2, 3];
|
let out_vec = vec![1, 2, 3];
|
||||||
for _v in out_vec {}
|
for _v in out_vec {}
|
||||||
|
|
||||||
let array = [1, 2, 3];
|
|
||||||
for _v in &array {}
|
|
||||||
|
|
||||||
for _v in &vec {} // these are fine
|
for _v in &vec {} // these are fine
|
||||||
for _v in &mut vec {} // these are fine
|
for _v in &mut vec {} // these are fine
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Unrelated {
|
||||||
clippy::cognitive_complexity,
|
clippy::cognitive_complexity,
|
||||||
clippy::similar_names
|
clippy::similar_names
|
||||||
)]
|
)]
|
||||||
#[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)]
|
#[allow(clippy::many_single_char_names, unused_variables)]
|
||||||
fn main() {
|
fn main() {
|
||||||
const MAX_LEN: usize = 42;
|
const MAX_LEN: usize = 42;
|
||||||
let mut vec = vec![1, 2, 3, 4];
|
let mut vec = vec![1, 2, 3, 4];
|
||||||
|
@ -102,9 +102,6 @@ fn main() {
|
||||||
let out_vec = vec![1, 2, 3];
|
let out_vec = vec![1, 2, 3];
|
||||||
for _v in out_vec.into_iter() {}
|
for _v in out_vec.into_iter() {}
|
||||||
|
|
||||||
let array = [1, 2, 3];
|
|
||||||
for _v in array.into_iter() {}
|
|
||||||
|
|
||||||
for _v in &vec {} // these are fine
|
for _v in &vec {} // these are fine
|
||||||
for _v in &mut vec {} // these are fine
|
for _v in &mut vec {} // these are fine
|
||||||
|
|
||||||
|
|
|
@ -77,64 +77,58 @@ LL | for _v in out_vec.into_iter() {}
|
||||||
= note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings`
|
= note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:106:15
|
--> $DIR/for_loop_fixable.rs:108:15
|
||||||
|
|
|
||||||
LL | for _v in array.into_iter() {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array`
|
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
|
||||||
--> $DIR/for_loop_fixable.rs:111:15
|
|
||||||
|
|
|
|
||||||
LL | for _v in [1, 2, 3].iter() {}
|
LL | for _v in [1, 2, 3].iter() {}
|
||||||
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
|
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:115:15
|
--> $DIR/for_loop_fixable.rs:112:15
|
||||||
|
|
|
|
||||||
LL | for _v in [0; 32].iter() {}
|
LL | for _v in [0; 32].iter() {}
|
||||||
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
|
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:120:15
|
--> $DIR/for_loop_fixable.rs:117:15
|
||||||
|
|
|
|
||||||
LL | for _v in ll.iter() {}
|
LL | for _v in ll.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&ll`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&ll`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:123:15
|
--> $DIR/for_loop_fixable.rs:120:15
|
||||||
|
|
|
|
||||||
LL | for _v in vd.iter() {}
|
LL | for _v in vd.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:126:15
|
--> $DIR/for_loop_fixable.rs:123:15
|
||||||
|
|
|
|
||||||
LL | for _v in bh.iter() {}
|
LL | for _v in bh.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bh`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&bh`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:129:15
|
--> $DIR/for_loop_fixable.rs:126:15
|
||||||
|
|
|
|
||||||
LL | for _v in hm.iter() {}
|
LL | for _v in hm.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:132:15
|
--> $DIR/for_loop_fixable.rs:129:15
|
||||||
|
|
|
|
||||||
LL | for _v in bt.iter() {}
|
LL | for _v in bt.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:135:15
|
--> $DIR/for_loop_fixable.rs:132:15
|
||||||
|
|
|
|
||||||
LL | for _v in hs.iter() {}
|
LL | for _v in hs.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
|
||||||
|
|
||||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||||
--> $DIR/for_loop_fixable.rs:138:15
|
--> $DIR/for_loop_fixable.rs:135:15
|
||||||
|
|
|
|
||||||
LL | for _v in bs.iter() {}
|
LL | for _v in bs.iter() {}
|
||||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`
|
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`
|
||||||
|
|
||||||
error: aborting due to 18 previous errors
|
error: aborting due to 17 previous errors
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
unused,
|
unused,
|
||||||
dead_code
|
dead_code
|
||||||
)]
|
)]
|
||||||
#[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)]
|
#[allow(clippy::many_single_char_names, unused_variables)]
|
||||||
fn main() {
|
fn main() {
|
||||||
for i in 5..5 {
|
for i in 5..5 {
|
||||||
println!("{}", i);
|
println!("{}", i);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
#![allow(clippy::useless_vec)]
|
#![allow(clippy::useless_vec)]
|
||||||
#![warn(clippy::into_iter_on_ref)]
|
#![warn(clippy::into_iter_on_ref)]
|
||||||
#![deny(clippy::into_iter_on_array)]
|
|
||||||
|
|
||||||
struct X;
|
struct X;
|
||||||
use std::collections::*;
|
use std::collections::*;
|
||||||
|
@ -10,9 +9,7 @@ fn main() {
|
||||||
for _ in &[1, 2, 3] {}
|
for _ in &[1, 2, 3] {}
|
||||||
for _ in vec![X, X] {}
|
for _ in vec![X, X] {}
|
||||||
for _ in &vec![X, X] {}
|
for _ in &vec![X, X] {}
|
||||||
for _ in [1, 2, 3].iter() {} //~ ERROR equivalent to .iter()
|
|
||||||
|
|
||||||
let _ = [1, 2, 3].iter(); //~ ERROR equivalent to .iter()
|
|
||||||
let _ = vec![1, 2, 3].into_iter();
|
let _ = vec![1, 2, 3].into_iter();
|
||||||
let _ = (&vec![1, 2, 3]).iter(); //~ WARN equivalent to .iter()
|
let _ = (&vec![1, 2, 3]).iter(); //~ WARN equivalent to .iter()
|
||||||
let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ WARN equivalent to .iter()
|
let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ WARN equivalent to .iter()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
#![allow(clippy::useless_vec)]
|
#![allow(clippy::useless_vec)]
|
||||||
#![warn(clippy::into_iter_on_ref)]
|
#![warn(clippy::into_iter_on_ref)]
|
||||||
#![deny(clippy::into_iter_on_array)]
|
|
||||||
|
|
||||||
struct X;
|
struct X;
|
||||||
use std::collections::*;
|
use std::collections::*;
|
||||||
|
@ -10,9 +9,7 @@ fn main() {
|
||||||
for _ in &[1, 2, 3] {}
|
for _ in &[1, 2, 3] {}
|
||||||
for _ in vec![X, X] {}
|
for _ in vec![X, X] {}
|
||||||
for _ in &vec![X, X] {}
|
for _ in &vec![X, X] {}
|
||||||
for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter()
|
|
||||||
|
|
||||||
let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter()
|
|
||||||
let _ = vec![1, 2, 3].into_iter();
|
let _ = vec![1, 2, 3].into_iter();
|
||||||
let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
||||||
let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
|
let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
|
||||||
|
|
|
@ -1,23 +1,5 @@
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
|
||||||
--> $DIR/into_iter_on_ref.rs:13:24
|
|
||||||
|
|
|
||||||
LL | for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter()
|
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/into_iter_on_ref.rs:4:9
|
|
||||||
|
|
|
||||||
LL | #![deny(clippy::into_iter_on_array)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
|
||||||
--> $DIR/into_iter_on_ref.rs:15:23
|
|
||||||
|
|
|
||||||
LL | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter()
|
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the Vec
|
error: this .into_iter() call is equivalent to .iter() and will not move the Vec
|
||||||
--> $DIR/into_iter_on_ref.rs:17:30
|
--> $DIR/into_iter_on_ref.rs:14:30
|
||||||
|
|
|
|
||||||
LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
@ -25,154 +7,154 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
||||||
= note: `-D clippy::into-iter-on-ref` implied by `-D warnings`
|
= note: `-D clippy::into-iter-on-ref` implied by `-D warnings`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
||||||
--> $DIR/into_iter_on_ref.rs:18:46
|
--> $DIR/into_iter_on_ref.rs:15:46
|
||||||
|
|
|
|
||||||
LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
||||||
--> $DIR/into_iter_on_ref.rs:19:41
|
--> $DIR/into_iter_on_ref.rs:16:41
|
||||||
|
|
|
|
||||||
LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
||||||
--> $DIR/into_iter_on_ref.rs:20:44
|
--> $DIR/into_iter_on_ref.rs:17:44
|
||||||
|
|
|
|
||||||
LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
||||||
--> $DIR/into_iter_on_ref.rs:22:32
|
--> $DIR/into_iter_on_ref.rs:19:32
|
||||||
|
|
|
|
||||||
LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
|
LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
||||||
--> $DIR/into_iter_on_ref.rs:23:36
|
--> $DIR/into_iter_on_ref.rs:20:36
|
||||||
|
|
|
|
||||||
LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
|
LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the array
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the array
|
||||||
--> $DIR/into_iter_on_ref.rs:24:40
|
--> $DIR/into_iter_on_ref.rs:21:40
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut()
|
LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the Option
|
error: this .into_iter() call is equivalent to .iter() and will not move the Option
|
||||||
--> $DIR/into_iter_on_ref.rs:26:24
|
--> $DIR/into_iter_on_ref.rs:23:24
|
||||||
|
|
|
|
||||||
LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Option
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Option
|
||||||
--> $DIR/into_iter_on_ref.rs:27:28
|
--> $DIR/into_iter_on_ref.rs:24:28
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the Result
|
error: this .into_iter() call is equivalent to .iter() and will not move the Result
|
||||||
--> $DIR/into_iter_on_ref.rs:28:32
|
--> $DIR/into_iter_on_ref.rs:25:32
|
||||||
|
|
|
|
||||||
LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Result
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Result
|
||||||
--> $DIR/into_iter_on_ref.rs:29:37
|
--> $DIR/into_iter_on_ref.rs:26:37
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the Vec
|
error: this .into_iter() call is equivalent to .iter() and will not move the Vec
|
||||||
--> $DIR/into_iter_on_ref.rs:30:34
|
--> $DIR/into_iter_on_ref.rs:27:34
|
||||||
|
|
|
|
||||||
LL | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Vec
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Vec
|
||||||
--> $DIR/into_iter_on_ref.rs:31:38
|
--> $DIR/into_iter_on_ref.rs:28:38
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the BTreeMap
|
error: this .into_iter() call is equivalent to .iter() and will not move the BTreeMap
|
||||||
--> $DIR/into_iter_on_ref.rs:32:44
|
--> $DIR/into_iter_on_ref.rs:29:44
|
||||||
|
|
|
|
||||||
LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the BTreeMap
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the BTreeMap
|
||||||
--> $DIR/into_iter_on_ref.rs:33:48
|
--> $DIR/into_iter_on_ref.rs:30:48
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the VecDeque
|
error: this .into_iter() call is equivalent to .iter() and will not move the VecDeque
|
||||||
--> $DIR/into_iter_on_ref.rs:34:39
|
--> $DIR/into_iter_on_ref.rs:31:39
|
||||||
|
|
|
|
||||||
LL | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the VecDeque
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the VecDeque
|
||||||
--> $DIR/into_iter_on_ref.rs:35:43
|
--> $DIR/into_iter_on_ref.rs:32:43
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the LinkedList
|
error: this .into_iter() call is equivalent to .iter() and will not move the LinkedList
|
||||||
--> $DIR/into_iter_on_ref.rs:36:41
|
--> $DIR/into_iter_on_ref.rs:33:41
|
||||||
|
|
|
|
||||||
LL | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the LinkedList
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the LinkedList
|
||||||
--> $DIR/into_iter_on_ref.rs:37:45
|
--> $DIR/into_iter_on_ref.rs:34:45
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the HashMap
|
error: this .into_iter() call is equivalent to .iter() and will not move the HashMap
|
||||||
--> $DIR/into_iter_on_ref.rs:38:43
|
--> $DIR/into_iter_on_ref.rs:35:43
|
||||||
|
|
|
|
||||||
LL | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the HashMap
|
error: this .into_iter() call is equivalent to .iter_mut() and will not move the HashMap
|
||||||
--> $DIR/into_iter_on_ref.rs:39:47
|
--> $DIR/into_iter_on_ref.rs:36:47
|
||||||
|
|
|
|
||||||
LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the BTreeSet
|
error: this .into_iter() call is equivalent to .iter() and will not move the BTreeSet
|
||||||
--> $DIR/into_iter_on_ref.rs:41:39
|
--> $DIR/into_iter_on_ref.rs:38:39
|
||||||
|
|
|
|
||||||
LL | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the BinaryHeap
|
error: this .into_iter() call is equivalent to .iter() and will not move the BinaryHeap
|
||||||
--> $DIR/into_iter_on_ref.rs:42:41
|
--> $DIR/into_iter_on_ref.rs:39:41
|
||||||
|
|
|
|
||||||
LL | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the HashSet
|
error: this .into_iter() call is equivalent to .iter() and will not move the HashSet
|
||||||
--> $DIR/into_iter_on_ref.rs:43:38
|
--> $DIR/into_iter_on_ref.rs:40:38
|
||||||
|
|
|
|
||||||
LL | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the Path
|
error: this .into_iter() call is equivalent to .iter() and will not move the Path
|
||||||
--> $DIR/into_iter_on_ref.rs:44:43
|
--> $DIR/into_iter_on_ref.rs:41:43
|
||||||
|
|
|
|
||||||
LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter()
|
LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: this .into_iter() call is equivalent to .iter() and will not move the PathBuf
|
error: this .into_iter() call is equivalent to .iter() and will not move the PathBuf
|
||||||
--> $DIR/into_iter_on_ref.rs:45:47
|
--> $DIR/into_iter_on_ref.rs:42:47
|
||||||
|
|
|
|
||||||
LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter()
|
LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter()
|
||||||
| ^^^^^^^^^ help: call directly: `iter`
|
| ^^^^^^^^^ help: call directly: `iter`
|
||||||
|
|
||||||
error: aborting due to 28 previous errors
|
error: aborting due to 26 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue