Auto merge of #6070 - matsujika:unnecessary_wrap, r=flip1995
Add new lint `unnecessary_wrap` Fixes #5969 changelog: New lint [`unnecessary_wraps`]
This commit is contained in:
commit
44d944586c
@ -2008,6 +2008,7 @@ Released 2018-09-13
|
||||
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
|
||||
[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
|
||||
[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
|
||||
[`unnecessary_wraps`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps
|
||||
[`unneeded_field_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
|
||||
[`unneeded_wildcard_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_wildcard_pattern
|
||||
[`unnested_or_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
|
||||
|
@ -323,6 +323,7 @@ mod unicode;
|
||||
mod unit_return_expecting_ord;
|
||||
mod unnamed_address;
|
||||
mod unnecessary_sort_by;
|
||||
mod unnecessary_wraps;
|
||||
mod unnested_or_patterns;
|
||||
mod unsafe_removed_from_name;
|
||||
mod unused_io_amount;
|
||||
@ -892,6 +893,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||
&unnamed_address::FN_ADDRESS_COMPARISONS,
|
||||
&unnamed_address::VTABLE_ADDRESS_COMPARISONS,
|
||||
&unnecessary_sort_by::UNNECESSARY_SORT_BY,
|
||||
&unnecessary_wraps::UNNECESSARY_WRAPS,
|
||||
&unnested_or_patterns::UNNESTED_OR_PATTERNS,
|
||||
&unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
|
||||
&unused_io_amount::UNUSED_IO_AMOUNT,
|
||||
@ -1064,6 +1066,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||
store.register_late_pass(|| box redundant_clone::RedundantClone);
|
||||
store.register_late_pass(|| box slow_vector_initialization::SlowVectorInit);
|
||||
store.register_late_pass(|| box unnecessary_sort_by::UnnecessarySortBy);
|
||||
store.register_late_pass(|| box unnecessary_wraps::UnnecessaryWraps);
|
||||
store.register_late_pass(|| box types::RefToMut);
|
||||
store.register_late_pass(|| box assertions_on_constants::AssertionsOnConstants);
|
||||
store.register_late_pass(|| box missing_const_for_fn::MissingConstForFn);
|
||||
@ -1571,6 +1574,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
|
||||
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
|
||||
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
|
||||
LintId::of(&unnecessary_wraps::UNNECESSARY_WRAPS),
|
||||
LintId::of(&unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME),
|
||||
LintId::of(&unused_io_amount::UNUSED_IO_AMOUNT),
|
||||
LintId::of(&unused_unit::UNUSED_UNIT),
|
||||
@ -1775,6 +1779,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||
LintId::of(&types::UNNECESSARY_CAST),
|
||||
LintId::of(&types::VEC_BOX),
|
||||
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
|
||||
LintId::of(&unnecessary_wraps::UNNECESSARY_WRAPS),
|
||||
LintId::of(&unwrap::UNNECESSARY_UNWRAP),
|
||||
LintId::of(&useless_conversion::USELESS_CONVERSION),
|
||||
LintId::of(&zero_div_zero::ZERO_DIVIDED_BY_ZERO),
|
||||
|
@ -1,14 +1,12 @@
|
||||
use super::{contains_return, BIND_INSTEAD_OF_MAP};
|
||||
use crate::utils::{
|
||||
in_macro, match_qpath, match_type, method_calls, multispan_sugg_with_applicability, paths, remove_blocks, snippet,
|
||||
snippet_with_macro_callsite, span_lint_and_sugg, span_lint_and_then,
|
||||
snippet_with_macro_callsite, span_lint_and_sugg, span_lint_and_then, visitors::find_all_ret_expressions,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(crate) struct OptionAndThenSome;
|
||||
@ -193,124 +191,3 @@ pub(crate) trait BindInsteadOfMap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// returns `true` if expr contains match expr desugared from try
|
||||
fn contains_try(expr: &hir::Expr<'_>) -> bool {
|
||||
struct TryFinder {
|
||||
found: bool,
|
||||
}
|
||||
|
||||
impl<'hir> intravisit::Visitor<'hir> for TryFinder {
|
||||
type Map = Map<'hir>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
|
||||
intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
|
||||
if self.found {
|
||||
return;
|
||||
}
|
||||
match expr.kind {
|
||||
hir::ExprKind::Match(_, _, hir::MatchSource::TryDesugar) => self.found = true,
|
||||
_ => intravisit::walk_expr(self, expr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = TryFinder { found: false };
|
||||
visitor.visit_expr(expr);
|
||||
visitor.found
|
||||
}
|
||||
|
||||
fn find_all_ret_expressions<'hir, F>(_cx: &LateContext<'_>, expr: &'hir hir::Expr<'hir>, callback: F) -> bool
|
||||
where
|
||||
F: FnMut(&'hir hir::Expr<'hir>) -> bool,
|
||||
{
|
||||
struct RetFinder<F> {
|
||||
in_stmt: bool,
|
||||
failed: bool,
|
||||
cb: F,
|
||||
}
|
||||
|
||||
struct WithStmtGuarg<'a, F> {
|
||||
val: &'a mut RetFinder<F>,
|
||||
prev_in_stmt: bool,
|
||||
}
|
||||
|
||||
impl<F> RetFinder<F> {
|
||||
fn inside_stmt(&mut self, in_stmt: bool) -> WithStmtGuarg<'_, F> {
|
||||
let prev_in_stmt = std::mem::replace(&mut self.in_stmt, in_stmt);
|
||||
WithStmtGuarg {
|
||||
val: self,
|
||||
prev_in_stmt,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> std::ops::Deref for WithStmtGuarg<'_, F> {
|
||||
type Target = RetFinder<F>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.val
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> std::ops::DerefMut for WithStmtGuarg<'_, F> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.val
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> Drop for WithStmtGuarg<'_, F> {
|
||||
fn drop(&mut self) {
|
||||
self.val.in_stmt = self.prev_in_stmt;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir, F: FnMut(&'hir hir::Expr<'hir>) -> bool> intravisit::Visitor<'hir> for RetFinder<F> {
|
||||
type Map = Map<'hir>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
|
||||
intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'hir hir::Stmt<'_>) {
|
||||
intravisit::walk_stmt(&mut *self.inside_stmt(true), stmt)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'hir hir::Expr<'_>) {
|
||||
if self.failed {
|
||||
return;
|
||||
}
|
||||
if self.in_stmt {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Ret(Some(expr)) => self.inside_stmt(false).visit_expr(expr),
|
||||
_ => intravisit::walk_expr(self, expr),
|
||||
}
|
||||
} else {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Match(cond, arms, _) => {
|
||||
self.inside_stmt(true).visit_expr(cond);
|
||||
for arm in arms {
|
||||
self.visit_expr(arm.body);
|
||||
}
|
||||
},
|
||||
hir::ExprKind::Block(..) => intravisit::walk_expr(self, expr),
|
||||
hir::ExprKind::Ret(Some(expr)) => self.visit_expr(expr),
|
||||
_ => self.failed |= !(self.cb)(expr),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
!contains_try(expr) && {
|
||||
let mut ret_finder = RetFinder {
|
||||
in_stmt: false,
|
||||
failed: false,
|
||||
cb: callback,
|
||||
};
|
||||
ret_finder.visit_expr(expr);
|
||||
!ret_finder.failed
|
||||
}
|
||||
}
|
||||
|
@ -320,11 +320,11 @@ fn find_stmt_assigns_to<'tcx>(
|
||||
|
||||
match (by_ref, &*rvalue) {
|
||||
(true, mir::Rvalue::Ref(_, _, place)) | (false, mir::Rvalue::Use(mir::Operand::Copy(place))) => {
|
||||
base_local_and_movability(cx, mir, *place)
|
||||
Some(base_local_and_movability(cx, mir, *place))
|
||||
},
|
||||
(false, mir::Rvalue::Ref(_, _, place)) => {
|
||||
if let [mir::ProjectionElem::Deref] = place.as_ref().projection {
|
||||
base_local_and_movability(cx, mir, *place)
|
||||
Some(base_local_and_movability(cx, mir, *place))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -341,7 +341,7 @@ fn base_local_and_movability<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
mir: &mir::Body<'tcx>,
|
||||
place: mir::Place<'tcx>,
|
||||
) -> Option<(mir::Local, CannotMoveOut)> {
|
||||
) -> (mir::Local, CannotMoveOut) {
|
||||
use rustc_middle::mir::PlaceRef;
|
||||
|
||||
// Dereference. You cannot move things out from a borrowed value.
|
||||
@ -362,7 +362,7 @@ fn base_local_and_movability<'tcx>(
|
||||
&& !is_copy(cx, mir::Place::ty_from(local, projection, &mir.local_decls, cx.tcx).ty);
|
||||
}
|
||||
|
||||
Some((local, deref || field || slice))
|
||||
(local, deref || field || slice)
|
||||
}
|
||||
|
||||
struct LocalUseVisitor {
|
||||
|
143
clippy_lints/src/unnecessary_wraps.rs
Normal file
143
clippy_lints/src/unnecessary_wraps.rs
Normal file
@ -0,0 +1,143 @@
|
||||
use crate::utils::{
|
||||
in_macro, is_type_diagnostic_item, match_qpath, paths, return_ty, snippet, span_lint_and_then,
|
||||
visitors::find_all_ret_expressions,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{Body, ExprKind, FnDecl, HirId, ItemKind, Node};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::Span;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for private functions that only return `Ok` or `Some`.
|
||||
///
|
||||
/// **Why is this bad?** It is not meaningful to wrap values when no `None` or `Err` is returned.
|
||||
///
|
||||
/// **Known problems:** Since this lint changes function type signature, you may need to
|
||||
/// adjust some code at callee side.
|
||||
///
|
||||
/// **Example:**
|
||||
///
|
||||
/// ```rust
|
||||
/// fn get_cool_number(a: bool, b: bool) -> Option<i32> {
|
||||
/// if a && b {
|
||||
/// return Some(50);
|
||||
/// }
|
||||
/// if a {
|
||||
/// Some(0)
|
||||
/// } else {
|
||||
/// Some(10)
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
/// Use instead:
|
||||
/// ```rust
|
||||
/// fn get_cool_number(a: bool, b: bool) -> i32 {
|
||||
/// if a && b {
|
||||
/// return 50;
|
||||
/// }
|
||||
/// if a {
|
||||
/// 0
|
||||
/// } else {
|
||||
/// 10
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub UNNECESSARY_WRAPS,
|
||||
complexity,
|
||||
"functions that only return `Ok` or `Some`"
|
||||
}
|
||||
|
||||
declare_lint_pass!(UnnecessaryWraps => [UNNECESSARY_WRAPS]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'tcx>,
|
||||
fn_kind: FnKind<'tcx>,
|
||||
fn_decl: &FnDecl<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
span: Span,
|
||||
hir_id: HirId,
|
||||
) {
|
||||
match fn_kind {
|
||||
FnKind::ItemFn(.., visibility, _) | FnKind::Method(.., Some(visibility), _) => {
|
||||
if visibility.node.is_pub() {
|
||||
return;
|
||||
}
|
||||
},
|
||||
FnKind::Closure(..) => return,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
|
||||
if matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), ..} | ItemKind::Trait(..)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let (return_type, path) = if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym!(option_type)) {
|
||||
("Option", &paths::OPTION_SOME)
|
||||
} else if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym!(result_type)) {
|
||||
("Result", &paths::RESULT_OK)
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut suggs = Vec::new();
|
||||
let can_sugg = find_all_ret_expressions(cx, &body.value, |ret_expr| {
|
||||
if_chain! {
|
||||
if !in_macro(ret_expr.span);
|
||||
if let ExprKind::Call(ref func, ref args) = ret_expr.kind;
|
||||
if let ExprKind::Path(ref qpath) = func.kind;
|
||||
if match_qpath(qpath, path);
|
||||
if args.len() == 1;
|
||||
then {
|
||||
suggs.push((ret_expr.span, snippet(cx, args[0].span.source_callsite(), "..").to_string()));
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if can_sugg && !suggs.is_empty() {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
UNNECESSARY_WRAPS,
|
||||
span,
|
||||
format!(
|
||||
"this function's return value is unnecessarily wrapped by `{}`",
|
||||
return_type
|
||||
)
|
||||
.as_str(),
|
||||
|diag| {
|
||||
let inner_ty = return_ty(cx, hir_id)
|
||||
.walk()
|
||||
.skip(1) // skip `std::option::Option` or `std::result::Result`
|
||||
.take(1) // take the first outermost inner type
|
||||
.filter_map(|inner| match inner.unpack() {
|
||||
GenericArgKind::Type(inner_ty) => Some(inner_ty.to_string()),
|
||||
_ => None,
|
||||
});
|
||||
inner_ty.for_each(|inner_ty| {
|
||||
diag.span_suggestion(
|
||||
fn_decl.output.span(),
|
||||
format!("remove `{}` from the return type...", return_type).as_str(),
|
||||
inner_ty,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
});
|
||||
diag.multipart_suggestion(
|
||||
"...and change the returning expressions",
|
||||
suggs,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ pub mod ptr;
|
||||
pub mod qualify_min_const_fn;
|
||||
pub mod sugg;
|
||||
pub mod usage;
|
||||
pub mod visitors;
|
||||
|
||||
pub use self::attrs::*;
|
||||
pub use self::diagnostics::*;
|
||||
|
125
clippy_lints/src/utils/visitors.rs
Normal file
125
clippy_lints/src/utils/visitors.rs
Normal file
@ -0,0 +1,125 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::map::Map;
|
||||
|
||||
/// returns `true` if expr contains match expr desugared from try
|
||||
fn contains_try(expr: &hir::Expr<'_>) -> bool {
|
||||
struct TryFinder {
|
||||
found: bool,
|
||||
}
|
||||
|
||||
impl<'hir> intravisit::Visitor<'hir> for TryFinder {
|
||||
type Map = Map<'hir>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
|
||||
intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
|
||||
if self.found {
|
||||
return;
|
||||
}
|
||||
match expr.kind {
|
||||
hir::ExprKind::Match(_, _, hir::MatchSource::TryDesugar) => self.found = true,
|
||||
_ => intravisit::walk_expr(self, expr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = TryFinder { found: false };
|
||||
visitor.visit_expr(expr);
|
||||
visitor.found
|
||||
}
|
||||
|
||||
pub fn find_all_ret_expressions<'hir, F>(_cx: &LateContext<'_>, expr: &'hir hir::Expr<'hir>, callback: F) -> bool
|
||||
where
|
||||
F: FnMut(&'hir hir::Expr<'hir>) -> bool,
|
||||
{
|
||||
struct RetFinder<F> {
|
||||
in_stmt: bool,
|
||||
failed: bool,
|
||||
cb: F,
|
||||
}
|
||||
|
||||
struct WithStmtGuarg<'a, F> {
|
||||
val: &'a mut RetFinder<F>,
|
||||
prev_in_stmt: bool,
|
||||
}
|
||||
|
||||
impl<F> RetFinder<F> {
|
||||
fn inside_stmt(&mut self, in_stmt: bool) -> WithStmtGuarg<'_, F> {
|
||||
let prev_in_stmt = std::mem::replace(&mut self.in_stmt, in_stmt);
|
||||
WithStmtGuarg {
|
||||
val: self,
|
||||
prev_in_stmt,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> std::ops::Deref for WithStmtGuarg<'_, F> {
|
||||
type Target = RetFinder<F>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.val
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> std::ops::DerefMut for WithStmtGuarg<'_, F> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.val
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> Drop for WithStmtGuarg<'_, F> {
|
||||
fn drop(&mut self) {
|
||||
self.val.in_stmt = self.prev_in_stmt;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir, F: FnMut(&'hir hir::Expr<'hir>) -> bool> intravisit::Visitor<'hir> for RetFinder<F> {
|
||||
type Map = Map<'hir>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
|
||||
intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'hir hir::Stmt<'_>) {
|
||||
intravisit::walk_stmt(&mut *self.inside_stmt(true), stmt)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'hir hir::Expr<'_>) {
|
||||
if self.failed {
|
||||
return;
|
||||
}
|
||||
if self.in_stmt {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Ret(Some(expr)) => self.inside_stmt(false).visit_expr(expr),
|
||||
_ => intravisit::walk_expr(self, expr),
|
||||
}
|
||||
} else {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Match(cond, arms, _) => {
|
||||
self.inside_stmt(true).visit_expr(cond);
|
||||
for arm in arms {
|
||||
self.visit_expr(arm.body);
|
||||
}
|
||||
},
|
||||
hir::ExprKind::Block(..) => intravisit::walk_expr(self, expr),
|
||||
hir::ExprKind::Ret(Some(expr)) => self.visit_expr(expr),
|
||||
_ => self.failed |= !(self.cb)(expr),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
!contains_try(expr) && {
|
||||
let mut ret_finder = RetFinder {
|
||||
in_stmt: false,
|
||||
failed: false,
|
||||
cb: callback,
|
||||
};
|
||||
ret_finder.visit_expr(expr);
|
||||
!ret_finder.failed
|
||||
}
|
||||
}
|
@ -2608,6 +2608,13 @@ vec![
|
||||
deprecation: None,
|
||||
module: "unwrap",
|
||||
},
|
||||
Lint {
|
||||
name: "unnecessary_wraps",
|
||||
group: "complexity",
|
||||
desc: "functions that only return `Ok` or `Some`",
|
||||
deprecation: None,
|
||||
module: "unnecessary_wraps",
|
||||
},
|
||||
Lint {
|
||||
name: "unneeded_field_pattern",
|
||||
group: "restriction",
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![warn(clippy::derive_ord_xor_partial_ord)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:20:10
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:21:10
|
||||
|
|
||||
LL | #[derive(Ord, PartialEq, Eq)]
|
||||
| ^^^
|
||||
|
|
||||
= note: `-D clippy::derive-ord-xor-partial-ord` implied by `-D warnings`
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:23:1
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:24:1
|
||||
|
|
||||
LL | / impl PartialOrd for DeriveOrd {
|
||||
LL | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
@ -17,13 +17,13 @@ LL | | }
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:29:10
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:30:10
|
||||
|
|
||||
LL | #[derive(Ord, PartialEq, Eq)]
|
||||
| ^^^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:32:1
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:33:1
|
||||
|
|
||||
LL | / impl PartialOrd<DeriveOrdWithExplicitTypeVariable> for DeriveOrdWithExplicitTypeVariable {
|
||||
LL | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
@ -34,7 +34,7 @@ LL | | }
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: you are implementing `Ord` explicitly but have derived `PartialOrd`
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:41:1
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:42:1
|
||||
|
|
||||
LL | / impl std::cmp::Ord for DerivePartialOrd {
|
||||
LL | | fn cmp(&self, other: &Self) -> Ordering {
|
||||
@ -44,14 +44,14 @@ LL | | }
|
||||
| |_^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:38:10
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:39:10
|
||||
|
|
||||
LL | #[derive(PartialOrd, PartialEq, Eq)]
|
||||
| ^^^^^^^^^^
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: you are implementing `Ord` explicitly but have derived `PartialOrd`
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:61:5
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:62:5
|
||||
|
|
||||
LL | / impl Ord for DerivePartialOrdInUseOrd {
|
||||
LL | | fn cmp(&self, other: &Self) -> Ordering {
|
||||
@ -61,7 +61,7 @@ LL | | }
|
||||
| |_____^
|
||||
|
|
||||
note: `PartialOrd` implemented here
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:58:14
|
||||
--> $DIR/derive_ord_xor_partial_ord.rs:59:14
|
||||
|
|
||||
LL | #[derive(PartialOrd, PartialEq, Eq)]
|
||||
| ^^^^^^^^^^
|
||||
|
@ -1,6 +1,7 @@
|
||||
// edition:2018
|
||||
#![warn(clippy::missing_errors_doc)]
|
||||
#![allow(clippy::result_unit_err)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use std::io;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:7:1
|
||||
--> $DIR/doc_errors.rs:8:1
|
||||
|
|
||||
LL | / pub fn pub_fn_missing_errors_header() -> Result<(), ()> {
|
||||
LL | | unimplemented!();
|
||||
@ -9,7 +9,7 @@ LL | | }
|
||||
= note: `-D clippy::missing-errors-doc` implied by `-D warnings`
|
||||
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:11:1
|
||||
--> $DIR/doc_errors.rs:12:1
|
||||
|
|
||||
LL | / pub async fn async_pub_fn_missing_errors_header() -> Result<(), ()> {
|
||||
LL | | unimplemented!();
|
||||
@ -17,7 +17,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:16:1
|
||||
--> $DIR/doc_errors.rs:17:1
|
||||
|
|
||||
LL | / pub fn pub_fn_returning_io_result() -> io::Result<()> {
|
||||
LL | | unimplemented!();
|
||||
@ -25,7 +25,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:21:1
|
||||
--> $DIR/doc_errors.rs:22:1
|
||||
|
|
||||
LL | / pub async fn async_pub_fn_returning_io_result() -> io::Result<()> {
|
||||
LL | | unimplemented!();
|
||||
@ -33,7 +33,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:51:5
|
||||
--> $DIR/doc_errors.rs:52:5
|
||||
|
|
||||
LL | / pub fn pub_method_missing_errors_header() -> Result<(), ()> {
|
||||
LL | | unimplemented!();
|
||||
@ -41,7 +41,7 @@ LL | | }
|
||||
| |_____^
|
||||
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:56:5
|
||||
--> $DIR/doc_errors.rs:57:5
|
||||
|
|
||||
LL | / pub async fn async_pub_method_missing_errors_header() -> Result<(), ()> {
|
||||
LL | | unimplemented!();
|
||||
@ -49,7 +49,7 @@ LL | | }
|
||||
| |_____^
|
||||
|
||||
error: docs for function returning `Result` missing `# Errors` section
|
||||
--> $DIR/doc_errors.rs:85:5
|
||||
--> $DIR/doc_errors.rs:86:5
|
||||
|
|
||||
LL | fn trait_method_missing_errors_header() -> Result<(), ()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,6 +1,7 @@
|
||||
#![warn(clippy::drop_ref)]
|
||||
#![allow(clippy::toplevel_ref_arg)]
|
||||
#![allow(clippy::map_err_ignore)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use std::mem::drop;
|
||||
|
||||
|
@ -1,108 +1,108 @@
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:10:5
|
||||
--> $DIR/drop_ref.rs:11:5
|
||||
|
|
||||
LL | drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::drop-ref` implied by `-D warnings`
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/drop_ref.rs:10:10
|
||||
--> $DIR/drop_ref.rs:11:10
|
||||
|
|
||||
LL | drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:13:5
|
||||
--> $DIR/drop_ref.rs:14:5
|
||||
|
|
||||
LL | drop(&owned1);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/drop_ref.rs:13:10
|
||||
--> $DIR/drop_ref.rs:14:10
|
||||
|
|
||||
LL | drop(&owned1);
|
||||
| ^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:14:5
|
||||
--> $DIR/drop_ref.rs:15:5
|
||||
|
|
||||
LL | drop(&&owned1);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&&SomeStruct`
|
||||
--> $DIR/drop_ref.rs:14:10
|
||||
--> $DIR/drop_ref.rs:15:10
|
||||
|
|
||||
LL | drop(&&owned1);
|
||||
| ^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:15:5
|
||||
--> $DIR/drop_ref.rs:16:5
|
||||
|
|
||||
LL | drop(&mut owned1);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&mut SomeStruct`
|
||||
--> $DIR/drop_ref.rs:15:10
|
||||
--> $DIR/drop_ref.rs:16:10
|
||||
|
|
||||
LL | drop(&mut owned1);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:19:5
|
||||
--> $DIR/drop_ref.rs:20:5
|
||||
|
|
||||
LL | drop(reference1);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/drop_ref.rs:19:10
|
||||
--> $DIR/drop_ref.rs:20:10
|
||||
|
|
||||
LL | drop(reference1);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:22:5
|
||||
--> $DIR/drop_ref.rs:23:5
|
||||
|
|
||||
LL | drop(reference2);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&mut SomeStruct`
|
||||
--> $DIR/drop_ref.rs:22:10
|
||||
--> $DIR/drop_ref.rs:23:10
|
||||
|
|
||||
LL | drop(reference2);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:25:5
|
||||
--> $DIR/drop_ref.rs:26:5
|
||||
|
|
||||
LL | drop(reference3);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/drop_ref.rs:25:10
|
||||
--> $DIR/drop_ref.rs:26:10
|
||||
|
|
||||
LL | drop(reference3);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:30:5
|
||||
--> $DIR/drop_ref.rs:31:5
|
||||
|
|
||||
LL | drop(&val);
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&T`
|
||||
--> $DIR/drop_ref.rs:30:10
|
||||
--> $DIR/drop_ref.rs:31:10
|
||||
|
|
||||
LL | drop(&val);
|
||||
| ^^^^
|
||||
|
||||
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
|
||||
--> $DIR/drop_ref.rs:38:5
|
||||
--> $DIR/drop_ref.rs:39:5
|
||||
|
|
||||
LL | std::mem::drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/drop_ref.rs:38:20
|
||||
--> $DIR/drop_ref.rs:39:20
|
||||
|
|
||||
LL | std::mem::drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
@ -1,5 +1,6 @@
|
||||
#![warn(clippy::forget_ref)]
|
||||
#![allow(clippy::toplevel_ref_arg)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use std::mem::forget;
|
||||
|
||||
|
@ -1,108 +1,108 @@
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:9:5
|
||||
--> $DIR/forget_ref.rs:10:5
|
||||
|
|
||||
LL | forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::forget-ref` implied by `-D warnings`
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/forget_ref.rs:9:12
|
||||
--> $DIR/forget_ref.rs:10:12
|
||||
|
|
||||
LL | forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:12:5
|
||||
--> $DIR/forget_ref.rs:13:5
|
||||
|
|
||||
LL | forget(&owned);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/forget_ref.rs:12:12
|
||||
--> $DIR/forget_ref.rs:13:12
|
||||
|
|
||||
LL | forget(&owned);
|
||||
| ^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:13:5
|
||||
--> $DIR/forget_ref.rs:14:5
|
||||
|
|
||||
LL | forget(&&owned);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&&SomeStruct`
|
||||
--> $DIR/forget_ref.rs:13:12
|
||||
--> $DIR/forget_ref.rs:14:12
|
||||
|
|
||||
LL | forget(&&owned);
|
||||
| ^^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:14:5
|
||||
--> $DIR/forget_ref.rs:15:5
|
||||
|
|
||||
LL | forget(&mut owned);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&mut SomeStruct`
|
||||
--> $DIR/forget_ref.rs:14:12
|
||||
--> $DIR/forget_ref.rs:15:12
|
||||
|
|
||||
LL | forget(&mut owned);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:18:5
|
||||
--> $DIR/forget_ref.rs:19:5
|
||||
|
|
||||
LL | forget(&*reference1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/forget_ref.rs:18:12
|
||||
--> $DIR/forget_ref.rs:19:12
|
||||
|
|
||||
LL | forget(&*reference1);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:21:5
|
||||
--> $DIR/forget_ref.rs:22:5
|
||||
|
|
||||
LL | forget(reference2);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&mut SomeStruct`
|
||||
--> $DIR/forget_ref.rs:21:12
|
||||
--> $DIR/forget_ref.rs:22:12
|
||||
|
|
||||
LL | forget(reference2);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:24:5
|
||||
--> $DIR/forget_ref.rs:25:5
|
||||
|
|
||||
LL | forget(reference3);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/forget_ref.rs:24:12
|
||||
--> $DIR/forget_ref.rs:25:12
|
||||
|
|
||||
LL | forget(reference3);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:29:5
|
||||
--> $DIR/forget_ref.rs:30:5
|
||||
|
|
||||
LL | forget(&val);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&T`
|
||||
--> $DIR/forget_ref.rs:29:12
|
||||
--> $DIR/forget_ref.rs:30:12
|
||||
|
|
||||
LL | forget(&val);
|
||||
| ^^^^
|
||||
|
||||
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
|
||||
--> $DIR/forget_ref.rs:37:5
|
||||
--> $DIR/forget_ref.rs:38:5
|
||||
|
|
||||
LL | std::mem::forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type `&SomeStruct`
|
||||
--> $DIR/forget_ref.rs:37:22
|
||||
--> $DIR/forget_ref.rs:38:22
|
||||
|
|
||||
LL | std::mem::forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![warn(clippy::let_underscore_must_use)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
// Debug implementations can fire this lint,
|
||||
// so we shouldn't lint external macros
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: non-binding let on a result of a `#[must_use]` function
|
||||
--> $DIR/let_underscore_must_use.rs:66:5
|
||||
--> $DIR/let_underscore_must_use.rs:67:5
|
||||
|
|
||||
LL | let _ = f();
|
||||
| ^^^^^^^^^^^^
|
||||
@ -8,7 +8,7 @@ LL | let _ = f();
|
||||
= help: consider explicitly using function result
|
||||
|
||||
error: non-binding let on an expression with `#[must_use]` type
|
||||
--> $DIR/let_underscore_must_use.rs:67:5
|
||||
--> $DIR/let_underscore_must_use.rs:68:5
|
||||
|
|
||||
LL | let _ = g();
|
||||
| ^^^^^^^^^^^^
|
||||
@ -16,7 +16,7 @@ LL | let _ = g();
|
||||
= help: consider explicitly using expression value
|
||||
|
||||
error: non-binding let on a result of a `#[must_use]` function
|
||||
--> $DIR/let_underscore_must_use.rs:69:5
|
||||
--> $DIR/let_underscore_must_use.rs:70:5
|
||||
|
|
||||
LL | let _ = l(0_u32);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
@ -24,7 +24,7 @@ LL | let _ = l(0_u32);
|
||||
= help: consider explicitly using function result
|
||||
|
||||
error: non-binding let on a result of a `#[must_use]` function
|
||||
--> $DIR/let_underscore_must_use.rs:73:5
|
||||
--> $DIR/let_underscore_must_use.rs:74:5
|
||||
|
|
||||
LL | let _ = s.f();
|
||||
| ^^^^^^^^^^^^^^
|
||||
@ -32,7 +32,7 @@ LL | let _ = s.f();
|
||||
= help: consider explicitly using function result
|
||||
|
||||
error: non-binding let on an expression with `#[must_use]` type
|
||||
--> $DIR/let_underscore_must_use.rs:74:5
|
||||
--> $DIR/let_underscore_must_use.rs:75:5
|
||||
|
|
||||
LL | let _ = s.g();
|
||||
| ^^^^^^^^^^^^^^
|
||||
@ -40,7 +40,7 @@ LL | let _ = s.g();
|
||||
= help: consider explicitly using expression value
|
||||
|
||||
error: non-binding let on a result of a `#[must_use]` function
|
||||
--> $DIR/let_underscore_must_use.rs:77:5
|
||||
--> $DIR/let_underscore_must_use.rs:78:5
|
||||
|
|
||||
LL | let _ = S::h();
|
||||
| ^^^^^^^^^^^^^^^
|
||||
@ -48,7 +48,7 @@ LL | let _ = S::h();
|
||||
= help: consider explicitly using function result
|
||||
|
||||
error: non-binding let on an expression with `#[must_use]` type
|
||||
--> $DIR/let_underscore_must_use.rs:78:5
|
||||
--> $DIR/let_underscore_must_use.rs:79:5
|
||||
|
|
||||
LL | let _ = S::p();
|
||||
| ^^^^^^^^^^^^^^^
|
||||
@ -56,7 +56,7 @@ LL | let _ = S::p();
|
||||
= help: consider explicitly using expression value
|
||||
|
||||
error: non-binding let on a result of a `#[must_use]` function
|
||||
--> $DIR/let_underscore_must_use.rs:80:5
|
||||
--> $DIR/let_underscore_must_use.rs:81:5
|
||||
|
|
||||
LL | let _ = S::a();
|
||||
| ^^^^^^^^^^^^^^^
|
||||
@ -64,7 +64,7 @@ LL | let _ = S::a();
|
||||
= help: consider explicitly using function result
|
||||
|
||||
error: non-binding let on an expression with `#[must_use]` type
|
||||
--> $DIR/let_underscore_must_use.rs:82:5
|
||||
--> $DIR/let_underscore_must_use.rs:83:5
|
||||
|
|
||||
LL | let _ = if true { Ok(()) } else { Err(()) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -72,7 +72,7 @@ LL | let _ = if true { Ok(()) } else { Err(()) };
|
||||
= help: consider explicitly using expression value
|
||||
|
||||
error: non-binding let on a result of a `#[must_use]` function
|
||||
--> $DIR/let_underscore_must_use.rs:86:5
|
||||
--> $DIR/let_underscore_must_use.rs:87:5
|
||||
|
|
||||
LL | let _ = a.is_ok();
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
@ -80,7 +80,7 @@ LL | let _ = a.is_ok();
|
||||
= help: consider explicitly using function result
|
||||
|
||||
error: non-binding let on an expression with `#[must_use]` type
|
||||
--> $DIR/let_underscore_must_use.rs:88:5
|
||||
--> $DIR/let_underscore_must_use.rs:89:5
|
||||
|
|
||||
LL | let _ = a.map(|_| ());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -88,7 +88,7 @@ LL | let _ = a.map(|_| ());
|
||||
= help: consider explicitly using expression value
|
||||
|
||||
error: non-binding let on an expression with `#[must_use]` type
|
||||
--> $DIR/let_underscore_must_use.rs:90:5
|
||||
--> $DIR/let_underscore_must_use.rs:91:5
|
||||
|
|
||||
LL | let _ = a;
|
||||
| ^^^^^^^^^^
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_variables, clippy::unnecessary_wraps)]
|
||||
|
||||
fn option_unwrap_or() {
|
||||
// int case
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_variables, clippy::unnecessary_wraps)]
|
||||
|
||||
fn option_unwrap_or() {
|
||||
// int case
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![warn(clippy::map_err_ignore)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
use std::convert::TryFrom;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `map_err(|_|...` ignores the original error
|
||||
--> $DIR/map_err.rs:22:32
|
||||
--> $DIR/map_err.rs:23:32
|
||||
|
|
||||
LL | println!("{:?}", x.map_err(|_| Errors::Ignored));
|
||||
| ^^^
|
||||
|
@ -4,6 +4,7 @@
|
||||
#![allow(clippy::let_underscore_drop)]
|
||||
#![allow(clippy::missing_docs_in_private_items)]
|
||||
#![allow(clippy::map_identity)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn main() {
|
||||
// mapping to Option on Iterator
|
||||
|
@ -4,6 +4,7 @@
|
||||
#![allow(clippy::let_underscore_drop)]
|
||||
#![allow(clippy::missing_docs_in_private_items)]
|
||||
#![allow(clippy::map_identity)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn main() {
|
||||
// mapping to Option on Iterator
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: called `map(..).flatten()` on an `Iterator`
|
||||
--> $DIR/map_flatten.rs:15:46
|
||||
--> $DIR/map_flatten.rs:16:46
|
||||
|
|
||||
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(option_id)`
|
||||
@ -7,31 +7,31 @@ LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().coll
|
||||
= note: `-D clippy::map-flatten` implied by `-D warnings`
|
||||
|
||||
error: called `map(..).flatten()` on an `Iterator`
|
||||
--> $DIR/map_flatten.rs:16:46
|
||||
--> $DIR/map_flatten.rs:17:46
|
||||
|
|
||||
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(option_id_ref)`
|
||||
|
||||
error: called `map(..).flatten()` on an `Iterator`
|
||||
--> $DIR/map_flatten.rs:17:46
|
||||
--> $DIR/map_flatten.rs:18:46
|
||||
|
|
||||
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(option_id_closure)`
|
||||
|
||||
error: called `map(..).flatten()` on an `Iterator`
|
||||
--> $DIR/map_flatten.rs:18:46
|
||||
--> $DIR/map_flatten.rs:19:46
|
||||
|
|
||||
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `filter_map` instead: `.filter_map(|x| x.checked_add(1))`
|
||||
|
||||
error: called `map(..).flatten()` on an `Iterator`
|
||||
--> $DIR/map_flatten.rs:21:46
|
||||
--> $DIR/map_flatten.rs:22:46
|
||||
|
|
||||
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `flat_map` instead: `.flat_map(|x| 0..x)`
|
||||
|
||||
error: called `map(..).flatten()` on an `Option`
|
||||
--> $DIR/map_flatten.rs:24:39
|
||||
--> $DIR/map_flatten.rs:25:39
|
||||
|
|
||||
LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `.and_then(|x| x)`
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![warn(clippy::needless_lifetimes)]
|
||||
#![allow(dead_code, clippy::needless_pass_by_value)]
|
||||
#![allow(dead_code, clippy::needless_pass_by_value, clippy::unnecessary_wraps)]
|
||||
|
||||
fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#![warn(clippy::option_map_unit_fn)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn do_nothing<T>(_: T) {}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#![warn(clippy::option_map_unit_fn)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn do_nothing<T>(_: T) {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:38:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:39:5
|
||||
|
|
||||
LL | x.field.map(do_nothing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -9,7 +9,7 @@ LL | x.field.map(do_nothing);
|
||||
= note: `-D clippy::option-map-unit-fn` implied by `-D warnings`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:40:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:41:5
|
||||
|
|
||||
LL | x.field.map(do_nothing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -17,7 +17,7 @@ LL | x.field.map(do_nothing);
|
||||
| help: try this: `if let Some(x_field) = x.field { do_nothing(x_field) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:42:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:43:5
|
||||
|
|
||||
LL | x.field.map(diverge);
|
||||
| ^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -25,7 +25,7 @@ LL | x.field.map(diverge);
|
||||
| help: try this: `if let Some(x_field) = x.field { diverge(x_field) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:48:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:49:5
|
||||
|
|
||||
LL | x.field.map(|value| x.do_option_nothing(value + captured));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -33,7 +33,7 @@ LL | x.field.map(|value| x.do_option_nothing(value + captured));
|
||||
| help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:50:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:51:5
|
||||
|
|
||||
LL | x.field.map(|value| { x.do_option_plus_one(value + captured); });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -41,7 +41,7 @@ LL | x.field.map(|value| { x.do_option_plus_one(value + captured); });
|
||||
| help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:53:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:54:5
|
||||
|
|
||||
LL | x.field.map(|value| do_nothing(value + captured));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -49,7 +49,7 @@ LL | x.field.map(|value| do_nothing(value + captured));
|
||||
| help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:55:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:56:5
|
||||
|
|
||||
LL | x.field.map(|value| { do_nothing(value + captured) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -57,7 +57,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) });
|
||||
| help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:57:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:58:5
|
||||
|
|
||||
LL | x.field.map(|value| { do_nothing(value + captured); });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -65,7 +65,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); });
|
||||
| help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:59:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:60:5
|
||||
|
|
||||
LL | x.field.map(|value| { { do_nothing(value + captured); } });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -73,7 +73,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } });
|
||||
| help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:62:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:63:5
|
||||
|
|
||||
LL | x.field.map(|value| diverge(value + captured));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -81,7 +81,7 @@ LL | x.field.map(|value| diverge(value + captured));
|
||||
| help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:64:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:65:5
|
||||
|
|
||||
LL | x.field.map(|value| { diverge(value + captured) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -89,7 +89,7 @@ LL | x.field.map(|value| { diverge(value + captured) });
|
||||
| help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:66:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:67:5
|
||||
|
|
||||
LL | x.field.map(|value| { diverge(value + captured); });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -97,7 +97,7 @@ LL | x.field.map(|value| { diverge(value + captured); });
|
||||
| help: try this: `if let Some(value) = x.field { diverge(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:68:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:69:5
|
||||
|
|
||||
LL | x.field.map(|value| { { diverge(value + captured); } });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -105,7 +105,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } });
|
||||
| help: try this: `if let Some(value) = x.field { diverge(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:73:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:74:5
|
||||
|
|
||||
LL | x.field.map(|value| { let y = plus_one(value + captured); });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -113,7 +113,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); });
|
||||
| help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:75:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:76:5
|
||||
|
|
||||
LL | x.field.map(|value| { plus_one(value + captured); });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -121,7 +121,7 @@ LL | x.field.map(|value| { plus_one(value + captured); });
|
||||
| help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:77:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:78:5
|
||||
|
|
||||
LL | x.field.map(|value| { { plus_one(value + captured); } });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -129,7 +129,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } });
|
||||
| help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:80:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:81:5
|
||||
|
|
||||
LL | x.field.map(|ref value| { do_nothing(value + captured) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
@ -137,7 +137,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) });
|
||||
| help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }`
|
||||
|
||||
error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:82:5
|
||||
--> $DIR/option_map_unit_fn_fixable.rs:83:5
|
||||
|
|
||||
LL | option().map(do_nothing);}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![deny(clippy::option_option)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn input(_: Option<Option<u8>>) {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:3:13
|
||||
--> $DIR/option_option.rs:4:13
|
||||
|
|
||||
LL | fn input(_: Option<Option<u8>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
@ -11,55 +11,55 @@ LL | #![deny(clippy::option_option)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:5:16
|
||||
--> $DIR/option_option.rs:6:16
|
||||
|
|
||||
LL | fn output() -> Option<Option<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:9:27
|
||||
--> $DIR/option_option.rs:10:27
|
||||
|
|
||||
LL | fn output_nested() -> Vec<Option<Option<u8>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:14:30
|
||||
--> $DIR/option_option.rs:15:30
|
||||
|
|
||||
LL | fn output_nested_nested() -> Option<Option<Option<u8>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:19:8
|
||||
--> $DIR/option_option.rs:20:8
|
||||
|
|
||||
LL | x: Option<Option<u8>>,
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:23:23
|
||||
--> $DIR/option_option.rs:24:23
|
||||
|
|
||||
LL | fn struct_fn() -> Option<Option<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:29:22
|
||||
--> $DIR/option_option.rs:30:22
|
||||
|
|
||||
LL | fn trait_fn() -> Option<Option<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:33:11
|
||||
--> $DIR/option_option.rs:34:11
|
||||
|
|
||||
LL | Tuple(Option<Option<u8>>),
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:34:17
|
||||
--> $DIR/option_option.rs:35:17
|
||||
|
|
||||
LL | Struct { x: Option<Option<u8>> },
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> $DIR/option_option.rs:75:14
|
||||
--> $DIR/option_option.rs:76:14
|
||||
|
|
||||
LL | foo: Option<Option<Cow<'a, str>>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#![warn(clippy::or_fun_call)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#![warn(clippy::or_fun_call)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:32:19
|
||||
--> $DIR/or_fun_call.rs:33:19
|
||||
|
|
||||
LL | with_const_fn.unwrap_or(Duration::from_secs(5));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Duration::from_secs(5))`
|
||||
@ -7,97 +7,97 @@ LL | with_const_fn.unwrap_or(Duration::from_secs(5));
|
||||
= note: `-D clippy::or-fun-call` implied by `-D warnings`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:35:22
|
||||
--> $DIR/or_fun_call.rs:36:22
|
||||
|
|
||||
LL | with_constructor.unwrap_or(make());
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `new`
|
||||
--> $DIR/or_fun_call.rs:38:5
|
||||
--> $DIR/or_fun_call.rs:39:5
|
||||
|
|
||||
LL | with_new.unwrap_or(Vec::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:41:21
|
||||
--> $DIR/or_fun_call.rs:42:21
|
||||
|
|
||||
LL | with_const_args.unwrap_or(Vec::with_capacity(12));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:44:14
|
||||
--> $DIR/or_fun_call.rs:45:14
|
||||
|
|
||||
LL | with_err.unwrap_or(make());
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:47:19
|
||||
--> $DIR/or_fun_call.rs:48:19
|
||||
|
|
||||
LL | with_err_args.unwrap_or(Vec::with_capacity(12));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `default`
|
||||
--> $DIR/or_fun_call.rs:50:5
|
||||
--> $DIR/or_fun_call.rs:51:5
|
||||
|
|
||||
LL | with_default_trait.unwrap_or(Default::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `default`
|
||||
--> $DIR/or_fun_call.rs:53:5
|
||||
--> $DIR/or_fun_call.rs:54:5
|
||||
|
|
||||
LL | with_default_type.unwrap_or(u64::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a call to `new`
|
||||
--> $DIR/or_fun_call.rs:56:5
|
||||
--> $DIR/or_fun_call.rs:57:5
|
||||
|
|
||||
LL | with_vec.unwrap_or(vec![]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_vec.unwrap_or_default()`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:59:21
|
||||
--> $DIR/or_fun_call.rs:60:21
|
||||
|
|
||||
LL | without_default.unwrap_or(Foo::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
|
||||
|
||||
error: use of `or_insert` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:62:19
|
||||
--> $DIR/or_fun_call.rs:63:19
|
||||
|
|
||||
LL | map.entry(42).or_insert(String::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
|
||||
|
||||
error: use of `or_insert` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:65:21
|
||||
--> $DIR/or_fun_call.rs:66:21
|
||||
|
|
||||
LL | btree.entry(42).or_insert(String::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:68:21
|
||||
--> $DIR/or_fun_call.rs:69:21
|
||||
|
|
||||
LL | let _ = stringy.unwrap_or("".to_owned());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:76:21
|
||||
--> $DIR/or_fun_call.rs:77:21
|
||||
|
|
||||
LL | let _ = Some(1).unwrap_or(map[&1]);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`
|
||||
|
||||
error: use of `unwrap_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:78:21
|
||||
--> $DIR/or_fun_call.rs:79:21
|
||||
|
|
||||
LL | let _ = Some(1).unwrap_or(map[&1]);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`
|
||||
|
||||
error: use of `or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:102:35
|
||||
--> $DIR/or_fun_call.rs:103:35
|
||||
|
|
||||
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`
|
||||
|
||||
error: use of `or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:106:10
|
||||
--> $DIR/or_fun_call.rs:107:10
|
||||
|
|
||||
LL | .or(Some(Bar(b, Duration::from_secs(2))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![warn(clippy::panic_in_result_fn)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
struct A;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: used `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` in a function that returns `Result`
|
||||
--> $DIR/panic_in_result_fn.rs:6:5
|
||||
--> $DIR/panic_in_result_fn.rs:7:5
|
||||
|
|
||||
LL | / fn result_with_panic() -> Result<bool, String> // should emit lint
|
||||
LL | | {
|
||||
@ -10,14 +10,14 @@ LL | | }
|
||||
= note: `-D clippy::panic-in-result-fn` implied by `-D warnings`
|
||||
= help: `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing
|
||||
note: return Err() instead of panicking
|
||||
--> $DIR/panic_in_result_fn.rs:8:9
|
||||
--> $DIR/panic_in_result_fn.rs:9:9
|
||||
|
|
||||
LL | panic!("error");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: used `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` in a function that returns `Result`
|
||||
--> $DIR/panic_in_result_fn.rs:11:5
|
||||
--> $DIR/panic_in_result_fn.rs:12:5
|
||||
|
|
||||
LL | / fn result_with_unimplemented() -> Result<bool, String> // should emit lint
|
||||
LL | | {
|
||||
@ -27,14 +27,14 @@ LL | | }
|
||||
|
|
||||
= help: `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing
|
||||
note: return Err() instead of panicking
|
||||
--> $DIR/panic_in_result_fn.rs:13:9
|
||||
--> $DIR/panic_in_result_fn.rs:14:9
|
||||
|
|
||||
LL | unimplemented!();
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: used `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` in a function that returns `Result`
|
||||
--> $DIR/panic_in_result_fn.rs:16:5
|
||||
--> $DIR/panic_in_result_fn.rs:17:5
|
||||
|
|
||||
LL | / fn result_with_unreachable() -> Result<bool, String> // should emit lint
|
||||
LL | | {
|
||||
@ -44,14 +44,14 @@ LL | | }
|
||||
|
|
||||
= help: `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing
|
||||
note: return Err() instead of panicking
|
||||
--> $DIR/panic_in_result_fn.rs:18:9
|
||||
--> $DIR/panic_in_result_fn.rs:19:9
|
||||
|
|
||||
LL | unreachable!();
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: used `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` in a function that returns `Result`
|
||||
--> $DIR/panic_in_result_fn.rs:21:5
|
||||
--> $DIR/panic_in_result_fn.rs:22:5
|
||||
|
|
||||
LL | / fn result_with_todo() -> Result<bool, String> // should emit lint
|
||||
LL | | {
|
||||
@ -61,14 +61,14 @@ LL | | }
|
||||
|
|
||||
= help: `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing
|
||||
note: return Err() instead of panicking
|
||||
--> $DIR/panic_in_result_fn.rs:23:9
|
||||
--> $DIR/panic_in_result_fn.rs:24:9
|
||||
|
|
||||
LL | todo!("Finish this");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: used `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` in a function that returns `Result`
|
||||
--> $DIR/panic_in_result_fn.rs:52:1
|
||||
--> $DIR/panic_in_result_fn.rs:53:1
|
||||
|
|
||||
LL | / fn function_result_with_panic() -> Result<bool, String> // should emit lint
|
||||
LL | | {
|
||||
@ -78,14 +78,14 @@ LL | | }
|
||||
|
|
||||
= help: `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing
|
||||
note: return Err() instead of panicking
|
||||
--> $DIR/panic_in_result_fn.rs:54:5
|
||||
--> $DIR/panic_in_result_fn.rs:55:5
|
||||
|
|
||||
LL | panic!("error");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: used `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` in a function that returns `Result`
|
||||
--> $DIR/panic_in_result_fn.rs:67:1
|
||||
--> $DIR/panic_in_result_fn.rs:68:1
|
||||
|
|
||||
LL | / fn main() -> Result<(), String> {
|
||||
LL | | todo!("finish main method");
|
||||
@ -95,7 +95,7 @@ LL | | }
|
||||
|
|
||||
= help: `unimplemented!()`, `unreachable!()`, `todo!()` or `panic!()` should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing
|
||||
note: return Err() instead of panicking
|
||||
--> $DIR/panic_in_result_fn.rs:68:5
|
||||
--> $DIR/panic_in_result_fn.rs:69:5
|
||||
|
|
||||
LL | todo!("finish main method");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,5 +1,6 @@
|
||||
// run-rustfix
|
||||
#![allow(unreachable_code)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn some_func(a: Option<u32>) -> Option<u32> {
|
||||
a?;
|
||||
|
@ -1,5 +1,6 @@
|
||||
// run-rustfix
|
||||
#![allow(unreachable_code)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn some_func(a: Option<u32>) -> Option<u32> {
|
||||
if a.is_none() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:5:5
|
||||
--> $DIR/question_mark.rs:6:5
|
||||
|
|
||||
LL | / if a.is_none() {
|
||||
LL | | return None;
|
||||
@ -9,7 +9,7 @@ LL | | }
|
||||
= note: `-D clippy::question-mark` implied by `-D warnings`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:50:9
|
||||
--> $DIR/question_mark.rs:51:9
|
||||
|
|
||||
LL | / if (self.opt).is_none() {
|
||||
LL | | return None;
|
||||
@ -17,7 +17,7 @@ LL | | }
|
||||
| |_________^ help: replace it with: `(self.opt)?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:54:9
|
||||
--> $DIR/question_mark.rs:55:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None
|
||||
@ -25,7 +25,7 @@ LL | | }
|
||||
| |_________^ help: replace it with: `self.opt?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:58:17
|
||||
--> $DIR/question_mark.rs:59:17
|
||||
|
|
||||
LL | let _ = if self.opt.is_none() {
|
||||
| _________________^
|
||||
@ -36,7 +36,7 @@ LL | | };
|
||||
| |_________^ help: replace it with: `Some(self.opt?)`
|
||||
|
||||
error: this if-let-else may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:64:17
|
||||
--> $DIR/question_mark.rs:65:17
|
||||
|
|
||||
LL | let _ = if let Some(x) = self.opt {
|
||||
| _________________^
|
||||
@ -47,7 +47,7 @@ LL | | };
|
||||
| |_________^ help: replace it with: `self.opt?`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:81:9
|
||||
--> $DIR/question_mark.rs:82:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None;
|
||||
@ -55,7 +55,7 @@ LL | | }
|
||||
| |_________^ help: replace it with: `self.opt.as_ref()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:89:9
|
||||
--> $DIR/question_mark.rs:90:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None;
|
||||
@ -63,7 +63,7 @@ LL | | }
|
||||
| |_________^ help: replace it with: `self.opt.as_ref()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:97:9
|
||||
--> $DIR/question_mark.rs:98:9
|
||||
|
|
||||
LL | / if self.opt.is_none() {
|
||||
LL | | return None;
|
||||
@ -71,7 +71,7 @@ LL | | }
|
||||
| |_________^ help: replace it with: `self.opt.as_ref()?;`
|
||||
|
||||
error: this if-let-else may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:104:26
|
||||
--> $DIR/question_mark.rs:105:26
|
||||
|
|
||||
LL | let v: &Vec<_> = if let Some(ref v) = self.opt {
|
||||
| __________________________^
|
||||
@ -82,7 +82,7 @@ LL | | };
|
||||
| |_________^ help: replace it with: `self.opt.as_ref()?`
|
||||
|
||||
error: this if-let-else may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:114:17
|
||||
--> $DIR/question_mark.rs:115:17
|
||||
|
|
||||
LL | let v = if let Some(v) = self.opt {
|
||||
| _________________^
|
||||
@ -93,7 +93,7 @@ LL | | };
|
||||
| |_________^ help: replace it with: `self.opt?`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:129:5
|
||||
--> $DIR/question_mark.rs:130:5
|
||||
|
|
||||
LL | / if f().is_none() {
|
||||
LL | | return None;
|
||||
|
@ -7,6 +7,7 @@
|
||||
unused_must_use,
|
||||
clippy::needless_bool,
|
||||
clippy::match_like_matches_macro,
|
||||
clippy::unnecessary_wraps,
|
||||
deprecated
|
||||
)]
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
unused_must_use,
|
||||
clippy::needless_bool,
|
||||
clippy::match_like_matches_macro,
|
||||
clippy::unnecessary_wraps,
|
||||
deprecated
|
||||
)]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:15:12
|
||||
--> $DIR/redundant_pattern_matching.rs:16:12
|
||||
|
|
||||
LL | if let Ok(_) = &result {}
|
||||
| -------^^^^^---------- help: try this: `if result.is_ok()`
|
||||
@ -7,31 +7,31 @@ LL | if let Ok(_) = &result {}
|
||||
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:17:12
|
||||
--> $DIR/redundant_pattern_matching.rs:18:12
|
||||
|
|
||||
LL | if let Ok(_) = Ok::<i32, i32>(42) {}
|
||||
| -------^^^^^--------------------- help: try this: `if Ok::<i32, i32>(42).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:19:12
|
||||
--> $DIR/redundant_pattern_matching.rs:20:12
|
||||
|
|
||||
LL | if let Err(_) = Err::<i32, i32>(42) {}
|
||||
| -------^^^^^^---------------------- help: try this: `if Err::<i32, i32>(42).is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:21:15
|
||||
--> $DIR/redundant_pattern_matching.rs:22:15
|
||||
|
|
||||
LL | while let Ok(_) = Ok::<i32, i32>(10) {}
|
||||
| ----------^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:23:15
|
||||
--> $DIR/redundant_pattern_matching.rs:24:15
|
||||
|
|
||||
LL | while let Err(_) = Ok::<i32, i32>(10) {}
|
||||
| ----------^^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:33:5
|
||||
--> $DIR/redundant_pattern_matching.rs:34:5
|
||||
|
|
||||
LL | / match Ok::<i32, i32>(42) {
|
||||
LL | | Ok(_) => true,
|
||||
@ -40,7 +40,7 @@ LL | | };
|
||||
| |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:38:5
|
||||
--> $DIR/redundant_pattern_matching.rs:39:5
|
||||
|
|
||||
LL | / match Ok::<i32, i32>(42) {
|
||||
LL | | Ok(_) => false,
|
||||
@ -49,7 +49,7 @@ LL | | };
|
||||
| |_____^ help: try this: `Ok::<i32, i32>(42).is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:43:5
|
||||
--> $DIR/redundant_pattern_matching.rs:44:5
|
||||
|
|
||||
LL | / match Err::<i32, i32>(42) {
|
||||
LL | | Ok(_) => false,
|
||||
@ -58,7 +58,7 @@ LL | | };
|
||||
| |_____^ help: try this: `Err::<i32, i32>(42).is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:48:5
|
||||
--> $DIR/redundant_pattern_matching.rs:49:5
|
||||
|
|
||||
LL | / match Err::<i32, i32>(42) {
|
||||
LL | | Ok(_) => true,
|
||||
@ -67,73 +67,73 @@ LL | | };
|
||||
| |_____^ help: try this: `Err::<i32, i32>(42).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:53:20
|
||||
--> $DIR/redundant_pattern_matching.rs:54:20
|
||||
|
|
||||
LL | let _ = if let Ok(_) = Ok::<usize, ()>(4) { true } else { false };
|
||||
| -------^^^^^--------------------- help: try this: `if Ok::<usize, ()>(4).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:59:20
|
||||
--> $DIR/redundant_pattern_matching.rs:60:20
|
||||
|
|
||||
LL | let _ = if let Ok(_) = gen_res() {
|
||||
| -------^^^^^------------ help: try this: `if gen_res().is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:61:19
|
||||
--> $DIR/redundant_pattern_matching.rs:62:19
|
||||
|
|
||||
LL | } else if let Err(_) = gen_res() {
|
||||
| -------^^^^^^------------ help: try this: `if gen_res().is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_some()`
|
||||
--> $DIR/redundant_pattern_matching.rs:84:19
|
||||
--> $DIR/redundant_pattern_matching.rs:85:19
|
||||
|
|
||||
LL | while let Some(_) = r#try!(result_opt()) {}
|
||||
| ----------^^^^^^^----------------------- help: try this: `while r#try!(result_opt()).is_some()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_some()`
|
||||
--> $DIR/redundant_pattern_matching.rs:85:16
|
||||
--> $DIR/redundant_pattern_matching.rs:86:16
|
||||
|
|
||||
LL | if let Some(_) = r#try!(result_opt()) {}
|
||||
| -------^^^^^^^----------------------- help: try this: `if r#try!(result_opt()).is_some()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_some()`
|
||||
--> $DIR/redundant_pattern_matching.rs:91:12
|
||||
--> $DIR/redundant_pattern_matching.rs:92:12
|
||||
|
|
||||
LL | if let Some(_) = m!() {}
|
||||
| -------^^^^^^^------- help: try this: `if m!().is_some()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_some()`
|
||||
--> $DIR/redundant_pattern_matching.rs:92:15
|
||||
--> $DIR/redundant_pattern_matching.rs:93:15
|
||||
|
|
||||
LL | while let Some(_) = m!() {}
|
||||
| ----------^^^^^^^------- help: try this: `while m!().is_some()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:110:12
|
||||
--> $DIR/redundant_pattern_matching.rs:111:12
|
||||
|
|
||||
LL | if let Ok(_) = Ok::<i32, i32>(42) {}
|
||||
| -------^^^^^--------------------- help: try this: `if Ok::<i32, i32>(42).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:112:12
|
||||
--> $DIR/redundant_pattern_matching.rs:113:12
|
||||
|
|
||||
LL | if let Err(_) = Err::<i32, i32>(42) {}
|
||||
| -------^^^^^^---------------------- help: try this: `if Err::<i32, i32>(42).is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:114:15
|
||||
--> $DIR/redundant_pattern_matching.rs:115:15
|
||||
|
|
||||
LL | while let Ok(_) = Ok::<i32, i32>(10) {}
|
||||
| ----------^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:116:15
|
||||
--> $DIR/redundant_pattern_matching.rs:117:15
|
||||
|
|
||||
LL | while let Err(_) = Ok::<i32, i32>(10) {}
|
||||
| ----------^^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_err()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_ok()`
|
||||
--> $DIR/redundant_pattern_matching.rs:118:5
|
||||
--> $DIR/redundant_pattern_matching.rs:119:5
|
||||
|
|
||||
LL | / match Ok::<i32, i32>(42) {
|
||||
LL | | Ok(_) => true,
|
||||
@ -142,7 +142,7 @@ LL | | };
|
||||
| |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()`
|
||||
|
||||
error: redundant pattern matching, consider using `is_err()`
|
||||
--> $DIR/redundant_pattern_matching.rs:123:5
|
||||
--> $DIR/redundant_pattern_matching.rs:124:5
|
||||
|
|
||||
LL | / match Err::<i32, i32>(42) {
|
||||
LL | | Ok(_) => false,
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
#[warn(clippy::result_unit_err)]
|
||||
#[allow(unused)]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this returns a `Result<_, ()>
|
||||
--> $DIR/result_unit_error.rs:4:1
|
||||
--> $DIR/result_unit_error.rs:5:1
|
||||
|
|
||||
LL | pub fn returns_unit_error() -> Result<u32, ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -8,7 +8,7 @@ LL | pub fn returns_unit_error() -> Result<u32, ()> {
|
||||
= help: use a custom Error type instead
|
||||
|
||||
error: this returns a `Result<_, ()>
|
||||
--> $DIR/result_unit_error.rs:13:5
|
||||
--> $DIR/result_unit_error.rs:14:5
|
||||
|
|
||||
LL | fn get_that_error(&self) -> Result<bool, ()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -16,7 +16,7 @@ LL | fn get_that_error(&self) -> Result<bool, ()>;
|
||||
= help: use a custom Error type instead
|
||||
|
||||
error: this returns a `Result<_, ()>
|
||||
--> $DIR/result_unit_error.rs:15:5
|
||||
--> $DIR/result_unit_error.rs:16:5
|
||||
|
|
||||
LL | fn get_this_one_too(&self) -> Result<bool, ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -24,7 +24,7 @@ LL | fn get_this_one_too(&self) -> Result<bool, ()> {
|
||||
= help: use a custom Error type instead
|
||||
|
||||
error: this returns a `Result<_, ()>
|
||||
--> $DIR/result_unit_error.rs:33:5
|
||||
--> $DIR/result_unit_error.rs:34:5
|
||||
|
|
||||
LL | pub fn unit_error(&self) -> Result<usize, ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,6 +2,7 @@
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![deny(clippy::try_err)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate macro_rules;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![deny(clippy::try_err)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate macro_rules;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:18:9
|
||||
--> $DIR/try_err.rs:19:9
|
||||
|
|
||||
LL | Err(err)?;
|
||||
| ^^^^^^^^^ help: try this: `return Err(err)`
|
||||
@ -11,25 +11,25 @@ LL | #![deny(clippy::try_err)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:28:9
|
||||
--> $DIR/try_err.rs:29:9
|
||||
|
|
||||
LL | Err(err)?;
|
||||
| ^^^^^^^^^ help: try this: `return Err(err.into())`
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:48:17
|
||||
--> $DIR/try_err.rs:49:17
|
||||
|
|
||||
LL | Err(err)?;
|
||||
| ^^^^^^^^^ help: try this: `return Err(err)`
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:67:17
|
||||
--> $DIR/try_err.rs:68:17
|
||||
|
|
||||
LL | Err(err)?;
|
||||
| ^^^^^^^^^ help: try this: `return Err(err.into())`
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:86:23
|
||||
--> $DIR/try_err.rs:87:23
|
||||
|
|
||||
LL | Err(_) => Err(1)?,
|
||||
| ^^^^^^^ help: try this: `return Err(1)`
|
||||
@ -40,7 +40,7 @@ LL | try_validation!(Ok::<_, i32>(5));
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:101:23
|
||||
--> $DIR/try_err.rs:102:23
|
||||
|
|
||||
LL | Err(_) => Err(ret_one!())?,
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `return Err(ret_one!())`
|
||||
@ -51,25 +51,25 @@ LL | try_validation_in_macro!(Ok::<_, i32>(5));
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:140:9
|
||||
--> $DIR/try_err.rs:141:9
|
||||
|
|
||||
LL | Err(foo!())?;
|
||||
| ^^^^^^^^^^^^ help: try this: `return Err(foo!())`
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:147:9
|
||||
--> $DIR/try_err.rs:148:9
|
||||
|
|
||||
LL | Err(io::ErrorKind::WriteZero)?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Poll::Ready(Err(io::ErrorKind::WriteZero.into()))`
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:149:9
|
||||
--> $DIR/try_err.rs:150:9
|
||||
|
|
||||
LL | Err(io::Error::new(io::ErrorKind::InvalidInput, "error"))?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Poll::Ready(Err(io::Error::new(io::ErrorKind::InvalidInput, "error")))`
|
||||
|
||||
error: returning an `Err(_)` with the `?` operator
|
||||
--> $DIR/try_err.rs:157:9
|
||||
--> $DIR/try_err.rs:158:9
|
||||
|
|
||||
LL | Err(io::ErrorKind::NotFound)?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Poll::Ready(Some(Err(io::ErrorKind::NotFound.into())))`
|
||||
|
@ -4,6 +4,7 @@
|
||||
unused_must_use,
|
||||
unused_variables,
|
||||
clippy::unused_unit,
|
||||
clippy::unnecessary_wraps,
|
||||
clippy::or_fun_call
|
||||
)]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:29:5
|
||||
--> $DIR/unit_arg.rs:30:5
|
||||
|
|
||||
LL | / foo({
|
||||
LL | | 1;
|
||||
@ -20,7 +20,7 @@ LL | foo(());
|
||||
|
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:32:5
|
||||
--> $DIR/unit_arg.rs:33:5
|
||||
|
|
||||
LL | foo(foo(1));
|
||||
| ^^^^^^^^^^^
|
||||
@ -32,7 +32,7 @@ LL | foo(());
|
||||
|
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:33:5
|
||||
--> $DIR/unit_arg.rs:34:5
|
||||
|
|
||||
LL | / foo({
|
||||
LL | | foo(1);
|
||||
@ -54,7 +54,7 @@ LL | foo(());
|
||||
|
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:38:5
|
||||
--> $DIR/unit_arg.rs:39:5
|
||||
|
|
||||
LL | / b.bar({
|
||||
LL | | 1;
|
||||
@ -74,7 +74,7 @@ LL | b.bar(());
|
||||
|
|
||||
|
||||
error: passing unit values to a function
|
||||
--> $DIR/unit_arg.rs:41:5
|
||||
--> $DIR/unit_arg.rs:42:5
|
||||
|
|
||||
LL | taking_multiple_units(foo(0), foo(1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -87,7 +87,7 @@ LL | taking_multiple_units((), ());
|
||||
|
|
||||
|
||||
error: passing unit values to a function
|
||||
--> $DIR/unit_arg.rs:42:5
|
||||
--> $DIR/unit_arg.rs:43:5
|
||||
|
|
||||
LL | / taking_multiple_units(foo(0), {
|
||||
LL | | foo(1);
|
||||
@ -110,7 +110,7 @@ LL | taking_multiple_units((), ());
|
||||
|
|
||||
|
||||
error: passing unit values to a function
|
||||
--> $DIR/unit_arg.rs:46:5
|
||||
--> $DIR/unit_arg.rs:47:5
|
||||
|
|
||||
LL | / taking_multiple_units(
|
||||
LL | | {
|
||||
@ -140,7 +140,7 @@ LL | foo(2);
|
||||
...
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:57:13
|
||||
--> $DIR/unit_arg.rs:58:13
|
||||
|
|
||||
LL | None.or(Some(foo(2)));
|
||||
| ^^^^^^^^^^^^
|
||||
@ -154,7 +154,7 @@ LL | });
|
||||
|
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:60:5
|
||||
--> $DIR/unit_arg.rs:61:5
|
||||
|
|
||||
LL | foo(foo(()))
|
||||
| ^^^^^^^^^^^^
|
||||
@ -166,7 +166,7 @@ LL | foo(())
|
||||
|
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:93:5
|
||||
--> $DIR/unit_arg.rs:94:5
|
||||
|
|
||||
LL | Some(foo(1))
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -1,7 +1,7 @@
|
||||
// does not test any rustfixable lints
|
||||
|
||||
#![warn(clippy::clone_on_ref_ptr)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
#![allow(unused, clippy::redundant_clone, clippy::unnecessary_wraps)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::{self, Rc};
|
||||
|
116
tests/ui/unnecessary_wraps.rs
Normal file
116
tests/ui/unnecessary_wraps.rs
Normal file
@ -0,0 +1,116 @@
|
||||
#![warn(clippy::unnecessary_wraps)]
|
||||
#![allow(clippy::no_effect)]
|
||||
#![allow(clippy::needless_return)]
|
||||
#![allow(clippy::if_same_then_else)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// should be linted
|
||||
fn func1(a: bool, b: bool) -> Option<i32> {
|
||||
if a && b {
|
||||
return Some(42);
|
||||
}
|
||||
if a {
|
||||
Some(-1);
|
||||
Some(2)
|
||||
} else {
|
||||
return Some(1337);
|
||||
}
|
||||
}
|
||||
|
||||
// should be linted
|
||||
fn func2(a: bool, b: bool) -> Option<i32> {
|
||||
if a && b {
|
||||
return Some(10);
|
||||
}
|
||||
if a {
|
||||
Some(20)
|
||||
} else {
|
||||
Some(30)
|
||||
}
|
||||
}
|
||||
|
||||
// public fns should not be linted
|
||||
pub fn func3(a: bool) -> Option<i32> {
|
||||
if a {
|
||||
Some(1)
|
||||
} else {
|
||||
Some(1)
|
||||
}
|
||||
}
|
||||
|
||||
// should not be linted
|
||||
fn func4(a: bool) -> Option<i32> {
|
||||
if a {
|
||||
Some(1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// should be linted
|
||||
fn func5() -> Option<i32> {
|
||||
Some(1)
|
||||
}
|
||||
|
||||
// should not be linted
|
||||
fn func6() -> Option<i32> {
|
||||
None
|
||||
}
|
||||
|
||||
// should be linted
|
||||
fn func7() -> Result<i32, ()> {
|
||||
Ok(1)
|
||||
}
|
||||
|
||||
// should not be linted
|
||||
fn func8(a: bool) -> Result<i32, ()> {
|
||||
if a {
|
||||
Ok(1)
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
// should not be linted
|
||||
fn func9(a: bool) -> Result<i32, ()> {
|
||||
Err(())
|
||||
}
|
||||
|
||||
// should not be linted
|
||||
fn func10() -> Option<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
struct A;
|
||||
|
||||
impl A {
|
||||
// should not be linted
|
||||
pub fn func11() -> Option<i32> {
|
||||
Some(1)
|
||||
}
|
||||
|
||||
// should be linted
|
||||
fn func12() -> Option<i32> {
|
||||
Some(1)
|
||||
}
|
||||
}
|
||||
|
||||
trait B {
|
||||
// trait impls are not linted
|
||||
fn func13() -> Option<i32> {
|
||||
Some(1)
|
||||
}
|
||||
}
|
||||
|
||||
impl B for A {
|
||||
// trait impls are not linted
|
||||
fn func13() -> Option<i32> {
|
||||
Some(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// method calls are not linted
|
||||
func1(true, true);
|
||||
func2(true, true);
|
||||
}
|
106
tests/ui/unnecessary_wraps.stderr
Normal file
106
tests/ui/unnecessary_wraps.stderr
Normal file
@ -0,0 +1,106 @@
|
||||
error: this function's return value is unnecessarily wrapped by `Option`
|
||||
--> $DIR/unnecessary_wraps.rs:8:1
|
||||
|
|
||||
LL | / fn func1(a: bool, b: bool) -> Option<i32> {
|
||||
LL | | if a && b {
|
||||
LL | | return Some(42);
|
||||
LL | | }
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
= note: `-D clippy::unnecessary-wraps` implied by `-D warnings`
|
||||
help: remove `Option` from the return type...
|
||||
|
|
||||
LL | fn func1(a: bool, b: bool) -> i32 {
|
||||
| ^^^
|
||||
help: ...and change the returning expressions
|
||||
|
|
||||
LL | return 42;
|
||||
LL | }
|
||||
LL | if a {
|
||||
LL | Some(-1);
|
||||
LL | 2
|
||||
LL | } else {
|
||||
...
|
||||
|
||||
error: this function's return value is unnecessarily wrapped by `Option`
|
||||
--> $DIR/unnecessary_wraps.rs:21:1
|
||||
|
|
||||
LL | / fn func2(a: bool, b: bool) -> Option<i32> {
|
||||
LL | | if a && b {
|
||||
LL | | return Some(10);
|
||||
LL | | }
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
help: remove `Option` from the return type...
|
||||
|
|
||||
LL | fn func2(a: bool, b: bool) -> i32 {
|
||||
| ^^^
|
||||
help: ...and change the returning expressions
|
||||
|
|
||||
LL | return 10;
|
||||
LL | }
|
||||
LL | if a {
|
||||
LL | 20
|
||||
LL | } else {
|
||||
LL | 30
|
||||
|
|
||||
|
||||
error: this function's return value is unnecessarily wrapped by `Option`
|
||||
--> $DIR/unnecessary_wraps.rs:51:1
|
||||
|
|
||||
LL | / fn func5() -> Option<i32> {
|
||||
LL | | Some(1)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
help: remove `Option` from the return type...
|
||||
|
|
||||
LL | fn func5() -> i32 {
|
||||
| ^^^
|
||||
help: ...and change the returning expressions
|
||||
|
|
||||
LL | 1
|
||||
|
|
||||
|
||||
error: this function's return value is unnecessarily wrapped by `Result`
|
||||
--> $DIR/unnecessary_wraps.rs:61:1
|
||||
|
|
||||
LL | / fn func7() -> Result<i32, ()> {
|
||||
LL | | Ok(1)
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
help: remove `Result` from the return type...
|
||||
|
|
||||
LL | fn func7() -> i32 {
|
||||
| ^^^
|
||||
help: ...and change the returning expressions
|
||||
|
|
||||
LL | 1
|
||||
|
|
||||
|
||||
error: this function's return value is unnecessarily wrapped by `Option`
|
||||
--> $DIR/unnecessary_wraps.rs:93:5
|
||||
|
|
||||
LL | / fn func12() -> Option<i32> {
|
||||
LL | | Some(1)
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: remove `Option` from the return type...
|
||||
|
|
||||
LL | fn func12() -> i32 {
|
||||
| ^^^
|
||||
help: ...and change the returning expressions
|
||||
|
|
||||
LL | 1
|
||||
|
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
@ -1,6 +1,7 @@
|
||||
// run-rustfix
|
||||
|
||||
#![deny(clippy::useless_conversion)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn test_generic<T: Copy>(val: T) -> T {
|
||||
let _ = val;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// run-rustfix
|
||||
|
||||
#![deny(clippy::useless_conversion)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
fn test_generic<T: Copy>(val: T) -> T {
|
||||
let _ = T::from(val);
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: useless conversion to the same type: `T`
|
||||
--> $DIR/useless_conversion.rs:6:13
|
||||
--> $DIR/useless_conversion.rs:7:13
|
||||
|
|
||||
LL | let _ = T::from(val);
|
||||
| ^^^^^^^^^^^^ help: consider removing `T::from()`: `val`
|
||||
@ -11,61 +11,61 @@ LL | #![deny(clippy::useless_conversion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: useless conversion to the same type: `T`
|
||||
--> $DIR/useless_conversion.rs:7:5
|
||||
--> $DIR/useless_conversion.rs:8:5
|
||||
|
|
||||
LL | val.into()
|
||||
| ^^^^^^^^^^ help: consider removing `.into()`: `val`
|
||||
|
||||
error: useless conversion to the same type: `i32`
|
||||
--> $DIR/useless_conversion.rs:19:22
|
||||
--> $DIR/useless_conversion.rs:20:22
|
||||
|
|
||||
LL | let _: i32 = 0i32.into();
|
||||
| ^^^^^^^^^^^ help: consider removing `.into()`: `0i32`
|
||||
|
||||
error: useless conversion to the same type: `std::string::String`
|
||||
--> $DIR/useless_conversion.rs:60:21
|
||||
--> $DIR/useless_conversion.rs:61:21
|
||||
|
|
||||
LL | let _: String = "foo".to_string().into();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()`
|
||||
|
||||
error: useless conversion to the same type: `std::string::String`
|
||||
--> $DIR/useless_conversion.rs:61:21
|
||||
--> $DIR/useless_conversion.rs:62:21
|
||||
|
|
||||
LL | let _: String = From::from("foo".to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()`
|
||||
|
||||
error: useless conversion to the same type: `std::string::String`
|
||||
--> $DIR/useless_conversion.rs:62:13
|
||||
--> $DIR/useless_conversion.rs:63:13
|
||||
|
|
||||
LL | let _ = String::from("foo".to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()`
|
||||
|
||||
error: useless conversion to the same type: `std::string::String`
|
||||
--> $DIR/useless_conversion.rs:63:13
|
||||
--> $DIR/useless_conversion.rs:64:13
|
||||
|
|
||||
LL | let _ = String::from(format!("A: {:04}", 123));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)`
|
||||
|
||||
error: useless conversion to the same type: `std::str::Lines`
|
||||
--> $DIR/useless_conversion.rs:64:13
|
||||
--> $DIR/useless_conversion.rs:65:13
|
||||
|
|
||||
LL | let _ = "".lines().into_iter();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()`
|
||||
|
||||
error: useless conversion to the same type: `std::vec::IntoIter<i32>`
|
||||
--> $DIR/useless_conversion.rs:65:13
|
||||
--> $DIR/useless_conversion.rs:66:13
|
||||
|
|
||||
LL | let _ = vec![1, 2, 3].into_iter().into_iter();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()`
|
||||
|
||||
error: useless conversion to the same type: `std::string::String`
|
||||
--> $DIR/useless_conversion.rs:66:21
|
||||
--> $DIR/useless_conversion.rs:67:21
|
||||
|
|
||||
LL | let _: String = format!("Hello {}", "world").into();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")`
|
||||
|
||||
error: useless conversion to the same type: `i32`
|
||||
--> $DIR/useless_conversion.rs:71:13
|
||||
--> $DIR/useless_conversion.rs:72:13
|
||||
|
|
||||
LL | let _ = i32::from(a + b) * 3;
|
||||
| ^^^^^^^^^^^^^^^^ help: consider removing `i32::from()`: `(a + b)`
|
||||
|
@ -4,6 +4,7 @@
|
||||
#![warn(clippy::wildcard_imports)]
|
||||
//#![allow(clippy::redundant_pub_crate)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
#![warn(unused_imports)]
|
||||
|
||||
extern crate wildcard_imports_helper;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#![warn(clippy::wildcard_imports)]
|
||||
//#![allow(clippy::redundant_pub_crate)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
#![warn(unused_imports)]
|
||||
|
||||
extern crate wildcard_imports_helper;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:11:5
|
||||
--> $DIR/wildcard_imports.rs:12:5
|
||||
|
|
||||
LL | use crate::fn_mod::*;
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo`
|
||||
@ -7,85 +7,85 @@ LL | use crate::fn_mod::*;
|
||||
= note: `-D clippy::wildcard-imports` implied by `-D warnings`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:12:5
|
||||
--> $DIR/wildcard_imports.rs:13:5
|
||||
|
|
||||
LL | use crate::mod_mod::*;
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:13:5
|
||||
--> $DIR/wildcard_imports.rs:14:5
|
||||
|
|
||||
LL | use crate::multi_fn_mod::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:15:5
|
||||
--> $DIR/wildcard_imports.rs:16:5
|
||||
|
|
||||
LL | use crate::struct_mod::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:19:5
|
||||
--> $DIR/wildcard_imports.rs:20:5
|
||||
|
|
||||
LL | use wildcard_imports_helper::inner::inner_for_self_import::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:20:5
|
||||
--> $DIR/wildcard_imports.rs:21:5
|
||||
|
|
||||
LL | use wildcard_imports_helper::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:91:13
|
||||
--> $DIR/wildcard_imports.rs:92:13
|
||||
|
|
||||
LL | use crate::fn_mod::*;
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:97:75
|
||||
--> $DIR/wildcard_imports.rs:98:75
|
||||
|
|
||||
LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *};
|
||||
| ^ help: try: `inner_extern_foo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:98:13
|
||||
--> $DIR/wildcard_imports.rs:99:13
|
||||
|
|
||||
LL | use wildcard_imports_helper::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:109:20
|
||||
--> $DIR/wildcard_imports.rs:110:20
|
||||
|
|
||||
LL | use self::{inner::*, inner2::*};
|
||||
| ^^^^^^^^ help: try: `inner::inner_foo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:109:30
|
||||
--> $DIR/wildcard_imports.rs:110:30
|
||||
|
|
||||
LL | use self::{inner::*, inner2::*};
|
||||
| ^^^^^^^^^ help: try: `inner2::inner_bar`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:116:13
|
||||
--> $DIR/wildcard_imports.rs:117:13
|
||||
|
|
||||
LL | use wildcard_imports_helper::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:145:9
|
||||
--> $DIR/wildcard_imports.rs:146:9
|
||||
|
|
||||
LL | use crate::in_fn_test::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:154:9
|
||||
--> $DIR/wildcard_imports.rs:155:9
|
||||
|
|
||||
LL | use crate:: in_fn_test:: * ;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:155:9
|
||||
--> $DIR/wildcard_imports.rs:156:9
|
||||
|
|
||||
LL | use crate:: fn_mod::
|
||||
| _________^
|
||||
@ -93,31 +93,31 @@ LL | | *;
|
||||
| |_________^ help: try: `crate:: fn_mod::foo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:166:13
|
||||
--> $DIR/wildcard_imports.rs:167:13
|
||||
|
|
||||
LL | use super::*;
|
||||
| ^^^^^^^^ help: try: `super::foofoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:201:17
|
||||
--> $DIR/wildcard_imports.rs:202:17
|
||||
|
|
||||
LL | use super::*;
|
||||
| ^^^^^^^^ help: try: `super::insidefoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:209:13
|
||||
--> $DIR/wildcard_imports.rs:210:13
|
||||
|
|
||||
LL | use super_imports::*;
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `super_imports::foofoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:218:17
|
||||
--> $DIR/wildcard_imports.rs:219:17
|
||||
|
|
||||
LL | use super::super::*;
|
||||
| ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> $DIR/wildcard_imports.rs:227:13
|
||||
--> $DIR/wildcard_imports.rs:228:13
|
||||
|
|
||||
LL | use super::super::super_imports::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo`
|
||||
|
Loading…
x
Reference in New Issue
Block a user