diff --git a/.travis.yml b/.travis.yml index 92d48101254..29879e44755 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ rust: nightly os: - linux - - osx + # - osx # doesn't even start atm. Not sure what travis is up to. Disabling to reduce the noise sudo: false diff --git a/CHANGELOG.md b/CHANGELOG.md index ffa7f89eb50..7af39eda8ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## 0.0.180 +* Rustup to *rustc 1.25.0-nightly (3f92e8d89 2018-01-14)* + ## 0.0.179 * Rustup to *rustc 1.25.0-nightly (61452e506 2018-01-09)* @@ -580,6 +583,7 @@ All notable changes to this project will be documented in this file. [`ineffective_bit_mask`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#ineffective_bit_mask [`infinite_iter`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#infinite_iter [`inline_always`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#inline_always +[`inline_fn_without_body`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#inline_fn_without_body [`int_plus_one`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#int_plus_one [`integer_arithmetic`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#integer_arithmetic [`invalid_ref`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#invalid_ref @@ -670,6 +674,7 @@ All notable changes to this project will be documented in this file. [`redundant_closure_call`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_closure_call [`redundant_pattern`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#redundant_pattern [`regex_macro`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#regex_macro +[`replace_consts`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#replace_consts [`result_map_unwrap_or_else`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#result_map_unwrap_or_else [`result_unwrap_used`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#result_unwrap_used [`reverse_range_loop`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#reverse_range_loop diff --git a/Cargo.toml b/Cargo.toml index 701c27bf26d..040cb78d1c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.179" +version = "0.0.180" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -37,13 +37,13 @@ path = "src/driver.rs" [dependencies] # begin automatic update -clippy_lints = { version = "0.0.179", path = "clippy_lints" } +clippy_lints = { version = "0.0.180", path = "clippy_lints" } # end automatic update cargo_metadata = "0.2" regex = "0.2" [dev-dependencies] -compiletest_rs = "0.3" +compiletest_rs = "0.3.5" duct = "0.8.2" lazy_static = "1.0" serde_derive = "1.0" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 2d5038abd6b..87d7c7aee66 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.179" +version = "0.0.180" # end automatic update authors = [ "Manish Goregaokar ", diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index 3ad3be181d2..293d63daaaa 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -1,6 +1,6 @@ use syntax::ast::{Item, ItemKind, Ty, TyKind}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use utils::{in_macro, span_lint_and_then}; +use utils::{in_macro, snippet, span_lint_and_then}; /// **What it does:** Checks for constants with an explicit `'static` lifetime. /// @@ -51,14 +51,15 @@ impl StaticConst { TyKind::Path(..) | TyKind::Slice(..) | TyKind::Array(..) | TyKind::Tup(..) => { if lifetime.ident.name == "'static" { - let mut sug: String = String::new(); + let snip = snippet(cx, borrow_type.ty.span, ""); + let sugg = format!("&{}", snip); span_lint_and_then( cx, CONST_STATIC_LIFETIME, lifetime.span, "Constants have by default a `'static` lifetime", |db| { - db.span_suggestion(lifetime.span, "consider removing `'static`", sug); + db.span_suggestion(ty.span, "consider removing `'static`", sugg); }, ); } diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs new file mode 100644 index 00000000000..b354fe70596 --- /dev/null +++ b/clippy_lints/src/else_if_without_else.rs @@ -0,0 +1,70 @@ +//! lint on if expressions with an else if, but without a final else branch + +use rustc::lint::*; +use syntax::ast::*; + +use utils::{in_external_macro, span_lint_and_sugg}; + +/// **What it does:** Checks for usage of if expressions with an `else if` branch, +/// but without a final `else` branch. +/// +/// **Why is this bad?** Some coding guidelines require this (e.g. MISRA-C:2004 Rule 14.10). +/// +/// **Known problems:** None. +/// +/// **Example:** +/// ```rust +/// if x.is_positive() { +/// a(); +/// } else if x.is_negative() { +/// b(); +/// } +/// ``` +/// +/// Could be written: +/// +/// ```rust +/// if x.is_positive() { +/// a(); +/// } else if x.is_negative() { +/// b(); +/// } else { +/// // we don't care about zero +/// } +/// ``` +declare_restriction_lint! { + pub ELSE_IF_WITHOUT_ELSE, + "if expression with an `else if`, but without a final `else` branch" +} + +#[derive(Copy, Clone)] +pub struct ElseIfWithoutElse; + +impl LintPass for ElseIfWithoutElse { + fn get_lints(&self) -> LintArray { + lint_array!(ELSE_IF_WITHOUT_ELSE) + } +} + +impl EarlyLintPass for ElseIfWithoutElse { + fn check_expr(&mut self, cx: &EarlyContext, mut item: &Expr) { + if in_external_macro(cx, item.span) { + return; + } + + while let ExprKind::If(_, _, Some(ref els)) = item.node { + if let ExprKind::If(_, _, None) = els.node { + span_lint_and_sugg( + cx, + ELSE_IF_WITHOUT_ELSE, + els.span, + "if expression with an `else if`, but without a final `else`", + "add an `else` block here", + "".to_string() + ); + } + + item = els; + } + } +} diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 12e5ffa0651..3df037f3329 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { use rustc::hir::map::Node::*; let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) { - matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _) | hir::ItemAutoImpl(..)) + matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _)) } else { false }; diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs new file mode 100644 index 00000000000..1bb9519d304 --- /dev/null +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -0,0 +1,65 @@ +//! checks for `#[inline]` on trait methods without bodies + +use rustc::lint::*; +use rustc::hir::*; +use syntax::ast::{Attribute, Name}; +use utils::span_lint_and_then; +use utils::sugg::DiagnosticBuilderExt; + +/// **What it does:** Checks for `#[inline]` on trait methods without bodies +/// +/// **Why is this bad?** Only implementations of trait methods may be inlined. +/// The inline attribute is ignored for trait methods without bodies. +/// +/// **Known problems:** None. +/// +/// **Example:** +/// ```rust +/// trait Animal { +/// #[inline] +/// fn name(&self) -> &'static str; +/// } +/// ``` +declare_lint! { + pub INLINE_FN_WITHOUT_BODY, + Warn, + "use of `#[inline]` on trait methods without bodies" +} + +#[derive(Copy, Clone)] +pub struct Pass; + +impl LintPass for Pass { + fn get_lints(&self) -> LintArray { + lint_array!(INLINE_FN_WITHOUT_BODY) + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { + fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { + match item.node { + TraitItemKind::Method(_, TraitMethod::Required(_)) => { + check_attrs(cx, &item.name, &item.attrs); + }, + _ => {}, + } + } +} + +fn check_attrs(cx: &LateContext, name: &Name, attrs: &[Attribute]) { + for attr in attrs { + if attr.name().map_or(true, |n| n != "inline") { + continue; + } + + span_lint_and_then( + cx, + INLINE_FN_WITHOUT_BODY, + attr.span, + &format!("use of `#[inline]` on trait method `{}` which has no body", name), + |db| { + db.suggest_remove_item(cx, attr.span, "remove"); + }, + ); + } +} diff --git a/clippy_lints/src/is_unit_expr.rs b/clippy_lints/src/is_unit_expr.rs deleted file mode 100644 index 90e2ef760f7..00000000000 --- a/clippy_lints/src/is_unit_expr.rs +++ /dev/null @@ -1,140 +0,0 @@ -use rustc::lint::*; -use syntax::ast::*; -use syntax::ext::quote::rt::Span; -use utils::{span_lint, span_note_and_lint}; - -/// **What it does:** Checks for -/// - () being assigned to a variable -/// - () being passed to a function -/// -/// **Why is this bad?** It is extremely unlikely that a user intended to -/// assign '()' to valiable. Instead, -/// Unit is what a block evaluates to when it returns nothing. This is -/// typically caused by a trailing -/// unintended semicolon. -/// -/// **Known problems:** None. -/// -/// **Example:** -/// * `let x = {"foo" ;}` when the user almost certainly intended `let x -/// ={"foo"}` -declare_lint! { - pub UNIT_EXPR, - Warn, - "unintended assignment or use of a unit typed value" -} - -#[derive(Copy, Clone)] -enum UnitCause { - SemiColon, - EmptyBlock, -} - -#[derive(Copy, Clone)] -pub struct UnitExpr; - -impl LintPass for UnitExpr { - fn get_lints(&self) -> LintArray { - lint_array!(UNIT_EXPR) - } -} - -impl EarlyLintPass for UnitExpr { - fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) { - if let ExprKind::Assign(ref _left, ref right) = expr.node { - check_for_unit(cx, right); - } - if let ExprKind::MethodCall(ref _left, ref args) = expr.node { - for arg in args { - check_for_unit(cx, arg); - } - } - if let ExprKind::Call(_, ref args) = expr.node { - for arg in args { - check_for_unit(cx, arg); - } - } - } - - fn check_stmt(&mut self, cx: &EarlyContext, stmt: &Stmt) { - if let StmtKind::Local(ref local) = stmt.node { - if local.pat.node == PatKind::Wild { - return; - } - if let Some(ref expr) = local.init { - check_for_unit(cx, expr); - } - } - } -} - -fn check_for_unit(cx: &EarlyContext, expr: &Expr) { - match is_unit_expr(expr) { - Some((span, UnitCause::SemiColon)) => span_note_and_lint( - cx, - UNIT_EXPR, - expr.span, - "This expression evaluates to the Unit type ()", - span, - "Consider removing the trailing semicolon", - ), - Some((_span, UnitCause::EmptyBlock)) => span_lint( - cx, - UNIT_EXPR, - expr.span, - "This expression evaluates to the Unit type ()", - ), - None => (), - } -} - -fn is_unit_expr(expr: &Expr) -> Option<(Span, UnitCause)> { - match expr.node { - ExprKind::Block(ref block) => match check_last_stmt_in_block(block) { - Some(UnitCause::SemiColon) => - Some((block.stmts[block.stmts.len() - 1].span, UnitCause::SemiColon)), - Some(UnitCause::EmptyBlock) => - Some((block.span, UnitCause::EmptyBlock)), - None => None - } - ExprKind::If(_, ref then, ref else_) => { - let check_then = check_last_stmt_in_block(then); - if let Some(ref else_) = *else_ { - let check_else = is_unit_expr(else_); - if let Some(ref expr_else) = check_else { - return Some(*expr_else); - } - } - match check_then { - Some(c) => Some((expr.span, c)), - None => None, - } - }, - ExprKind::Match(ref _pattern, ref arms) => { - for arm in arms { - if let Some(r) = is_unit_expr(&arm.body) { - return Some(r); - } - } - None - }, - _ => None, - } -} - -fn check_last_stmt_in_block(block: &Block) -> Option { - if block.stmts.is_empty() { return Some(UnitCause::EmptyBlock); } - let final_stmt = &block.stmts[block.stmts.len() - 1]; - - - // Made a choice here to risk false positives on divergent macro invocations - // like `panic!()` - match final_stmt.node { - StmtKind::Expr(_) => None, - StmtKind::Semi(ref expr) => match expr.node { - ExprKind::Break(_, _) | ExprKind::Continue(_) | ExprKind::Ret(_) => None, - _ => Some(UnitCause::SemiColon), - }, - _ => Some(UnitCause::SemiColon), // not sure what's happening here - } -} diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 13760e8c0fb..ee59745353b 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -88,6 +88,7 @@ pub mod derive; pub mod doc; pub mod double_parens; pub mod drop_forget_ref; +pub mod else_if_without_else; pub mod empty_enum; pub mod entry; pub mod enum_clike; @@ -108,9 +109,9 @@ pub mod identity_op; pub mod if_let_redundant_pattern_matching; pub mod if_not_else; pub mod infinite_iter; +pub mod inline_fn_without_body; pub mod int_plus_one; pub mod invalid_ref; -pub mod is_unit_expr; pub mod items_after_statements; pub mod large_enum_variant; pub mod len_zero; @@ -247,6 +248,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { "string_to_string", "using `string::to_string` is common even today and specialization will likely happen soon", ); + store.register_removed( + "unit_expr", + "superseded by `let_unit_value` and `unit_arg`", + ); // end deprecated lints, do not remove this comment, it’s used in `update_lints` reg.register_late_lint_pass(box serde_api::Serde); @@ -267,7 +272,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { reg.register_late_lint_pass(box approx_const::Pass); reg.register_late_lint_pass(box misc::Pass); reg.register_early_lint_pass(box precedence::Precedence); - reg.register_early_lint_pass(box is_unit_expr::UnitExpr); reg.register_early_lint_pass(box needless_continue::NeedlessContinue); reg.register_late_lint_pass(box eta_reduction::EtaPass); reg.register_late_lint_pass(box identity_op::IdentityOp); @@ -329,6 +333,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { reg.register_early_lint_pass(box formatting::Formatting); reg.register_late_lint_pass(box swap::Swap); reg.register_early_lint_pass(box if_not_else::IfNotElse); + reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse); reg.register_early_lint_pass(box int_plus_one::IntPlusOne); reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional); reg.register_late_lint_pass(box unused_label::UnusedLabel); @@ -357,18 +362,21 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { reg.register_late_lint_pass(box use_self::UseSelf); reg.register_late_lint_pass(box bytecount::ByteCount); reg.register_late_lint_pass(box infinite_iter::Pass); + reg.register_late_lint_pass(box inline_fn_without_body::Pass); reg.register_late_lint_pass(box invalid_ref::InvalidRef); reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default()); reg.register_late_lint_pass(box types::ImplicitHasher); reg.register_early_lint_pass(box const_static_lifetime::StaticConst); reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom); reg.register_late_lint_pass(box replace_consts::ReplaceConsts); + reg.register_late_lint_pass(box types::UnitArg); reg.register_lint_group("clippy_restrictions", vec![ arithmetic::FLOAT_ARITHMETIC, arithmetic::INTEGER_ARITHMETIC, array_indexing::INDEXING_SLICING, assign_ops::ASSIGN_OPS, + else_if_without_else::ELSE_IF_WITHOUT_ELSE, misc::FLOAT_CMP_CONST, ]); @@ -474,8 +482,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { identity_op::IDENTITY_OP, if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING, infinite_iter::INFINITE_ITER, + inline_fn_without_body::INLINE_FN_WITHOUT_BODY, invalid_ref::INVALID_REF, - is_unit_expr::UNIT_EXPR, large_enum_variant::LARGE_ENUM_VARIANT, len_zero::LEN_WITHOUT_IS_EMPTY, len_zero::LEN_ZERO, @@ -602,8 +610,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { types::IMPLICIT_HASHER, types::LET_UNIT_VALUE, types::LINKEDLIST, + types::OPTION_OPTION, types::TYPE_COMPLEXITY, types::UNIT_CMP, + types::UNIT_ARG, types::UNNECESSARY_CAST, unicode::ZERO_WIDTH_SPACE, unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME, diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 3bcaccf345a..4eeaf675c88 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -10,7 +10,9 @@ use utils::{get_arg_name, is_adjusted, iter_input_pats, match_qpath, match_trait /// **Why is this bad?** It makes the code less readable than using the /// `.cloned()` adapter. /// -/// **Known problems:** None. +/// **Known problems:** Sometimes `.cloned()` requires stricter trait +/// bound than `.map(|e| e.clone())` (which works because of the coercion). +/// See [#498](https://github.com/rust-lang-nursery/rust-clippy/issues/498). /// /// **Example:** /// ```rust diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index ea5fba8adb2..d9b61a9e5cd 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -361,9 +361,8 @@ declare_lint! { /// ```rust /// x.clone() /// ``` -declare_lint! { +declare_restriction_lint! { pub CLONE_ON_REF_PTR, - Warn, "using 'clone' on a ref-counted pointer" } @@ -1039,24 +1038,26 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t fn lint_clone_on_ref_ptr(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr) { let (obj_ty, _) = walk_ptrs_ty_depth(cx.tables.expr_ty(arg)); - let caller_type = if match_type(cx, obj_ty, &paths::RC) { - "Rc" - } else if match_type(cx, obj_ty, &paths::ARC) { - "Arc" - } else if match_type(cx, obj_ty, &paths::WEAK_RC) || match_type(cx, obj_ty, &paths::WEAK_ARC) { - "Weak" - } else { - return; - }; + if let ty::TyAdt(_, subst) = obj_ty.sty { + let caller_type = if match_type(cx, obj_ty, &paths::RC) { + "Rc" + } else if match_type(cx, obj_ty, &paths::ARC) { + "Arc" + } else if match_type(cx, obj_ty, &paths::WEAK_RC) || match_type(cx, obj_ty, &paths::WEAK_ARC) { + "Weak" + } else { + return; + }; - span_lint_and_sugg( - cx, - CLONE_ON_REF_PTR, - expr.span, - "using '.clone()' on a ref-counted pointer", - "try this", - format!("{}::clone(&{})", caller_type, snippet(cx, arg.span, "_")), - ); + span_lint_and_sugg( + cx, + CLONE_ON_REF_PTR, + expr.span, + "using '.clone()' on a ref-counted pointer", + "try this", + format!("{}::<{}>::clone(&{})", caller_type, subst.type_at(0), snippet(cx, arg.span, "_")), + ); + } } diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 2a3a4e365a5..82df78ec234 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -124,7 +124,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { let desc = match it.node { hir::ItemConst(..) => "a constant", hir::ItemEnum(..) => "an enum", - hir::ItemFn(..) => "a function", + hir::ItemFn(..) => { + // ignore main() + if it.name == "main" { + let def_id = cx.tcx.hir.local_def_id(it.id); + let def_key = cx.tcx.hir.def_key(def_id); + if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) { + return; + } + } + "a function" + }, hir::ItemMod(..) => "a module", hir::ItemStatic(..) => "a static", hir::ItemStruct(..) => "a struct", @@ -133,7 +143,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { hir::ItemGlobalAsm(..) => "an assembly blob", hir::ItemTy(..) => "a type alias", hir::ItemUnion(..) => "a union", - hir::ItemAutoImpl(..) | hir::ItemExternCrate(..) | hir::ItemForeignMod(..) | hir::ItemImpl(..) | diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index c7410d29df4..21a7542e6c7 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -6,6 +6,7 @@ use rustc::ty::{self, RegionKind, TypeFoldable}; use rustc::traits; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; +use syntax::abi::Abi; use syntax::ast::NodeId; use syntax_pos::Span; use syntax::errors::DiagnosticBuilder; @@ -71,13 +72,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { } match kind { - FnKind::ItemFn(.., attrs) => for a in attrs { - if_chain! { - if a.meta_item_list().is_some(); - if let Some(name) = a.name(); - if name == "proc_macro_derive"; - then { - return; + FnKind::ItemFn(.., abi, _, attrs) => { + if abi != Abi::Rust { + return; + } + for a in attrs { + if_chain! { + if a.meta_item_list().is_some(); + if let Some(name) = a.name(); + if name == "proc_macro_derive"; + then { + return; + } } } }, @@ -87,7 +93,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Exclude non-inherent impls if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { - if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | ItemAutoImpl(..) | + if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | ItemTrait(..)) { return; @@ -96,10 +102,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Allow `Borrow` or functions to be taken by value let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT)); - let fn_traits = [ + let whitelisted_traits = [ need!(cx.tcx.lang_items().fn_trait()), need!(cx.tcx.lang_items().fn_once_trait()), need!(cx.tcx.lang_items().fn_mut_trait()), + need!(get_trait_def_id(cx, &paths::RANGE_ARGUMENT_TRAIT)) ]; let sized_trait = need!(cx.tcx.lang_items().sized_trait()); @@ -183,7 +190,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { if !is_self(arg); if !ty.is_mutable_pointer(); if !is_copy(cx, ty); - if !fn_traits.iter().any(|&t| implements_trait(cx, ty, t, &[])); + if !whitelisted_traits.iter().any(|&t| implements_trait(cx, ty, t, &[])); if !implements_borrow_trait; if !all_borrowable_trait; @@ -196,6 +203,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Dereference suggestion let sugg = |db: &mut DiagnosticBuilder| { + if let ty::TypeVariants::TyAdt(ref def, ..) = ty.sty { + if let Some(span) = cx.tcx.hir.span_if_local(def.did) { + let param_env = ty::ParamEnv::empty(traits::Reveal::UserFacing); + if param_env.can_type_implement_copy(cx.tcx, ty, span).is_ok() { + db.span_help(span, "consider marking this type as Copy"); + } + } + } + let deref_span = spans_need_deref.get(&canonical_id); if_chain! { if match_type(cx, ty, &paths::VEC); diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index e06c571b6f6..5d56a927bc0 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -1,7 +1,7 @@ use rustc::lint::*; use syntax::ast::*; use syntax::codemap::Spanned; -use utils::{snippet, span_lint_and_sugg}; +use utils::{in_macro, snippet, span_lint_and_sugg}; /// **What it does:** Checks for operations where precedence may be unclear /// and suggests to add parentheses. Currently it catches the following: @@ -37,6 +37,10 @@ impl LintPass for Precedence { impl EarlyLintPass for Precedence { fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) { + if in_macro(expr.span) { + return; + } + if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.node { let span_sugg = |expr: &Expr, sugg| { span_lint_and_sugg( diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 7c536140f28..c7e724625be 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -50,6 +50,26 @@ declare_lint! { "usage of `Box>`, vector elements are already on the heap" } +/// **What it does:** Checks for use of `Option>` in function signatures and type +/// definitions +/// +/// **Why is this bad?** `Option<_>` represents an optional value. `Option>` +/// represents an optional optional value which is logically the same thing as an optional +/// value but has an unneeded extra level of wrapping. +/// +/// **Known problems:** None. +/// +/// **Example** +/// ```rust +/// fn x() -> Option> { +/// None +/// } +declare_lint! { + pub OPTION_OPTION, + Warn, + "usage of `Option>`" +} + /// **What it does:** Checks for usage of any `LinkedList`, suggesting to use a /// `Vec` or a `VecDeque` (formerly called `RingBuf`). /// @@ -111,7 +131,7 @@ declare_lint! { impl LintPass for TypePass { fn get_lints(&self) -> LintArray { - lint_array!(BOX_VEC, LINKEDLIST, BORROWED_BOX) + lint_array!(BOX_VEC, OPTION_OPTION, LINKEDLIST, BORROWED_BOX) } } @@ -156,6 +176,23 @@ fn check_fn_decl(cx: &LateContext, decl: &FnDecl) { } } +/// Check if `qpath` has last segment with type parameter matching `path` +fn match_type_parameter(cx: &LateContext, qpath: &QPath, path: &[&str]) -> bool { + let last = last_path_segment(qpath); + if_chain! { + if let Some(ref params) = last.parameters; + if !params.parenthesized; + if let Some(ty) = params.types.get(0); + if let TyPath(ref qpath) = ty.node; + if let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(ty.id))); + if match_def_path(cx.tcx, did, path); + then { + return true; + } + } + false +} + /// Recursively check for `TypePass` lints in the given type. Stop at the first /// lint found. /// @@ -171,24 +208,26 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) { let def = cx.tables.qpath_def(qpath, hir_id); if let Some(def_id) = opt_def_id(def) { if Some(def_id) == cx.tcx.lang_items().owned_box() { - let last = last_path_segment(qpath); - if_chain! { - if let Some(ref params) = last.parameters; - if !params.parenthesized; - if let Some(vec) = params.types.get(0); - if let TyPath(ref qpath) = vec.node; - if let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(vec.id))); - if match_def_path(cx.tcx, did, &paths::VEC); - then { - span_help_and_lint( - cx, - BOX_VEC, - ast_ty.span, - "you seem to be trying to use `Box>`. Consider using just `Vec`", - "`Vec` is already on the heap, `Box>` makes an extra allocation.", - ); - return; // don't recurse into the type - } + if match_type_parameter(cx, qpath, &paths::VEC) { + span_help_and_lint( + cx, + BOX_VEC, + ast_ty.span, + "you seem to be trying to use `Box>`. Consider using just `Vec`", + "`Vec` is already on the heap, `Box>` makes an extra allocation.", + ); + return; // don't recurse into the type + } + } else if match_def_path(cx.tcx, def_id, &paths::OPTION) { + if match_type_parameter(cx, qpath, &paths::OPTION) { + span_lint( + cx, + OPTION_OPTION, + ast_ty.span, + "consider using `Option` instead of `Option>` or a custom \ + enum if you need to distinguish all 3 cases", + ); + return; // don't recurse into the type } } else if match_def_path(cx.tcx, def_id, &paths::LINKED_LIST) { span_help_and_lint( @@ -322,25 +361,22 @@ declare_lint! { fn check_let_unit(cx: &LateContext, decl: &Decl) { if let DeclLocal(ref local) = decl.node { - match cx.tables.pat_ty(&local.pat).sty { - ty::TyTuple(slice, _) if slice.is_empty() => { - if in_external_macro(cx, decl.span) || in_macro(local.pat.span) { - return; - } - if higher::is_from_for_desugar(decl) { - return; - } - span_lint( - cx, - LET_UNIT_VALUE, - decl.span, - &format!( - "this let-binding has unit value. Consider omitting `let {} =`", - snippet(cx, local.pat.span, "..") - ), - ); - }, - _ => (), + if is_unit(cx.tables.pat_ty(&local.pat)) { + if in_external_macro(cx, decl.span) || in_macro(local.pat.span) { + return; + } + if higher::is_from_for_desugar(decl) { + return; + } + span_lint( + cx, + LET_UNIT_VALUE, + decl.span, + &format!( + "this let-binding has unit value. Consider omitting `let {} =`", + snippet(cx, local.pat.span, "..") + ), + ); } } } @@ -395,31 +431,118 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitCmp { } if let ExprBinary(ref cmp, ref left, _) = expr.node { let op = cmp.node; - if op.is_comparison() { - match cx.tables.expr_ty(left).sty { - ty::TyTuple(slice, _) if slice.is_empty() => { - let result = match op { - BiEq | BiLe | BiGe => "true", - _ => "false", - }; - span_lint( - cx, - UNIT_CMP, - expr.span, - &format!( - "{}-comparison of unit values detected. This will always be {}", - op.as_str(), - result - ), - ); - }, - _ => (), - } + if op.is_comparison() && is_unit(cx.tables.expr_ty(left)) { + let result = match op { + BiEq | BiLe | BiGe => "true", + _ => "false", + }; + span_lint( + cx, + UNIT_CMP, + expr.span, + &format!( + "{}-comparison of unit values detected. This will always be {}", + op.as_str(), + result + ), + ); } } } } +/// **What it does:** Checks for passing a unit value as an argument to a function without using a unit literal (`()`). +/// +/// **Why is this bad?** This is likely the result of an accidental semicolon. +/// +/// **Known problems:** None. +/// +/// **Example:** +/// ```rust +/// foo({ +/// let a = bar(); +/// baz(a); +/// }) +/// ``` +declare_lint! { + pub UNIT_ARG, + Warn, + "passing unit to a function" +} + +pub struct UnitArg; + +impl LintPass for UnitArg { + fn get_lints(&self) -> LintArray { + lint_array!(UNIT_ARG) + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg { + fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { + if in_macro(expr.span) { + return; + } + match expr.node { + ExprCall(_, ref args) | ExprMethodCall(_, _, ref args) => { + for arg in args { + if is_unit(cx.tables.expr_ty(arg)) && !is_unit_literal(arg) { + let map = &cx.tcx.hir; + // apparently stuff in the desugaring of `?` can trigger this + // so check for that here + // only the calls to `Try::from_error` is marked as desugared, + // so we need to check both the current Expr and its parent. + if !is_questionmark_desugar_marked_call(expr) { + if_chain!{ + let opt_parent_node = map.find(map.get_parent_node(expr.id)); + if let Some(hir::map::NodeExpr(parent_expr)) = opt_parent_node; + if is_questionmark_desugar_marked_call(parent_expr); + then {} + else { + // `expr` and `parent_expr` where _both_ not from + // desugaring `?`, so lint + span_lint_and_sugg( + cx, + UNIT_ARG, + arg.span, + "passing a unit value to a function", + "if you intended to pass a unit value, use a unit literal instead", + "()".to_string(), + ); + } + } + } + } + } + }, + _ => (), + } + } +} + +fn is_questionmark_desugar_marked_call(expr: &Expr) -> bool { + use syntax_pos::hygiene::CompilerDesugaringKind; + if let ExprCall(ref callee, _) = expr.node { + callee.span.is_compiler_desugaring(CompilerDesugaringKind::QuestionMark) + } else { + false + } +} + +fn is_unit(ty: Ty) -> bool { + match ty.sty { + ty::TyTuple(slice, _) if slice.is_empty() => true, + _ => false, + } +} + +fn is_unit_literal(expr: &Expr) -> bool { + match expr.node { + ExprTup(ref slice) if slice.is_empty() => true, + _ => false, + } +} + pub struct CastPass; /// **What it does:** Checks for casts from any numerical to a float type where @@ -1106,6 +1229,20 @@ enum AbsurdComparisonResult { } +fn is_cast_between_fixed_and_target<'a, 'tcx>( + cx: &LateContext<'a, 'tcx>, + expr: &'tcx Expr +) -> bool { + + if let ExprCast(ref cast_exp, _) = expr.node { + let precast_ty = cx.tables.expr_ty(cast_exp); + let cast_ty = cx.tables.expr_ty(expr); + + return is_isize_or_usize(precast_ty) != is_isize_or_usize(cast_ty) + } + + return false; +} fn detect_absurd_comparison<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, @@ -1123,6 +1260,11 @@ fn detect_absurd_comparison<'a, 'tcx>( return None; } + // comparisons between fix sized types and target sized types are considered unanalyzable + if is_cast_between_fixed_and_target(cx, lhs) || is_cast_between_fixed_and_target(cx, rhs) { + return None; + } + let normalized = normalize_comparison(op, lhs, rhs); let (rel, normalized_lhs, normalized_rhs) = if let Some(val) = normalized { val diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index fa6681ef078..9ade2778e0c 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -406,9 +406,6 @@ fn print_item(cx: &LateContext, item: &hir::Item) { hir::ItemTraitAlias(..) => { println!("trait alias"); } - hir::ItemAutoImpl(_, ref _trait_ref) => { - println!("auto impl"); - }, hir::ItemImpl(_, _, _, _, Some(ref _trait_ref), _, _) => { println!("trait impl"); }, diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs index 95e14609182..20244a19f4f 100644 --- a/clippy_lints/src/utils/paths.rs +++ b/clippy_lints/src/utils/paths.rs @@ -55,6 +55,7 @@ pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"]; pub const PTR_NULL: [&str; 2] = ["ptr", "null"]; pub const PTR_NULL_MUT: [&str; 2] = ["ptr", "null_mut"]; pub const RANGE: [&str; 3] = ["core", "ops", "Range"]; +pub const RANGE_ARGUMENT_TRAIT: [&str; 3] = ["alloc", "range", "RangeArgument"]; pub const RANGE_FROM: [&str; 3] = ["core", "ops", "RangeFrom"]; pub const RANGE_FROM_STD: [&str; 3] = ["std", "ops", "RangeFrom"]; pub const RANGE_FULL: [&str; 3] = ["core", "ops", "RangeFull"]; diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index c680e3eeb5b..2f651917bc1 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -15,6 +15,7 @@ use syntax::print::pprust::token_to_string; use syntax::util::parser::AssocOp; use syntax::ast; use utils::{higher, snippet, snippet_opt}; +use syntax_pos::{BytePos, Pos}; /// A helper type to build suggestion correctly handling parenthesis. pub enum Sugg<'a> { @@ -454,6 +455,19 @@ pub trait DiagnosticBuilderExt<'a, T: LintContext<'a>> { /// }"); /// ``` fn suggest_prepend_item(&mut self, cx: &T, item: Span, msg: &str, new_item: &str); + + /// Suggest to completely remove an item. + /// + /// This will remove an item and all following whitespace until the next non-whitespace + /// character. This should work correctly if item is on the same indentation level as the + /// following item. + /// + /// # Example + /// + /// ```rust,ignore + /// db.suggest_remove_item(cx, item, "remove this") + /// ``` + fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str); } impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_errors::DiagnosticBuilder<'b> { @@ -485,4 +499,21 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error self.span_suggestion(span, msg, format!("{}\n{}", new_item, indent)); } } + + fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str) { + let mut remove_span = item; + let fmpos = cx.sess() + .codemap() + .lookup_byte_offset(remove_span.next_point().hi()); + + if let Some(ref src) = fmpos.fm.src { + let non_whitespace_offset = src[fmpos.pos.to_usize()..].find(|c| c != ' ' && c != '\t' && c != '\n'); + + if let Some(non_whitespace_offset) = non_whitespace_offset { + remove_span = remove_span.with_hi(remove_span.hi() + BytePos(non_whitespace_offset as u32)) + } + } + + self.span_suggestion(remove_span, msg, String::new()); + } } diff --git a/main b/main new file mode 100755 index 00000000000..c5f9f914d33 Binary files /dev/null and b/main differ diff --git a/src/driver.rs b/src/driver.rs index 090e69cf027..bc766496cfb 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -12,7 +12,7 @@ extern crate rustc_plugin; extern crate syntax; use rustc_driver::{driver, Compilation, CompilerCalls, RustcDefaultCalls}; -use rustc::session::{config, CompileIncomplete, Session}; +use rustc::session::{config, Session}; use rustc::session::config::{ErrorOutputType, Input}; use std::path::PathBuf; use std::process::Command; @@ -153,47 +153,44 @@ pub fn main() { }) .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); - rustc_driver::in_rustc_thread(|| { - // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. - // We're invoking the compiler programmatically, so we ignore this/ - let mut orig_args: Vec = env::args().collect(); - if orig_args.len() <= 1 { - std::process::exit(1); - } - if orig_args[1] == "rustc" { - // we still want to be able to invoke it normally though - orig_args.remove(1); - } - // this conditional check for the --sysroot flag is there so users can call - // `clippy_driver` directly - // without having to pass --sysroot or anything - let mut args: Vec = if orig_args.iter().any(|s| s == "--sysroot") { - orig_args.clone() - } else { - orig_args - .clone() - .into_iter() - .chain(Some("--sysroot".to_owned())) - .chain(Some(sys_root)) - .collect() - }; + // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. + // We're invoking the compiler programmatically, so we ignore this/ + let mut orig_args: Vec = env::args().collect(); + if orig_args.len() <= 1 { + std::process::exit(1); + } + if orig_args[1] == "rustc" { + // we still want to be able to invoke it normally though + orig_args.remove(1); + } + // this conditional check for the --sysroot flag is there so users can call + // `clippy_driver` directly + // without having to pass --sysroot or anything + let mut args: Vec = if orig_args.iter().any(|s| s == "--sysroot") { + orig_args.clone() + } else { + orig_args + .clone() + .into_iter() + .chain(Some("--sysroot".to_owned())) + .chain(Some(sys_root)) + .collect() + }; - // this check ensures that dependencies are built but not linted and the final - // crate is - // linted but not built - let clippy_enabled = env::var("CLIPPY_TESTS") - .ok() - .map_or(false, |val| val == "true") - || orig_args.iter().any(|s| s == "--emit=metadata"); + // this check ensures that dependencies are built but not linted and the final + // crate is + // linted but not built + let clippy_enabled = env::var("CLIPPY_TESTS") + .ok() + .map_or(false, |val| val == "true") + || orig_args.iter().any(|s| s == "--emit=metadata"); - if clippy_enabled { - args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]); - } + if clippy_enabled { + args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]); + } - let mut ccc = ClippyCompilerCalls::new(clippy_enabled); - let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None); - if let Err(CompileIncomplete::Errored(_)) = result { - std::process::exit(1); - } - }).expect("rustc_thread failed"); + let mut ccc = ClippyCompilerCalls::new(clippy_enabled); + rustc_driver::run(move || { + rustc_driver::run_compiler(&args, &mut ccc, None, None) + }); } diff --git a/tests/compile-test.rs b/tests/compile-test.rs index d532d4e5a59..2b0fea0f8b9 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -46,7 +46,9 @@ fn config(dir: &'static str, mode: &'static str) -> compiletest::Config { config.target_rustcflags = Some(format!("-L {0} -L {0}/deps -Dwarnings", host_libs().display())); config.mode = cfg_mode; - config.build_base = { + config.build_base = if rustc_test_suite().is_some() { + PathBuf::from("/tmp/clippy_test_build_base") + } else { let mut path = std::env::current_dir().unwrap(); path.push("target/debug/test_build_base"); path diff --git a/tests/dogfood.rs b/tests/dogfood.rs index 1514383e6de..8ca9b5c92a4 100644 --- a/tests/dogfood.rs +++ b/tests/dogfood.rs @@ -1,5 +1,8 @@ #[test] fn dogfood() { + if option_env!("RUSTC_TEST_SUITE").is_some() { + return; + } let root_dir = std::env::current_dir().unwrap(); for d in &[".", "clippy_lints"] { std::env::set_current_dir(root_dir.join(d)).unwrap(); diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index 1f88d94bd2b..8c036e6c072 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -50,3 +50,8 @@ impl PartialOrd for U { pub fn foo(val: U) -> bool { val > std::u32::MAX } + +pub fn bar(len: u64) -> bool { + // This is OK as we are casting from target sized to fixed size + len >= std::usize::MAX as u64 +} diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index a4b8839797c..2b1e9ad66fe 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -143,3 +143,5 @@ error: <-comparison of unit values detected. This will always be false | = note: `-D unit-cmp` implied by `-D warnings` +error: aborting due to 18 previous errors + diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index f102dc5b5dc..dda28433d7a 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -114,3 +114,5 @@ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it 55 | let my_sq2 = 1.4142; | ^^^^^^ +error: aborting due to 19 previous errors + diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index ea32a005219..ad4a02e2190 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -69,3 +69,5 @@ error: floating-point arithmetic detected 29 | -f; | ^^ +error: aborting due to 11 previous errors + diff --git a/tests/ui/array_indexing.stderr b/tests/ui/array_indexing.stderr index dd11247243c..d730b012932 100644 --- a/tests/ui/array_indexing.stderr +++ b/tests/ui/array_indexing.stderr @@ -116,3 +116,5 @@ error: range is out of bounds 44 | &empty[..4]; | ^^^^^^^^^^ +error: aborting due to 19 previous errors + diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index c1cc5d24426..2123507e2ef 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -134,3 +134,5 @@ error: manual implementation of an assign operation 40 | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` +error: aborting due to 22 previous errors + diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 47528c315d4..0ff211259c0 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -48,3 +48,5 @@ error: variable appears on both sides of an assignment operation 15 | a &= a & 1; | ^^^^^^^^^^ help: replace it with: `a &= 1` +error: aborting due to 8 previous errors + diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index 9e4ac3d1283..f743399a606 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -20,3 +20,5 @@ error: the since field must contain a semver-compliant version 30 | #[deprecated(since = "1")] | ^^^^^^^^^^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index 39320bb9c30..6aad98ff528 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -106,3 +106,5 @@ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared 55 | x | 1 >= 8; | ^^^^^^^^^^ +error: aborting due to 17 previous errors + diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index a08a5326894..68fbe27a01e 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -84,3 +84,5 @@ error: use of a blacklisted/placeholder name `baz` 35 | if let Some(ref mut baz) = Some(42) {} | ^^^ +error: aborting due to 14 previous errors + diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index 86a289c19a8..4b7d12598ec 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -50,3 +50,5 @@ error: this boolean expression can be simplified | = note: `-D nonminimal-bool` implied by `-D warnings` +error: aborting due to 5 previous errors + diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index e5e062e0246..4436980bc11 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -24,3 +24,5 @@ error: equality checks against false can be replaced by a negation 10 | if false == x { "yes" } else { "no" }; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` +error: aborting due to 4 previous errors + diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index 6367ba0348c..c88a7a7be60 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -175,3 +175,5 @@ error: this boolean expression can be simplified 58 | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `!c ^ c || a.is_none()` +error: aborting due to 21 previous errors + diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 74134f4f2b1..2cf0ea79626 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -28,3 +28,5 @@ error: you seem to be trying to use `&Box`. Consider using just `&T` 22 | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` +error: aborting due to 4 previous errors + diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index c1badd0dc9b..254d0771386 100644 --- a/tests/ui/box_vec.stderr +++ b/tests/ui/box_vec.stderr @@ -7,3 +7,5 @@ error: you seem to be trying to use `Box>`. Consider using just `Vec` = note: `-D box-vec` implied by `-D warnings` = help: `Vec` is already on the heap, `Box>` makes an extra allocation. +error: aborting due to previous error + diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 058813356cd..eb4c73b65c6 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -17,3 +17,5 @@ error[E0308]: mismatched types = note: expected type `u32` found type `{integer}` +error: aborting due to 2 previous errors + diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index c4f6b65a21e..307edecfde1 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -22,3 +22,5 @@ error: You appear to be counting bytes the naive way 22 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)` +error: aborting due to 3 previous errors + diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index ac409a813cc..0a008cb68bb 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -178,3 +178,5 @@ error: casting to the same type is unnecessary (`bool` -> `bool`) 39 | false as bool; | ^^^^^^^^^^^^^ +error: aborting due to 28 previous errors + diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 781d9c89767..a60f838fae8 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -60,3 +60,5 @@ error: casting u32 to f64 may become silently lossy if types change 14 | 1u32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u32)` +error: aborting due to 10 previous errors + diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index fdd915979e4..19d6176193c 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -108,3 +108,5 @@ error: casting u32 to u64 may become silently lossy if types change 23 | 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` +error: aborting due to 18 previous errors + diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index a6aac1300a3..1c4b12bcebf 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -120,3 +120,5 @@ error: casting i32 to usize may lose the sign of the value 22 | 1i32 as usize; | ^^^^^^^^^^^^^ +error: aborting due to 19 previous errors + diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index 4e7c1866a9a..fcf038fe002 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -8,3 +8,5 @@ error: casting character literal to u8. `char`s are 4 bytes wide in rust, so cas = help: Consider using a byte literal instead: b'a' +error: aborting due to previous error + diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index 9ea1a29d29d..46f3d3d57e0 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -72,3 +72,5 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead 21 | y >= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ +error: aborting due to 12 previous errors + diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 51c0ceea4b1..481a4d0f942 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -12,3 +12,5 @@ error: Comparing with null is better expressed by the .is_null() method 16 | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index e6996244664..d40fb4b8add 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -36,3 +36,5 @@ error: this creates an owned instance just for comparison 30 | self.to_owned() == *other | ^^^^^^^^^^^^^^^ try calling implementing the comparison without allocating +error: aborting due to 6 previous errors + diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index bc10afcedb3..69f2013c1dc 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -240,3 +240,5 @@ help: try 112 | } | +error: aborting due to 13 previous errors + diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index 8ce63652f0b..829a22c233f 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -90,3 +90,5 @@ error: very complex type used. Consider factoring parts into `type` definitions 40 | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 15 previous errors + diff --git a/tests/ui/conf_bad_arg.stderr b/tests/ui/conf_bad_arg.stderr index d91729039b1..bc44cebdbbb 100644 --- a/tests/ui/conf_bad_arg.stderr +++ b/tests/ui/conf_bad_arg.stderr @@ -1,4 +1,4 @@ -error: compiler plugins are experimental and possibly buggy (see issue #29597) +error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597) --> $DIR/conf_bad_arg.rs:4:1 | 4 | #![plugin(clippy(conf_file))] @@ -6,3 +6,5 @@ error: compiler plugins are experimental and possibly buggy (see issue #29597) | = help: add #![feature(plugin)] to the crate attributes to enable +error: aborting due to previous error + diff --git a/tests/ui/conf_bad_toml.stderr b/tests/ui/conf_bad_toml.stderr index 45477ff0855..d4236926522 100644 --- a/tests/ui/conf_bad_toml.stderr +++ b/tests/ui/conf_bad_toml.stderr @@ -1,4 +1,4 @@ -error: compiler plugins are experimental and possibly buggy (see issue #29597) +error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597) --> $DIR/conf_bad_toml.rs:4:1 | 4 | #![plugin(clippy(conf_file="../ui/conf_bad_toml.toml"))] @@ -6,3 +6,5 @@ error: compiler plugins are experimental and possibly buggy (see issue #29597) | = help: add #![feature(plugin)] to the crate attributes to enable +error: aborting due to previous error + diff --git a/tests/ui/conf_bad_type.stderr b/tests/ui/conf_bad_type.stderr index 0fa40cfca9b..440437d140e 100644 --- a/tests/ui/conf_bad_type.stderr +++ b/tests/ui/conf_bad_type.stderr @@ -1,4 +1,4 @@ -error: compiler plugins are experimental and possibly buggy (see issue #29597) +error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597) --> $DIR/conf_bad_type.rs:4:1 | 4 | #![plugin(clippy(conf_file="../ui/conf_bad_type.toml"))] @@ -6,3 +6,5 @@ error: compiler plugins are experimental and possibly buggy (see issue #29597) | = help: add #![feature(plugin)] to the crate attributes to enable +error: aborting due to previous error + diff --git a/tests/ui/conf_french_blacklisted_name.stderr b/tests/ui/conf_french_blacklisted_name.stderr index f7eb174f9a6..19c8e5c9777 100644 --- a/tests/ui/conf_french_blacklisted_name.stderr +++ b/tests/ui/conf_french_blacklisted_name.stderr @@ -1,4 +1,4 @@ -error: compiler plugins are experimental and possibly buggy (see issue #29597) +error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597) --> $DIR/conf_french_blacklisted_name.rs:2:1 | 2 | #![plugin(clippy(conf_file="../auxiliary/conf_french_blacklisted_name.toml"))] @@ -6,3 +6,5 @@ error: compiler plugins are experimental and possibly buggy (see issue #29597) | = help: add #![feature(plugin)] to the crate attributes to enable +error: aborting due to previous error + diff --git a/tests/ui/conf_path_non_string.stderr b/tests/ui/conf_path_non_string.stderr index 4b15b5d0e17..7a0aebb572e 100644 --- a/tests/ui/conf_path_non_string.stderr +++ b/tests/ui/conf_path_non_string.stderr @@ -1,4 +1,4 @@ -error: compiler plugins are experimental and possibly buggy (see issue #29597) +error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597) --> $DIR/conf_path_non_string.rs:3:1 | 3 | #![plugin(clippy(conf_file=42))] @@ -6,3 +6,5 @@ error: compiler plugins are experimental and possibly buggy (see issue #29597) | = help: add #![feature(plugin)] to the crate attributes to enable +error: aborting due to previous error + diff --git a/tests/ui/conf_unknown_key.stderr b/tests/ui/conf_unknown_key.stderr index c525366c129..d1957c311ad 100644 --- a/tests/ui/conf_unknown_key.stderr +++ b/tests/ui/conf_unknown_key.stderr @@ -1,4 +1,4 @@ -error: compiler plugins are experimental and possibly buggy (see issue #29597) +error[E0658]: compiler plugins are experimental and possibly buggy (see issue #29597) --> $DIR/conf_unknown_key.rs:4:1 | 4 | #![plugin(clippy(conf_file="../auxiliary/conf_unknown_key.toml"))] @@ -6,3 +6,5 @@ error: compiler plugins are experimental and possibly buggy (see issue #29597) | = help: add #![feature(plugin)] to the crate attributes to enable +error: aborting due to previous error + diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index d4558f7b241..db33744c7a9 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -2,7 +2,7 @@ error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:4:17 | 4 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&str` | = note: `-D const-static-lifetime` implied by `-D warnings` @@ -10,71 +10,73 @@ error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:8:21 | 8 | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:10:32 | 10 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:10:47 | 10 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:12:18 | 12 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:12:30 | 12 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:14:17 | 14 | const VAR_SIX: &'static u8 = &5; - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^--- help: consider removing `'static`: `&u8` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:16:29 | 16 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:16:39 | 16 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:18:20 | 18 | const VAR_HEIGHT: &'static Foo = &Foo {}; - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:20:19 | 20 | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:22:19 | 22 | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:24:19 | 24 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. - | ^^^^^^^ help: consider removing `'static` + | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` + +error: aborting due to 13 previous errors diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index 4457e2b7d73..9accb310d12 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -33,3 +33,5 @@ error: This else block is redundant. } +error: aborting due to 2 previous errors + diff --git a/tests/ui/cstring.stderr b/tests/ui/cstring.stderr index c3dd9cf83f6..973f26a96db 100644 --- a/tests/ui/cstring.stderr +++ b/tests/ui/cstring.stderr @@ -12,3 +12,5 @@ help: assign the `CString` to a variable to extend its lifetime 7 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to previous error + diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index 62fd5313ccb..43676762d6c 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -269,3 +269,5 @@ error: the function has a cyclomatic complexity of 8 | = help: you could split it up into multiple smaller functions +error: aborting due to 20 previous errors + diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index a9cefe93e32..e671b34393b 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -13,3 +13,5 @@ error: the function has a cyclomatic complexity of 3 = note: `-D cyclomatic-complexity` implied by `-D warnings` = help: you could split it up into multiple smaller functions +error: aborting due to previous error + diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index 4255959675a..7d5d594cfa1 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -24,3 +24,5 @@ error: lint unstable_as_mut_slice has been removed: `Vec::as_mut_slice` has been 10 | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 4 previous errors + diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index f336dc3a8e1..ffeed948ba5 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -106,3 +106,5 @@ note: consider deriving `Clone` or removing `Copy` 87 | | } | |_^ +error: aborting due to 7 previous errors + diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index b39d1ae07e5..0d7b1ca6fd6 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -36,3 +36,5 @@ error: sub-expression diverges 37 | _ => true || break, | ^^^^^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index 95872c02994..de0422e17ed 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -47,3 +47,5 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct | = help: a VecDeque might work +error: aborting due to 6 previous errors + diff --git a/tests/ui/doc.stderr b/tests/ui/doc.stderr index fc036d01b86..f38678e89aa 100644 --- a/tests/ui/doc.stderr +++ b/tests/ui/doc.stderr @@ -180,3 +180,5 @@ error: you should put bare URLs between `<`/`>` or make a proper Markdown link 168 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 30 previous errors + diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index 8c64eb37e15..fd4da8820a2 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -6,3 +6,5 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usual | = note: `-D double-neg` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index ab3e844d7a7..a77b08528c4 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -30,3 +30,5 @@ error: Consider removing unnecessary double parentheses 32 | (()) | ^^^^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index f399c5a125f..3ea7bf9735a 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -72,3 +72,5 @@ note: argument has type SomeStruct 42 | forget(s4); | ^^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 6058b89c70f..1654fdd2861 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -216,3 +216,5 @@ note: argument has type &SomeStruct 59 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ +error: aborting due to 18 previous errors + diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index de9e6f1e056..c926f57f154 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -6,3 +6,5 @@ error: `darth` already exists, having another argument having almost the same na | = note: `-D duplicate-underscore-argument` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/else_if_without_else.rs b/tests/ui/else_if_without_else.rs new file mode 100644 index 00000000000..4f019819eff --- /dev/null +++ b/tests/ui/else_if_without_else.rs @@ -0,0 +1,50 @@ +#![warn(clippy)] +#![warn(else_if_without_else)] + +fn bla1() -> bool { unimplemented!() } +fn bla2() -> bool { unimplemented!() } +fn bla3() -> bool { unimplemented!() } + +fn main() { + if bla1() { + println!("if"); + } + + if bla1() { + println!("if"); + } else { + println!("else"); + } + + if bla1() { + println!("if"); + } else if bla2() { + println!("else if"); + } else { + println!("else") + } + + if bla1() { + println!("if"); + } else if bla2() { + println!("else if 1"); + } else if bla3() { + println!("else if 2"); + } else { + println!("else") + } + + if bla1() { + println!("if"); + } else if bla2() { //~ ERROR else if without else + println!("else if"); + } + + if bla1() { + println!("if"); + } else if bla2() { + println!("else if 1"); + } else if bla3() { //~ ERROR else if without else + println!("else if 2"); + } +} diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr new file mode 100644 index 00000000000..b8a5031fbcf --- /dev/null +++ b/tests/ui/else_if_without_else.stderr @@ -0,0 +1,22 @@ +error: if expression with an `else if`, but without a final `else` + --> $DIR/else_if_without_else.rs:39:12 + | +39 | } else if bla2() { //~ ERROR else if without else + | ____________^ +40 | | println!("else if"); +41 | | } + | |_____^ help: add an `else` block here + | + = note: `-D else-if-without-else` implied by `-D warnings` + +error: if expression with an `else if`, but without a final `else` + --> $DIR/else_if_without_else.rs:47:12 + | +47 | } else if bla3() { //~ ERROR else if without else + | ____________^ +48 | | println!("else if 2"); +49 | | } + | |_____^ help: add an `else` block here + +error: aborting due to 2 previous errors + diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index a0d491b6f96..ca377cee822 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -11,3 +11,5 @@ help: consider using the uninhabited type `!` or a wrapper around it 7 | enum Empty {} | ^^^^^^^^^^^^^ +error: aborting due to previous error + diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index e60c158d7c0..09c4a882280 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -42,3 +42,5 @@ error: usage of `contains_key` followed by `insert` on a `BTreeMap` 37 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +error: aborting due to 7 previous errors + diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 1e0fffb9ac4..2d53618c1b1 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -12,3 +12,5 @@ error: don't use glob imports for enum variants 12 | use self::Enum::*; | ^^^^^^^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 7e2716b8ea2..e33e29ec78e 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -97,3 +97,5 @@ error: All variants have the same prefix: `With` = note: `-D pub-enum-variant-names` implied by `-D warnings` = help: remove the prefixes and use full paths to the variants instead of glob imports +error: aborting due to 10 previous errors + diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index e0555bb0239..d6a137c6fe4 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -48,3 +48,5 @@ error: Clike enum variant discriminant is not portable to 32-bit targets 37 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ +error: aborting due to 8 previous errors + diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index 914a85719d0..46c0ac108cd 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -204,3 +204,5 @@ error: taken reference of right operand | = note: `-D op-ref` implied by `-D warnings` +error: aborting due to 33 previous errors + diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 8a05d2c251d..310c41c541b 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -18,3 +18,5 @@ error: this operation will always return zero. This is likely not the intended o 11 | 0 / x; | ^^^^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 34a6217cd70..5dca265c2a4 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -32,3 +32,5 @@ error: redundant closure found 18 | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` +error: aborting due to 5 previous errors + diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index e9bdc3b51d9..2e01a167c01 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -47,3 +47,5 @@ note: whether read occurs before this write depends on evaluation order 21 | x += { x = 20; 2 }; | ^^^^^^ +error: aborting due to 4 previous errors + diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index 9a813e89793..7a2a0c66f23 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -36,3 +36,5 @@ error: use of `stderr().write_fmt(...).unwrap()`. Consider using `eprint!` inste 21 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 8e93966ccd1..c8af77ecab3 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -89,3 +89,5 @@ note: potential failure(s) | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +error: aborting due to 4 previous errors + diff --git a/tests/ui/filter_methods.stderr b/tests/ui/filter_methods.stderr index 8f1853c3952..cec03a47bfd 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -36,3 +36,5 @@ error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly e 25 | | .map(|x| x.checked_mul(2)) | |__________________________________________________________^ +error: aborting due to 4 previous errors + diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index d2903f501f5..a764403d039 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -95,3 +95,5 @@ note: std::f32::EPSILON and std::f64::EPSILON are available. 57 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 8 previous errors + diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index fe277de28dd..6367ec73c96 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -83,3 +83,5 @@ note: std::f32::EPSILON and std::f64::EPSILON are available. 25 | v != ONE; | ^^^^^^^^ +error: aborting due to 7 previous errors + diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index b09350970fc..1e7ff40e1ac 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -565,3 +565,5 @@ error: it looks like you're manually copying between slices 549 | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` +error: aborting due to 59 previous errors + diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index 558e9e83c33..5f5bdc02a59 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -6,3 +6,5 @@ error: useless use of `format!` | = note: `-D useless-format` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index d121929d0c2..266de262ea0 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -86,3 +86,5 @@ error: possibly missing a comma here | = note: to remove this lint, add a comma or write the expr in a single line +error: aborting due to 10 previous errors + diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index c8b4db35245..0a97748954f 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -75,3 +75,5 @@ error: this public function dereferences a raw pointer but is not marked `unsafe 63 | unsafe { std::ptr::read(p) }; | ^ +error: aborting due to 12 previous errors + diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index 3724cbfc852..b5ada862531 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -60,3 +60,5 @@ error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and 40 | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vecdeque[0]` +error: aborting due to 10 previous errors + diff --git a/tests/ui/identity_conversion.stderr b/tests/ui/identity_conversion.stderr index 152bb8882bd..1ae3f229dd8 100644 --- a/tests/ui/identity_conversion.stderr +++ b/tests/ui/identity_conversion.stderr @@ -40,3 +40,5 @@ error: identical conversion 39 | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` +error: aborting due to 6 previous errors + diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index c1ce8d2ec4c..45f579ce832 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -48,3 +48,5 @@ error: the operation is ineffective. Consider reducing it to `u` 32 | u & 255; | ^^^^^^^ +error: aborting due to 8 previous errors + diff --git a/tests/ui/if_let_redundant_pattern_matching.stderr b/tests/ui/if_let_redundant_pattern_matching.stderr index b15d17e372e..e7bfd0275d8 100644 --- a/tests/ui/if_let_redundant_pattern_matching.stderr +++ b/tests/ui/if_let_redundant_pattern_matching.stderr @@ -24,3 +24,5 @@ error: redundant pattern matching, consider using `is_some()` 17 | if let Some(_) = Some(42) { | -------^^^^^^^----------- help: try this: `if Some(42).is_some()` +error: aborting due to 4 previous errors + diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index f9462f422ea..b920ef3b625 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -23,3 +23,5 @@ error: Unnecessary `!=` operation | = help: change to `==` and swap the blocks of the if/else +error: aborting due to 2 previous errors + diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index aaa1e37ca82..cdba5372b3c 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -133,3 +133,5 @@ help: consider adding a type parameter 78 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { | +error: aborting due to 10 previous errors + diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index 2725d5f4ef7..12d9e3cf0fd 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -39,3 +39,5 @@ error: digits grouped inconsistently by underscores | = help: consider: 1.234_567_8_f32 +error: aborting due to 5 previous errors + diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index 87b7ca49322..f79db778488 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -96,3 +96,5 @@ error: possible infinite iteration detected 30 | (0..).all(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 14 previous errors + diff --git a/tests/ui/inline_fn_without_body.rs b/tests/ui/inline_fn_without_body.rs new file mode 100644 index 00000000000..82e073184d3 --- /dev/null +++ b/tests/ui/inline_fn_without_body.rs @@ -0,0 +1,23 @@ + + + +#![warn(inline_fn_without_body)] +#![allow(inline_always)] + +trait Foo { + #[inline] + fn default_inline(); + + #[inline(always)]fn always_inline(); + + #[inline(never)] + + fn never_inline(); + + #[inline] + fn has_body() { + } +} + +fn main() { +} diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr new file mode 100644 index 00000000000..fd26013d11e --- /dev/null +++ b/tests/ui/inline_fn_without_body.stderr @@ -0,0 +1,27 @@ +error: use of `#[inline]` on trait method `default_inline` which has no body + --> $DIR/inline_fn_without_body.rs:8:5 + | +8 | #[inline] + | _____-^^^^^^^^ +9 | | fn default_inline(); + | |____- help: remove + | + = note: `-D inline-fn-without-body` implied by `-D warnings` + +error: use of `#[inline]` on trait method `always_inline` which has no body + --> $DIR/inline_fn_without_body.rs:11:5 + | +11 | #[inline(always)]fn always_inline(); + | ^^^^^^^^^^^^^^^^^ help: remove + +error: use of `#[inline]` on trait method `never_inline` which has no body + --> $DIR/inline_fn_without_body.rs:13:5 + | +13 | #[inline(never)] + | _____-^^^^^^^^^^^^^^^ +14 | | +15 | | fn never_inline(); + | |____- help: remove + +error: aborting due to 3 previous errors + diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 69a8621fb16..deecaffa1cf 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -40,3 +40,5 @@ help: change `>= y + 1` to `> y` as shown 14 | y < x; | ^^^^^ +error: aborting due to 4 previous errors + diff --git a/tests/ui/invalid_ref.stderr b/tests/ui/invalid_ref.stderr index c018bdf6dd3..420fed01744 100644 --- a/tests/ui/invalid_ref.stderr +++ b/tests/ui/invalid_ref.stderr @@ -47,3 +47,5 @@ error: reference to uninitialized memory | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html +error: aborting due to 6 previous errors + diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index 3f11c373074..eb46802899e 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -162,3 +162,5 @@ error: because of the numeric bounds on `u8` prior to casting, this expression i 78 | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ +error: aborting due to 27 previous errors + diff --git a/tests/ui/is_unit_expr.rs b/tests/ui/is_unit_expr.rs deleted file mode 100644 index 6c8f108d9f6..00000000000 --- a/tests/ui/is_unit_expr.rs +++ /dev/null @@ -1,79 +0,0 @@ - - -#![warn(unit_expr)] -#[allow(unused_variables)] - -fn main() { - // lint should note removing the semicolon from "baz" - let x = { - "foo"; - "baz"; - }; - - - // lint should ignore false positive. - let y = if true { - "foo" - } else { - return; - }; - - // lint should note removing semicolon from "bar" - let z = if true { - "foo"; - } else { - "bar"; - }; - - - let a1 = Some(5); - - // lint should ignore false positive - let a2 = match a1 { - Some(x) => x, - _ => { - return; - }, - }; - - // lint should note removing the semicolon after `x;` - let a3 = match a1 { - Some(x) => { - x; - }, - _ => { - 0; - }, - }; - - loop { - let a2 = match a1 { - Some(x) => x, - _ => { - break; - }, - }; - let a2 = match a1 { - Some(x) => x, - _ => { - continue; - }, - }; - } -} - -pub fn foo() -> i32 { - let a2 = match None { - Some(x) => x, - _ => { - return 42; - }, - }; - 55 -} - -pub fn issue_2160() { - let x1 = {}; - let x2 = if true {} else {}; - let x3 = match None { Some(_) => {}, None => {}, }; -} diff --git a/tests/ui/is_unit_expr.stderr b/tests/ui/is_unit_expr.stderr deleted file mode 100644 index 64a7ad86b70..00000000000 --- a/tests/ui/is_unit_expr.stderr +++ /dev/null @@ -1,71 +0,0 @@ -error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:8:13 - | -8 | let x = { - | _____________^ -9 | | "foo"; -10 | | "baz"; -11 | | }; - | |_____^ - | - = note: `-D unit-expr` implied by `-D warnings` -note: Consider removing the trailing semicolon - --> $DIR/is_unit_expr.rs:10:9 - | -10 | "baz"; - | ^^^^^^ - -error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:22:13 - | -22 | let z = if true { - | _____________^ -23 | | "foo"; -24 | | } else { -25 | | "bar"; -26 | | }; - | |_____^ - | -note: Consider removing the trailing semicolon - --> $DIR/is_unit_expr.rs:25:9 - | -25 | "bar"; - | ^^^^^^ - -error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:40:14 - | -40 | let a3 = match a1 { - | ______________^ -41 | | Some(x) => { -42 | | x; -43 | | }, -... | -46 | | }, -47 | | }; - | |_____^ - | -note: Consider removing the trailing semicolon - --> $DIR/is_unit_expr.rs:42:13 - | -42 | x; - | ^^ - -error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:76:14 - | -76 | let x1 = {}; - | ^^ - -error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:77:14 - | -77 | let x2 = if true {} else {}; - | ^^^^^^^^^^^^^^^^^^ - -error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:78:14 - | -78 | let x3 = match None { Some(_) => {}, None => {}, }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index e98e7ee129d..ec1296caf83 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -12,3 +12,5 @@ error: adding items after statements is confusing, since items exist from the st 17 | fn foo() { println!("foo"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index db49ded1d8a..6fc285274a0 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -47,3 +47,5 @@ error: digit groups should be smaller | = help: consider: 123_456.123_456_f32 +error: aborting due to 6 previous errors + diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 5c6aac7d4ee..5e938337bc0 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -66,3 +66,5 @@ help: consider boxing the large fields to reduce the total size of the enum 49 | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ^^^^^^^^^^^^^^^^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index d23a972dddc..6e3cf1b3ca1 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -94,3 +94,5 @@ error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_e 191 | | } | |_^ +error: aborting due to 12 previous errors + diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 39686a9dd07..b912373f95c 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -46,3 +46,5 @@ error: `if _ { .. } else { .. }` is an expression | = note: you might not need `mut` at all +error: aborting due to 4 previous errors + diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index b38c9ab2e91..459b2eafa26 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -23,3 +23,5 @@ note: this expression can be directly returned 15 | let x = 5; | ^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index 196afc0570c..da579ec80f3 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -12,3 +12,5 @@ error: this let-binding has unit value. Consider omitting `let _a =` 18 | let _a = (); | ^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index 744e1ce21ec..23b353d13d2 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -86,3 +86,5 @@ error: explicit lifetimes given in parameter types where they could be elided 120 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 14 previous errors + diff --git a/tests/ui/lint_pass.stderr b/tests/ui/lint_pass.stderr index 66f2d62ed24..2f9a6813b96 100644 --- a/tests/ui/lint_pass.stderr +++ b/tests/ui/lint_pass.stderr @@ -6,3 +6,5 @@ error: the lint `MISSING_LINT` is not added to any `LintPass` | = note: `-D lint-without-lint-pass` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index bcb9dbd136b..92540b73462 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -86,3 +86,5 @@ help: if you mean to use an octal constant, use `0o` 30 | let fail8 = 0o123; | ^^^^^ +error: aborting due to 11 previous errors + diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 272b868a278..c29f3791851 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -98,3 +98,5 @@ error: you seem to be using .map() to clone the contents of an Option, consider = help: try x.as_ref().cloned() +error: aborting due to 11 previous errors + diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 62c77c778be..fd22247cb1f 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -448,3 +448,5 @@ error: use as_mut() instead 329 | | }; | |_____^ help: try this: `mut_owned.as_mut()` +error: aborting due to 37 previous errors + diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index c79afa829fe..6e7a44694e1 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -18,3 +18,5 @@ error: usage of mem::forget on Drop type 24 | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 254c7bf1895..149fa4c1796 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -533,3 +533,5 @@ error: used unwrap() on an Option value. If you don't want to handle the None ca | = note: `-D option-unwrap-used` implied by `-D warnings` +error: aborting due to 66 previous errors + diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index e9225f93b5e..de4c4e16fa0 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -42,3 +42,5 @@ error: this min/max combination leads to constant result 30 | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 7 previous errors + diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index 55eab4f5d69..54834f9021c 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -264,9 +264,5 @@ error: missing documentation for a function 191 | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a function - --> $DIR/missing-doc.rs:202:1 - | -202 | fn main() {} - | ^^^^^^^^^^^^ +error: aborting due to 39 previous errors diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index cb6ea951a17..c9d3319db1b 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -16,3 +16,5 @@ error: module has the same name as its containing module 14 | | } | |_____^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 48cfe6c38cc..ccfca7154e0 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -6,3 +6,5 @@ error: any number modulo 1 will be 0 | = note: `-D modulo-one` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index eacda70ce07..a7cbc0b7a09 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -59,3 +59,5 @@ note: immutable borrow here 32 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index 8bfc2fc8a5c..d1f05ea8091 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -57,3 +57,5 @@ error: generally you want to avoid `&mut &mut _` if possible 35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ +error: aborting due to 9 previous errors + diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index 20dbb6511d7..d7be7ae1e6f 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -30,3 +30,5 @@ error: attempt to mutate range bound within loop; note that the range of the loo 40 | let n = &mut m; // warning | ^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 6708bca8b2e..73df19bf158 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -18,3 +18,5 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable 28 | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index d46c713164a..354f9891c17 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -44,3 +44,5 @@ error: Consider using an AtomicIsize instead of a Mutex here. If you just want t 16 | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ +error: aborting due to 7 previous errors + diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index a25b34bfaaf..63e0632445f 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -66,3 +66,5 @@ error: this if-then-else expression returns a bool literal 50 | if x && y { return false } else { return true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return !(x && y)` +error: aborting due to 11 previous errors + diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index 16962bb48f1..fde38508b32 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -38,3 +38,5 @@ error: this pattern creates a reference to a reference 50 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ help: change this to: `a` +error: aborting due to 6 previous errors + diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index c85bf9f5a7c..2a8cf4348d3 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -24,3 +24,5 @@ error: this pattern takes a reference on something that is being de-referenced 42 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' | ^^^^^^ help: try removing the `&ref` part and just keep: `k` +error: aborting due to 4 previous errors + diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index f63f120fcc7..3e0368892a4 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -55,3 +55,5 @@ error: There is no need for an explicit `else` block for this `if` expression println!("Jabber"); ... +error: aborting due to 2 previous errors + diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index 84c7e832951..3459d3820b7 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -2,7 +2,9 @@ #![warn(needless_pass_by_value)] -#![allow(dead_code, single_match, if_let_redundant_pattern_matching, many_single_char_names)] +#![allow(dead_code, single_match, if_let_redundant_pattern_matching, many_single_char_names, option_option)] + +#![feature(collections_range)] use std::borrow::Borrow; use std::convert::AsRef; @@ -110,4 +112,29 @@ trait FalsePositive { } } +// shouldn't warn on extern funcs +extern "C" fn ext(x: String) -> usize { x.len() } + +// whitelist RangeArgument +fn range>(range: T) { + let _ = range.start(); +} + +struct CopyWrapper(u32); + +fn bar_copy(x: u32, y: CopyWrapper) { + assert_eq!(x, 42); + assert_eq!(y.0, 42); +} + +// x and y should be warned, but z is ok +fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { + let CopyWrapper(s) = z; // moved + let CopyWrapper(ref t) = y; // not moved + let CopyWrapper(_) = y; // still not moved + + assert_eq!(x.0, s); + println!("{}", t); +} + fn main() {} diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 2ca96b127e5..469c16fa3d5 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,126 +1,188 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:12:23 + --> $DIR/needless_pass_by_value.rs:14:23 | -12 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { +14 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` | = note: `-D needless-pass-by-value` implied by `-D warnings` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:26:11 + --> $DIR/needless_pass_by_value.rs:28:11 | -26 | fn bar(x: String, y: Wrapper) { +28 | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:26:22 + --> $DIR/needless_pass_by_value.rs:28:22 | -26 | fn bar(x: String, y: Wrapper) { +28 | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:32:71 + --> $DIR/needless_pass_by_value.rs:34:71 | -32 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { +34 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:44:18 + --> $DIR/needless_pass_by_value.rs:46:18 | -44 | fn test_match(x: Option>, y: Option>) { +46 | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -44 | fn test_match(x: &Option>, y: Option>) { -45 | match *x { +46 | fn test_match(x: &Option>, y: Option>) { +47 | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:57:24 + --> $DIR/needless_pass_by_value.rs:59:24 | -57 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +59 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:57:36 + --> $DIR/needless_pass_by_value.rs:59:36 | -57 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +59 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead | -57 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { -58 | let Wrapper(s) = z; // moved -59 | let Wrapper(ref t) = *y; // not moved -60 | let Wrapper(_) = *y; // still not moved +59 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { +60 | let Wrapper(s) = z; // moved +61 | let Wrapper(ref t) = *y; // not moved +62 | let Wrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:73:49 + --> $DIR/needless_pass_by_value.rs:75:49 | -73 | fn test_blanket_ref(_foo: T, _serializable: S) {} +75 | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:75:18 + --> $DIR/needless_pass_by_value.rs:77:18 | -75 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:75:29 + --> $DIR/needless_pass_by_value.rs:77:29 | -75 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider changing the type to | -75 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { +77 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { | ^^^^ help: change `t.clone()` to | -77 | let _ = t.to_string(); +79 | let _ = t.to_string(); | ^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:75:40 + --> $DIR/needless_pass_by_value.rs:77:40 | -75 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:75:53 + --> $DIR/needless_pass_by_value.rs:77:53 | -75 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider changing the type to | -75 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { +77 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { | ^^^^^^ help: change `v.clone()` to | -79 | let _ = v.to_owned(); +81 | let _ = v.to_owned(); | ^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:87:12 + --> $DIR/needless_pass_by_value.rs:89:12 | -87 | s: String, +89 | s: String, | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:88:12 + --> $DIR/needless_pass_by_value.rs:90:12 | -88 | t: String, +90 | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:100:13 + --> $DIR/needless_pass_by_value.rs:102:13 | -100 | _u: U, +102 | _u: U, | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:101:13 + --> $DIR/needless_pass_by_value.rs:103:13 | -101 | _s: Self, +103 | _s: Self, | ^^^^ help: consider taking a reference instead: `&Self` +error: this argument is passed by value, but not consumed in the function body + --> $DIR/needless_pass_by_value.rs:125:24 + | +125 | fn bar_copy(x: u32, y: CopyWrapper) { + | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` + | +help: consider marking this type as Copy + --> $DIR/needless_pass_by_value.rs:123:1 + | +123 | struct CopyWrapper(u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this argument is passed by value, but not consumed in the function body + --> $DIR/needless_pass_by_value.rs:131:29 + | +131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { + | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` + | +help: consider marking this type as Copy + --> $DIR/needless_pass_by_value.rs:123:1 + | +123 | struct CopyWrapper(u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this argument is passed by value, but not consumed in the function body + --> $DIR/needless_pass_by_value.rs:131:45 + | +131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { + | ^^^^^^^^^^^ + | +help: consider marking this type as Copy + --> $DIR/needless_pass_by_value.rs:123:1 + | +123 | struct CopyWrapper(u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: consider taking a reference instead + | +131 | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { +132 | let CopyWrapper(s) = z; // moved +133 | let CopyWrapper(ref t) = *y; // not moved +134 | let CopyWrapper(_) = *y; // still not moved + | + +error: this argument is passed by value, but not consumed in the function body + --> $DIR/needless_pass_by_value.rs:131:61 + | +131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { + | ^^^^^^^^^^^ + | +help: consider marking this type as Copy + --> $DIR/needless_pass_by_value.rs:123:1 + | +123 | struct CopyWrapper(u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: consider taking a reference instead + | +131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { +132 | let CopyWrapper(s) = *z; // moved + | + +error: aborting due to 20 previous errors + diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index af78b370a12..7fb4571e0c3 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -37,3 +37,5 @@ help: consider using an iterator 35 | for in &mut ms { | +error: aborting due to 3 previous errors + diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 68c2654c863..42dc6e6594c 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -48,3 +48,5 @@ error: unneeded return statement 39 | let _ = || return true; | ^^^^^^^^^^^ help: remove `return` as shown: `true` +error: aborting due to 8 previous errors + diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 978fd8e625b..3e509870d00 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -6,3 +6,5 @@ error: struct update has no effect, all the fields in the struct have already be | = note: `-D needless-update` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 6ed31d384a0..1d52ba16eae 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -12,3 +12,5 @@ error: Negation by multiplying with -1 32 | -1 * x; | ^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index e62fe0c2905..83c10c9b193 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -90,3 +90,5 @@ error: this loop never actually loops 160 | | } | |_________^ +error: aborting due to 9 previous errors + diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index c12c10b9ae0..335e60404fa 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -36,3 +36,5 @@ help: try this 67 | } | +error: aborting due to 3 previous errors + diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 0d8d6624a83..5bcab9f2b5e 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -278,3 +278,5 @@ error: statement can be reduced 115 | FooString { s: String::from("blah"), }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `String::from("blah");` +error: aborting due to 46 previous errors + diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 6412b47aab4..850a3ccd951 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -149,3 +149,5 @@ error: consider choosing a more descriptive name 141 | let __1___2 = 12; //~ERROR Consider a more descriptive name | ^^^^^^^ +error: aborting due to 14 previous errors + diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index 79b09b3fa8a..da2d3b9500f 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -30,3 +30,5 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly 26 | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index b696672d2fd..e1371d924eb 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -11,3 +11,5 @@ error: Matching on `Some` with `ok()` is redundant = note: `-D if-let-some-result` implied by `-D warnings` = help: Consider matching on `Ok(y)` and removing the call to `ok` instead +error: aborting due to previous error + diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index 32596944570..a4f7b3c6761 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -10,3 +10,5 @@ help: use the values directly 13 | let foo = 5 - 6; | +error: aborting due to previous error + diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 2f4070c2868..f0d41904152 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -42,3 +42,5 @@ error: the method "truncate" is called more than once 15 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 7 previous errors + diff --git a/tests/ui/option_option.rs b/tests/ui/option_option.rs new file mode 100644 index 00000000000..249745c6a45 --- /dev/null +++ b/tests/ui/option_option.rs @@ -0,0 +1,63 @@ +fn input(_: Option>) { +} + +fn output() -> Option> { + None +} + +fn output_nested() -> Vec>> { + vec![None] +} + +// The lint only generates one warning for this +fn output_nested_nested() -> Option>> { + None +} + +struct Struct { + x: Option>, +} + +impl Struct { + fn struct_fn() -> Option> { + None + } +} + +trait Trait { + fn trait_fn() -> Option>; +} + +enum Enum { + Tuple(Option>), + Struct{x: Option>}, +} + +// The lint allows this +type OptionOption = Option>; + +// The lint allows this +fn output_type_alias() -> OptionOption { + None +} + +// The line allows this +impl Trait for Struct { + fn trait_fn() -> Option> { + None + } +} + +fn main() { + input(None); + output(); + output_nested(); + + // The lint allows this + let local: Option> = None; + + // The lint allows this + let expr = Some(Some(true)); +} + + diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr new file mode 100644 index 00000000000..19e00efae71 --- /dev/null +++ b/tests/ui/option_option.stderr @@ -0,0 +1,58 @@ +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:1:13 + | +1 | fn input(_: Option>) { + | ^^^^^^^^^^^^^^^^^^ + | + = note: `-D option-option` implied by `-D warnings` + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:4:16 + | +4 | fn output() -> Option> { + | ^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:8:27 + | +8 | fn output_nested() -> Vec>> { + | ^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:13:30 + | +13 | fn output_nested_nested() -> Option>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:18:8 + | +18 | x: Option>, + | ^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:22:23 + | +22 | fn struct_fn() -> Option> { + | ^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:28:22 + | +28 | fn trait_fn() -> Option>; + | ^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:32:11 + | +32 | Tuple(Option>), + | ^^^^^^^^^^^^^^^^^^ + +error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases + --> $DIR/option_option.rs:33:15 + | +33 | Struct{x: Option>}, + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index 6efcbfe38e1..adf353a1c4b 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -48,3 +48,5 @@ error: You are trying to use classic C underflow conditions that will fail in Ru 32 | if a < a - b { | ^^^^^^^^^ +error: aborting due to 8 previous errors + diff --git a/tests/ui/panic.stderr b/tests/ui/panic.stderr index f2480dfea6e..25113ed80b6 100644 --- a/tests/ui/panic.stderr +++ b/tests/ui/panic.stderr @@ -18,3 +18,5 @@ error: you probably are missing some parameter in your format string 12 | assert!(true, "here be missing values: {}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index c332ce53c1a..5e536cc51d2 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -6,3 +6,5 @@ error: re-implementing `PartialEq::ne` is unnecessary | = note: `-D partialeq-ne-impl` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index 9a246c483b2..59bce3a9a8f 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -6,3 +6,5 @@ error: the `y @ _` pattern can be written as just `y` | = note: `-D redundant-pattern` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index 720637c94b5..aacd90cdf92 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -4,6 +4,16 @@ #[warn(precedence)] #[allow(identity_op)] #[allow(eq_op)] + +macro_rules! trip { + ($a:expr) => { + match $a & 0b1111_1111i8 { + 0 => println!("a is zero ({})", $a), + _ => println!("a is {}", $a), + } + }; +} + fn main() { 1 << 2 + 3; 1 + 2 << 3; @@ -22,4 +32,7 @@ fn main() { let _ = -(1f32).abs(); let _ = -(1i32.abs()); let _ = -(1f32.abs()); + + let b = 3; + trip!(b * 8); } diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 26fbd75164d..92c1364746e 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,56 +1,58 @@ error: operator precedence can trip the unwary - --> $DIR/precedence.rs:8:5 - | -8 | 1 << 2 + 3; - | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` - | - = note: `-D precedence` implied by `-D warnings` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:9:5 - | -9 | 1 + 2 << 3; - | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:10:5 + --> $DIR/precedence.rs:18:5 | -10 | 4 >> 1 + 1; +18 | 1 << 2 + 3; + | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` + | + = note: `-D precedence` implied by `-D warnings` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:19:5 + | +19 | 1 + 2 << 3; + | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:20:5 + | +20 | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:11:5 + --> $DIR/precedence.rs:21:5 | -11 | 1 + 3 >> 2; +21 | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:12:5 + --> $DIR/precedence.rs:22:5 | -12 | 1 ^ 1 - 1; +22 | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:13:5 + --> $DIR/precedence.rs:23:5 | -13 | 3 | 2 - 1; +23 | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:14:5 + --> $DIR/precedence.rs:24:5 | -14 | 3 & 5 - 2; +24 | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:15:5 + --> $DIR/precedence.rs:25:5 | -15 | -1i32.abs(); +25 | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:16:5 + --> $DIR/precedence.rs:26:5 | -16 | -1f32.abs(); +26 | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` +error: aborting due to 9 previous errors + diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index fa547949bdb..789e1218b78 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -50,3 +50,5 @@ error: use of `Debug`-based formatting 31 | print!("Hello {:#?}", "#orld"); | ^^^^^^^ +error: aborting due to 8 previous errors + diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 0148a470e0d..4f32d1b2a2d 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -6,3 +6,5 @@ error: using `print!()` with a format string that ends in a newline, consider us | = note: `-D print-with-newline` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index 2036d7d976b..f70b056e562 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -6,3 +6,5 @@ error: using `println!("")` | = note: `-D print-with-newline` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index 4fbf73183c4..bf8608111cf 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -76,3 +76,5 @@ help: change `y.as_str()` to 62 | let c = y; | ^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 4098d32d08e..fc51f1a07f0 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -38,3 +38,5 @@ error: Iterator::step_by(0) will panic at runtime 33 | let _ = v1.iter().step_by(2/3); | ^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index a2a3ae6077f..cc0038c3442 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -65,3 +65,5 @@ error: an inclusive range would be more readable | help: use: `(f()+1)..=f()` | in this macro invocation +error: aborting due to 7 previous errors + diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 5acc3e9dde7..d2b5616a481 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -30,3 +30,5 @@ error: Try not to call a closure in the expression where it is declared. 12 | k = (|a,b| a*b)(1,5); | ^^^^^^^^^^^^^^^^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 2e6b23f6dc0..741c0cc1038 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -66,3 +66,5 @@ error: immediately dereferencing a reference 53 | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` +error: aborting due to 11 previous errors + diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 9f1397990bb..433061e41fb 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -149,3 +149,5 @@ error: trivial regex | = help: consider using consider using `str::is_empty` +error: aborting due to 21 previous errors + diff --git a/tests/ui/replace_consts.stderr b/tests/ui/replace_consts.stderr index a8e3dd2d00e..fb2e71db171 100644 --- a/tests/ui/replace_consts.stderr +++ b/tests/ui/replace_consts.stderr @@ -214,3 +214,5 @@ error: using `MAX` 47 | { let foo = std::u128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` +error: aborting due to 35 previous errors + diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index da0a96b2a3d..58667e0f820 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -10,3 +10,5 @@ error: you should not implement `visit_string` without also implementing `visit_ | = note: `-D serde-api-misuse` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index d5043261188..0eb5e5b2a2b 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -134,3 +134,5 @@ note: previous binding is here 21 | let x = y; | ^ +error: aborting due to 9 previous errors + diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index d7a02d7b9c3..7697cbd1c64 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -18,3 +18,5 @@ error: boolean short circuit operator in statement may be clearer using an expli 9 | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if !(1 == 2) { g(); }` +error: aborting due to 3 previous errors + diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index d5f21f210a3..42ee2b9fef4 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -102,3 +102,5 @@ error: single-character string constant used as pattern 37 | x.trim_right_matches("x"); | ---------------------^^^- help: try using a char instead: `x.trim_right_matches('x')` +error: aborting due to 17 previous errors + diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index c67cc8a86ea..7d73f201b69 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -74,3 +74,5 @@ error: you should use the `ends_with` method 38 | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` +error: aborting due to 12 previous errors + diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index 1f6d9400743..4be2037ad31 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -18,3 +18,5 @@ error: calling `.extend(_.chars())` 22 | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)` +error: aborting due to 3 previous errors + diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index a8fd59e12b2..d098ce9df5e 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -72,3 +72,5 @@ error: manual implementation of an assign operation 65 | ; x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` +error: aborting due to 11 previous errors + diff --git a/tests/ui/stutter.stderr b/tests/ui/stutter.stderr index e6465a2bce9..25e857991b8 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/stutter.stderr @@ -30,3 +30,5 @@ error: item name starts with its containing module's name 12 | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 0bda9bc8d2b..a01ec375e63 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -65,3 +65,5 @@ error: this looks like you are trying to swap `c.0` and `a` | = note: or maybe you should use `std::mem::replace`? +error: aborting due to 7 previous errors + diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 73a4818ba16..979720c914d 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -12,3 +12,5 @@ error: assignment to temporary 30 | (0, 0).0 = 1; | ^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 525b181bf91..f360e85329f 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -30,3 +30,5 @@ error: `ref` on an entire `let` pattern is discouraged, take a reference with `& 24 | let ref mut z = 1 + 2; | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` +error: aborting due to 5 previous errors + diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 0a4b5361d86..91e4d59da98 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -12,3 +12,5 @@ error: bit mask could be simplified with a call to `trailing_zeros` 8 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` +error: aborting due to 2 previous errors + diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index 6504f55845d..f3ac9a101ae 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -204,3 +204,5 @@ error: transmute from a `&mut [u8]` to a `&mut str` 140 | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` +error: aborting due to 32 previous errors + diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index b679b913877..3a6a6e73f57 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -12,3 +12,5 @@ error: transmute from a `f64` to a pointer 11 | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index a2f4ede5ca2..b41bff7a9b0 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -6,3 +6,5 @@ error: casting i32 to i64 may become silently lossy if types change | = note: `-D cast-lossless` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 870a12ee4c4..9e99a44bb60 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -28,3 +28,5 @@ error: literal non-ASCII character detected = help: Consider replacing the string with: ""/u{dc}ben!"" +error: aborting due to 3 previous errors + diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs new file mode 100644 index 00000000000..8f290446b5e --- /dev/null +++ b/tests/ui/unit_arg.rs @@ -0,0 +1,55 @@ +#![warn(unit_arg)] +#![allow(no_effect)] + +use std::fmt::Debug; + +fn foo(t: T) { + println!("{:?}", t); +} + +fn foo3(t1: T1, t2: T2, t3: T3) { + println!("{:?}, {:?}, {:?}", t1, t2, t3); +} + +struct Bar; + +impl Bar { + fn bar(&self, t: T) { + println!("{:?}", t); + } +} + +fn bad() { + foo({}); + foo({ 1; }); + foo(foo(1)); + foo({ + foo(1); + foo(2); + }); + foo3({}, 2, 2); + let b = Bar; + b.bar({ 1; }); +} + +fn ok() { + foo(()); + foo(1); + foo({ 1 }); + foo3("a", 3, vec![3]); + let b = Bar; + b.bar({ 1 }); + b.bar(()); + question_mark(); +} + +fn question_mark() -> Result<(), ()> { + Ok(Ok(())?)?; + Ok(Ok(()))??; + Ok(()) +} + +fn main() { + bad(); + ok(); +} diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr new file mode 100644 index 00000000000..ca48f39263b --- /dev/null +++ b/tests/ui/unit_arg.stderr @@ -0,0 +1,68 @@ +error: passing a unit value to a function + --> $DIR/unit_arg.rs:23:9 + | +23 | foo({}); + | ^^ + | + = note: `-D unit-arg` implied by `-D warnings` +help: if you intended to pass a unit value, use a unit literal instead + | +23 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:24:9 + | +24 | foo({ 1; }); + | ^^^^^^ +help: if you intended to pass a unit value, use a unit literal instead + | +24 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:25:9 + | +25 | foo(foo(1)); + | ^^^^^^ +help: if you intended to pass a unit value, use a unit literal instead + | +25 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:26:9 + | +26 | foo({ + | _________^ +27 | | foo(1); +28 | | foo(2); +29 | | }); + | |_____^ +help: if you intended to pass a unit value, use a unit literal instead + | +26 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:30:10 + | +30 | foo3({}, 2, 2); + | ^^ +help: if you intended to pass a unit value, use a unit literal instead + | +30 | foo3((), 2, 2); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:32:11 + | +32 | b.bar({ 1; }); + | ^^^^^^ +help: if you intended to pass a unit value, use a unit literal instead + | +32 | b.bar(()); + | ^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index a85e4150a3e..51ad3fca947 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -12,3 +12,5 @@ error: >-comparison of unit values detected. This will always be false 19 | if { true; } > { false; } { | ^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 2 previous errors + diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index f33def9eb4e..96166ed4f13 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -1,3 +1,4 @@ +#![warn(clone_on_ref_ptr)] #![allow(unused)] use std::collections::HashSet; @@ -5,6 +6,10 @@ use std::collections::VecDeque; use std::rc::{self, Rc}; use std::sync::{self, Arc}; +trait SomeTrait {} +struct SomeImpl; +impl SomeTrait for SomeImpl {} + fn main() {} fn clone_on_copy() { @@ -34,7 +39,8 @@ fn clone_on_ref_ptr() { arc_weak.clone(); sync::Weak::clone(&arc_weak); - + let x = Arc::new(SomeImpl); + let _: Arc = x.clone(); } fn clone_on_copy_generic(t: T) { diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 437df1ee97c..486d2e350f2 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,76 +1,84 @@ error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:11:5 + --> $DIR/unnecessary_clone.rs:16:5 | -11 | 42.clone(); +16 | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | = note: `-D clone-on-copy` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:15:5 + --> $DIR/unnecessary_clone.rs:20:5 | -15 | (&42).clone(); +20 | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:25:5 + --> $DIR/unnecessary_clone.rs:30:5 | -25 | rc.clone(); - | ^^^^^^^^^^ help: try this: `Rc::clone(&rc)` +30 | rc.clone(); + | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` | = note: `-D clone-on-ref-ptr` implied by `-D warnings` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:28:5 + --> $DIR/unnecessary_clone.rs:33:5 | -28 | arc.clone(); - | ^^^^^^^^^^^ help: try this: `Arc::clone(&arc)` +33 | arc.clone(); + | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:31:5 + --> $DIR/unnecessary_clone.rs:36:5 | -31 | rcweak.clone(); - | ^^^^^^^^^^^^^^ help: try this: `Weak::clone(&rcweak)` +36 | rcweak.clone(); + | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:34:5 + --> $DIR/unnecessary_clone.rs:39:5 | -34 | arc_weak.clone(); - | ^^^^^^^^^^^^^^^^ help: try this: `Weak::clone(&arc_weak)` +39 | arc_weak.clone(); + | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` + +error: using '.clone()' on a ref-counted pointer + --> $DIR/unnecessary_clone.rs:43:29 + | +43 | let _: Arc = x.clone(); + | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:41:5 + --> $DIR/unnecessary_clone.rs:47:5 | -41 | t.clone(); +47 | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:43:5 + --> $DIR/unnecessary_clone.rs:49:5 | -43 | Some(t).clone(); +49 | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type - --> $DIR/unnecessary_clone.rs:49:22 + --> $DIR/unnecessary_clone.rs:55:22 | -49 | let z: &Vec<_> = y.clone(); +55 | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | = note: `-D clone-double-ref` implied by `-D warnings` help: try dereferencing it | -49 | let z: &Vec<_> = &(*y).clone(); +55 | let z: &Vec<_> = &(*y).clone(); | ^^^^^^^^^^^^^ help: or try being explicit about what type to clone | -49 | let z: &Vec<_> = &std::vec::Vec::clone(y); +55 | let z: &Vec<_> = &std::vec::Vec::clone(y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/unnecessary_clone.rs:56:27 + --> $DIR/unnecessary_clone.rs:62:27 | -56 | let v2 : Vec = v.iter().cloned().collect(); +62 | let v2 : Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D iter-cloned-collect` implied by `-D warnings` +error: aborting due to 11 previous errors + diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index ef1a8d75732..7e4c3a6cb9c 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -15,3 +15,5 @@ error: All the struct fields are matched to a wildcard pattern, consider using ` | = help: Try with `Foo { .. }` instead +error: aborting due to 2 previous errors + diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index 81b69937a6d..72cb160fafc 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -31,3 +31,5 @@ error: long literal lacking separators | = help: consider: 1.234_56_f32 +error: aborting due to 4 previous errors + diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 7d455d31bce..93f2ddd533f 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -18,3 +18,5 @@ error: removed "unsafe" from the name of `Unsafe` in use as `LieAboutModSafety` 23 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index b4a3cb2122d..5114d375fff 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -39,3 +39,5 @@ error: handle read amount returned or use `Read::read_exact` instead 27 | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to 6 previous errors + diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index 338eb2f1551..19c91e2a6a3 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -22,3 +22,5 @@ error: unused label `'same_label_in_two_fns` 34 | | } | |_____^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index a4f01de18f7..b1fcebe6eed 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -18,3 +18,5 @@ error: this lifetime isn't used in the function definition 50 | fn x<'a>(&self) {} | ^^ +error: aborting due to 3 previous errors + diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 9d316dd3e08..bfd334335d8 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -36,3 +36,5 @@ error: unnecessary structure name repetition 24 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` +error: aborting due to 6 previous errors + diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 388a3491477..712f81c1b6f 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -30,3 +30,5 @@ error: used binding `_underscore_field` which is prefixed with an underscore. A 36 | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ +error: aborting due to 5 previous errors + diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 4b6af9b877e..875d830a353 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -70,3 +70,5 @@ error: this call to `as_ref` does nothing 106 | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try this: `mrt` +error: aborting due to 11 previous errors + diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 0bb87f8c538..707a11d55cc 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -6,3 +6,5 @@ error: useless lint attribute | = note: `-D useless-attribute` implied by `-D warnings` +error: aborting due to previous error + diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index a1555bc7907..6a47eb5b064 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -36,3 +36,5 @@ error: useless use of `vec!` 49 | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` +error: aborting due to 6 previous errors + diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index edc88405c40..689c92d6fb6 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -110,3 +110,5 @@ error: this loop could be written as a `for` loop 184 | | } | |_________^ help: try: `for v in y { .. }` +error: aborting due to 11 previous errors + diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index e57ffc3266b..216fd0bb82b 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -72,3 +72,5 @@ error: methods called `from_*` usually take no self; consider choosing a less am 54 | pub fn from_i64(self) {} | ^^^^ +error: aborting due to 12 previous errors + diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 697432af408..b81e59c07f1 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -57,3 +57,5 @@ error: constant division of 0.0 with 0.0 will always result in NaN | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN +error: aborting due to 8 previous errors + diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index fb87a47536e..5155dc401bd 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -12,3 +12,5 @@ error: `0 as *mut _` detected. Consider using `ptr::null_mut()` 7 | let y = 0 as *mut f64; | ^^^^^^^^^^^^^ +error: aborting due to 2 previous errors +