diff --git a/.github/deploy.sh b/.github/deploy.sh index 11d0b2d2a85..a242c35c3ae 100755 --- a/.github/deploy.sh +++ b/.github/deploy.sh @@ -1,16 +1,5 @@ #!/bin/bash -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - - # Automatically deploy on gh-pages set -ex diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index df216a8fbc9..415fb7ab0d7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,7 +79,7 @@ to lint-writing, though it does get into advanced stuff. Most lints consist of a of this. If you want to add a new lint or change existing ones apart from bugfixing, it's -also a good idea to give the [stability guaratees][rfc_stability] and +also a good idea to give the [stability guarantees][rfc_stability] and [lint categories][rfc_lint_cats] sections of the [Clippy 1.0 RFC][clippy_rfc] a quick read. diff --git a/COPYRIGHT b/COPYRIGHT index cb9970597a2..e507fb8b9b9 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright 2014-2018 The Rust Project Developers +Copyright 2014-2019 The Rust Project Developers Licensed under the Apache License, Version 2.0 or the MIT license diff --git a/README.md b/README.md index 3a7e9a165c1..6473b8efc54 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Clippy -[![Build Status](https://travis-ci.org/rust-lang/rust-clippy.svg?branch=master)](https://travis-ci.org/rust-lang/rust-clippy) +[![Build Status](https://travis-ci.com/rust-lang/rust-clippy.svg?branch=master)](https://travis-ci.com/rust-lang/rust-clippy) [![Windows Build status](https://ci.appveyor.com/api/projects/status/id677xpw1dguo7iw?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/rust-clippy) [![Current Version](https://meritbadge.herokuapp.com/clippy)](https://crates.io/crates/clippy) [![License: MIT/Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license) @@ -68,10 +68,15 @@ Once you have rustup and the latest stable release (at least Rust 1.29) installe ```terminal rustup component add clippy ``` +If it says that it can't find the `clippy` component, please run `rustup self update`. -Now you can run Clippy by invoking `cargo clippy`. +#### Step 3: Run Clippy -If it says that it can't find the `clippy` subcommand, please run `rustup self update` +Now you can run Clippy by invoking the following command: + +```terminal +cargo clippy +``` ### Running Clippy from the command line without installing it @@ -157,7 +162,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT ## License -Copyright 2014-2018 The Rust Project Developers +Copyright 2014-2019 The Rust Project Developers Licensed under the Apache License, Version 2.0 or the MIT license diff --git a/bors.toml b/bors.toml deleted file mode 100644 index 4e6e85f45fe..00000000000 --- a/bors.toml +++ /dev/null @@ -1,4 +0,0 @@ -status = [ - "continuous-integration/travis-ci/push", - "continuous-integration/appveyor/branch" -] diff --git a/build.rs b/build.rs index 22a6910f167..146a8dae745 100644 --- a/build.rs +++ b/build.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() { // Forward the profile to the main compilation println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap()); diff --git a/ci/base-tests.sh b/ci/base-tests.sh index b69e86ad3ac..6675c795b3b 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -1,14 +1,3 @@ -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - - set -ex echo "Running clippy base tests" diff --git a/ci/integration-tests.sh b/ci/integration-tests.sh index bf43d5b6811..1259c5e1d37 100755 --- a/ci/integration-tests.sh +++ b/ci/integration-tests.sh @@ -1,13 +1,3 @@ -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - set -x rm ~/.cargo/bin/cargo-clippy cargo install --force --path . diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 60f1a3df522..073b3a9e97f 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::default_hash_types)] use itertools::Itertools; diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 4ed07960010..1d9245d1347 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - extern crate clap; extern crate clippy_dev; extern crate regex; diff --git a/clippy_dummy/build.rs b/clippy_dummy/build.rs index b4ea0772ee5..59d32e5db43 100644 --- a/clippy_dummy/build.rs +++ b/clippy_dummy/build.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - extern crate term; fn main() { @@ -49,4 +39,4 @@ fn foo() -> Result<(), ()> { t.reset().map_err(|_| ())?; Ok(()) -} \ No newline at end of file +} diff --git a/clippy_dummy/src/main.rs b/clippy_dummy/src/main.rs index 878993d5c28..a118834f1fd 100644 --- a/clippy_dummy/src/main.rs +++ b/clippy_dummy/src/main.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - fn main() { panic!("This shouldn't even compile") } diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index afbfdd32304..8410408312f 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index c466b8cd5c9..efa53ff94c3 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -1,12 +1,4 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +use crate::consts::constant_simple; use crate::utils::span_lint; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; @@ -103,8 +95,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic { hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => { let ty = cx.tables.expr_ty(arg); if ty.is_integral() { - span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); - self.expr_span = Some(expr.span); + if constant_simple(cx, cx.tables, expr).is_none() { + span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); + self.expr_span = Some(expr.span); + } } else if ty.is_floating_point() { span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); self.expr_span = Some(expr.span); @@ -134,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic { } self.const_span = Some(body_span); }, - hir::BodyOwnerKind::Fn => (), + hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure => (), } } diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 496b6d65993..ad77ee3a3fa 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, SpanlessEq}; use crate::utils::{higher, sugg}; use if_chain::if_chain; diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 41946d06293..9e4dd52c414 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! checks for attributes use crate::reexport::*; @@ -341,9 +332,12 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) { // https://github.com/rust-lang/rust/pull/56992 CheckLintNameResult::NoLint(None) => (), _ => { - db.span_suggestion(lint.span, - "lowercase the lint name", - name_lower); + db.span_suggestion_with_applicability( + lint.span, + "lowercase the lint name", + name_lower, + Applicability::MaybeIncorrect, + ); } } } @@ -382,8 +376,9 @@ fn is_relevant_trait(tcx: TyCtxt<'_, '_, '_>, item: &TraitItem) -> bool { fn is_relevant_block(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>, block: &Block) -> bool { if let Some(stmt) = block.stmts.first() { match &stmt.node { - StmtKind::Decl(_, _) => true, - StmtKind::Expr(expr, _) | StmtKind::Semi(expr, _) => is_relevant_expr(tcx, tables, expr), + StmtKind::Local(_) => true, + StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(tcx, tables, expr), + _ => false, } } else { block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e)) @@ -520,18 +515,17 @@ impl EarlyLintPass for CfgAttrPass { // check for `rustfmt_skip` and `rustfmt::skip` if let Some(skip_item) = &items[1].meta_item(); if skip_item.name() == "rustfmt_skip" || skip_item.name() == "skip"; + // Only lint outer attributes, because custom inner attributes are unstable + // Tracking issue: https://github.com/rust-lang/rust/issues/54726 + if let AttrStyle::Outer = attr.style; then { - let attr_style = match attr.style { - AttrStyle::Outer => "#[", - AttrStyle::Inner => "#![", - }; span_lint_and_sugg( cx, DEPRECATED_CFG_ATTR, attr.span, "`cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes", "use", - format!("{}rustfmt::skip]", attr_style), + "#[rustfmt::skip]".to_string(), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 9af80493af1..b08d9961d25 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant, Constant}; use crate::utils::sugg::Sugg; use crate::utils::{span_lint, span_lint_and_then}; diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index ed7437e495b..64b3be8f302 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index 92979dc024d..6e850931e6b 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::*; use matches::matches; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 2279d24af95..8b1a56e3b6e 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{ get_trait_def_id, implements_trait, in_macro, match_type, paths, snippet_opt, span_lint_and_then, SpanlessEq, }; diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 0f2062d9e0f..794b43f4db5 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{ contains_name, get_pat_name, match_type, paths, single_segment_path, snippet_with_applicability, span_lint_and_sugg, walk_ptrs_ty, diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index 9f396b61330..70ea387515a 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on missing cargo common metadata use crate::utils::span_lint; diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index ae613d70240..10cbc9e6ccd 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for if expressions that contain only an if expression. //! //! For example, the lint would catch: diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index a7509dae3d5..229a411ce06 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{in_macro, snippet, span_lint_and_then}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 8102a416d82..49722e5ad71 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - #![allow(clippy::float_cmp)] use crate::utils::{clip, sext, unsext}; @@ -24,6 +14,7 @@ use std::convert::TryInto; use std::hash::{Hash, Hasher}; use syntax::ast::{FloatTy, LitKind}; use syntax::ptr::P; +use syntax_pos::symbol::Symbol; /// A `LitKind`-like enum to fold constant `Expr`s into. #[derive(Debug, Clone)] @@ -48,6 +39,8 @@ pub enum Constant { Repeat(Box, u64), /// a tuple of constants Tuple(Vec), + /// a literal with syntax error + Err(Symbol), } impl PartialEq for Constant { @@ -113,6 +106,9 @@ impl Hash for Constant { c.hash(state); l.hash(state); }, + Constant::Err(ref s) => { + s.hash(state); + }, } } } @@ -165,6 +161,7 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant { _ => bug!(), }, LitKind::Bool(b) => Constant::Bool(b), + LitKind::Err(s) => Constant::Err(s), } } diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 01398380075..3676519adc1 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_parent_expr, in_macro, snippet, span_lint_and_then, span_note_and_lint}; use crate::utils::{SpanlessEq, SpanlessHash}; use rustc::hir::*; diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index f45d8eea5e1..3d0df7424f1 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_copy, match_path, paths, span_note_and_lint}; use rustc::hir::{Item, ItemKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 695e4329dfd..9170f1e8ecf 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! calculate cyclomatic complexity and warn about overly complex functions use rustc::cfg::CFG; diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index 9dc404efd7e..c4b39dc0f0a 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use if_chain::if_chain; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index 17bef09164b..7cb04d7a95b 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - macro_rules! declare_deprecated_lint { (pub $name: ident, $_reason: expr) => { declare_lint!(pub $name, Allow, "deprecated lint") diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index b4556ebaff9..a2bf0098ab8 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::{is_automatically_derived, is_copy, match_path, span_lint_and_then}; use if_chain::if_chain; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index a3504e7e330..e96ef9ac621 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use itertools::Itertools; use pulldown_cmark; diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 34f4a56bef9..fc4af438d44 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Lint on unnecessary double comparisons. Some examples: use rustc::hir::*; diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index 3b476b81707..38381b069f0 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{in_macro, span_lint}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index f0f91c9ab69..4a2a38f6ea1 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_copy, match_def_path, opt_def_id, paths, span_note_and_lint}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index aebb378ee9b..3ac98c71644 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use if_chain::if_chain; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index ff8345290b2..f633d81764b 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on if expressions with an else if, but without a final else branch use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index af2a54069fc..71e84bf1b47 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint when there is an enum with no variants use crate::utils::span_lint_and_then; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index c59bfd1ad92..646a2569bbe 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::SpanlessEq; use crate::utils::{get_item_name, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty}; use if_chain::if_chain; diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 78cade1f2fb..ab9bc6cd0ca 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on C-like enums that are `repr(isize/usize)` and have values that //! don't fit into an `i32` diff --git a/clippy_lints/src/enum_glob_use.rs b/clippy_lints/src/enum_glob_use.rs index aa1ee038c59..9402c2a5aad 100644 --- a/clippy_lints/src/enum_glob_use.rs +++ b/clippy_lints/src/enum_glob_use.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on `use`ing all variants of an enum use crate::utils::span_lint; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 5466baae886..ffaa8b2811a 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on enum variants that are prefixed or suffixed by the same characters use crate::utils::{camel_case, in_macro}; diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index af9de9fe7e4..93132534a76 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{ implements_trait, in_macro, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq, }; diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index 43f16c74eb1..fea31855543 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant_simple, Constant}; use crate::utils::{in_macro, span_lint}; use rustc::hir::*; diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 445aeb3377b..a7b47fd1e54 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::hir::intravisit as visit; use rustc::hir::*; @@ -129,18 +120,16 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { if let Categorization::Rvalue(..) = cmt.cat { let id = map.hir_to_node_id(cmt.hir_id); if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) { - if let StmtKind::Decl(ref decl, _) = st.node { - if let DeclKind::Local(ref loc) = decl.node { - if let Some(ref ex) = loc.init { - if let ExprKind::Box(..) = ex.node { - if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) { - // let x = box (...) - self.set.insert(consume_pat.id); - } - // TODO Box::new - // TODO vec![] - // TODO "foo".to_owned() and friends + if let StmtKind::Local(ref loc) = st.node { + if let Some(ref ex) = loc.init { + if let ExprKind::Box(..) = ex.node { + if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) { + // let x = box (...) + self.set.insert(consume_pat.id); } + // TODO Box::new + // TODO vec![] + // TODO "foo".to_owned() and friends } } } diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index dd80afbc4ae..624d215492f 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_adjusted, iter_input_pats, snippet_opt, span_lint_and_then}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 50944eb5e7e..2b4b0d40239 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_parent_expr, span_lint, span_note_and_lint}; use if_chain::if_chain; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; @@ -98,14 +89,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence { } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { match stmt.node { - StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e), - StmtKind::Decl(ref d, _) => { - if let DeclKind::Local(ref local) = d.node { - if let Local { init: Some(ref e), .. } = **local { - DivergenceVisitor { cx }.visit_expr(e); - } + StmtKind::Local(ref local) => { + if let Local { init: Some(ref e), .. } = **local { + DivergenceVisitor { cx }.visit_expr(e); } }, + StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => DivergenceVisitor { cx }.maybe_walk_expr(e), + StmtKind::Item(..) => {}, } } } @@ -278,18 +268,14 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly { match stmt.node { - StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => check_expr(vis, expr), - StmtKind::Decl(ref decl, _) => { - // If the declaration is of a local variable, check its initializer - // expression if it has one. Otherwise, keep going. - let local = match decl.node { - DeclKind::Local(ref local) => Some(local), - _ => None, - }; - local - .and_then(|local| local.init.as_ref()) - .map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr)) - }, + StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => check_expr(vis, expr), + // If the declaration is of a local variable, check its initializer + // expression if it has one. Otherwise, keep going. + StmtKind::Local(ref local) => local + .init + .as_ref() + .map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr)), + _ => StopEarly::KeepGoing, } } diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index b3cf9131cce..f17b82ab33d 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint_and_sugg; use if_chain::if_chain; use rustc::hir; diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index f56e3225d0a..0bbc85a0416 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_expn_of, match_def_path, opt_def_id, resolve_node, span_lint, span_lint_and_sugg}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 65790b1b42e..2d11b3bd947 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT, OPTION, RESULT}; use crate::utils::{is_expn_of, match_def_path, method_chain_args, opt_def_id, span_lint_and_then, walk_ptrs_ty}; use if_chain::if_chain; diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 1db52079d3f..90e19af15d0 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::{ in_macro, is_expn_of, last_path_segment, match_def_path, match_type, opt_def_id, resolve_node, snippet, @@ -62,12 +53,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { ExprKind::Call(ref fun, ref args) => { if_chain! { if let ExprKind::Path(ref qpath) = fun.node; - if args.len() == 3; if let Some(fun_def_id) = opt_def_id(resolve_node(cx, qpath, fun.hir_id)); - if match_def_path(cx.tcx, fun_def_id, &paths::FMT_ARGUMENTS_NEWV1FORMATTED); + let new_v1 = match_def_path(cx.tcx, fun_def_id, &paths::FMT_ARGUMENTS_NEWV1); + let new_v1_fmt = match_def_path( + cx.tcx, + fun_def_id, + &paths::FMT_ARGUMENTS_NEWV1FORMATTED + ); + if new_v1 || new_v1_fmt; if check_single_piece(&args[0]); if let Some(format_arg) = get_single_string_arg(cx, &args[1]); - if check_unformatted(&args[2]); + if new_v1 || check_unformatted(&args[2]); if let ExprKind::AddrOf(_, ref format_arg) = format_arg.node; then { let (message, sugg) = if_chain! { diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index ce51f1433f9..6459e7b81c6 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{differing_macro_contexts, in_macro, snippet_opt, span_note_and_lint}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 19adf2d1dc4..a2b7d31b183 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{iter_input_pats, span_lint, type_is_unsafe_function}; use matches::matches; use rustc::hir; diff --git a/clippy_lints/src/identity_conversion.rs b/clippy_lints/src/identity_conversion.rs index b18d63a94b6..d0e1ee57748 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{ in_macro, match_def_path, match_trait_method, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then, }; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 5f1101461bd..862c289fce1 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant_simple, Constant}; use crate::utils::{clip, in_macro, snippet, span_lint, unsext}; use rustc::hir::*; diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index c40fb540da6..19554c7e207 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on if branches that could be swapped so no `!` operation is necessary //! on the condition diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 674667c4b5b..073c37eefc5 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -1,14 +1,5 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use crate::utils::{in_macro, snippet_opt, span_lint_and_then}; -use rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl}; +use crate::utils::{in_macro, is_expn_of, snippet_opt, span_lint_and_then}; +use rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl, MatchSource}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; @@ -90,15 +81,31 @@ impl Pass { Self::expr_match(cx, else_expr); } }, - ExprKind::Match(_, arms, ..) => { - for arm in arms { - Self::expr_match(cx, &arm.body); + ExprKind::Match(.., arms, source) => { + let check_all_arms = match source { + MatchSource::IfLetDesugar { + contains_else_clause: has_else, + } => *has_else, + _ => true, + }; + + if check_all_arms { + for arm in arms { + Self::expr_match(cx, &arm.body); + } + } else { + Self::expr_match(cx, &arms.first().expect("if let doesn't have a single arm").body); } }, // skip if it already has a return statement ExprKind::Ret(..) => (), // everything else is missing `return` - _ => Self::lint(cx, expr.span, expr.span, "add `return` as shown"), + _ => { + // make sure it's not just an unreachable expression + if is_expn_of(expr.span, "unreachable").is_none() { + Self::lint(cx, expr.span, expr.span, "add `return` as shown") + } + }, } } } diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index cf971b63052..b4893c759c8 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on indexing and slicing operations use crate::consts::{constant, Constant}; diff --git a/clippy_lints/src/infallible_destructuring_match.rs b/clippy_lints/src/infallible_destructuring_match.rs index e3d03c0e697..5d0c5a4a79d 100644 --- a/clippy_lints/src/infallible_destructuring_match.rs +++ b/clippy_lints/src/infallible_destructuring_match.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use super::utils::{get_arg_name, match_var, remove_blocks, snippet_with_applicability, span_lint_and_sugg}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index e2da8461f41..c25c4ec488f 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, match_type, paths, span_lint}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 5224b5fb867..52aa73d7a10 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on inherent implementations use crate::utils::span_lint_and_then; diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index afa8f234023..a092f86658b 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! checks for `#[inline]` on trait methods without bodies use crate::utils::span_lint_and_then; diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 3498c1e8114..547052f3429 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on blocks unnecessarily using >= with a + 1 or - 1 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index c0dcda6349b..03b099b4393 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_def_path, opt_def_id, paths, span_help_and_lint}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 2d8f284ea6d..0af8c3dd5cb 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint when items are used after statements use crate::utils::{in_macro, span_lint}; diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 052504cc57c..d5bc2a8fad7 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint when there is a large size difference between variants on an enum use crate::utils::{snippet_opt, span_lint_and_then}; diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 233bea77e03..b15ba5a4783 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_item_name, in_macro, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty}; use rustc::hir::def_id::DefId; use rustc::hir::*; @@ -40,10 +31,10 @@ use syntax::source_map::{Span, Spanned}; /// ``` /// instead use /// ```rust -/// if x.len().is_empty() { +/// if x.is_empty() { /// .. /// } -/// if !y.len().is_empty() { +/// if !y.is_empty() { /// .. /// } /// ``` @@ -124,8 +115,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero { check_cmp(cx, expr.span, left, right, "", 1); // len < 1 check_cmp(cx, expr.span, right, left, "!", 0); // 0 < len }, - BinOpKind::Ge => check_cmp(cx, expr.span, left, right, "!", 1), // len <= 1 - BinOpKind::Le => check_cmp(cx, expr.span, right, left, "!", 1), // 1 >= len + BinOpKind::Ge => check_cmp(cx, expr.span, left, right, "!", 1), // len >= 1 + BinOpKind::Le => check_cmp(cx, expr.span, right, left, "!", 1), // 1 <= len _ => (), } } diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 7e9f1b41d27..5154c6d4d08 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{snippet, span_lint_and_then}; use if_chain::if_chain; use rustc::hir; @@ -77,10 +68,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { while let Some(stmt) = it.next() { if_chain! { if let Some(expr) = it.peek(); - if let hir::StmtKind::Decl(ref decl, _) = stmt.node; - if let hir::DeclKind::Local(ref decl) = decl.node; - if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node; - if let hir::StmtKind::Expr(ref if_, _) = expr.node; + if let hir::StmtKind::Local(ref local) = stmt.node; + if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.node; + if let hir::StmtKind::Expr(ref if_) = expr.node; if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node; if !used_in_expr(cx, canonical_id, cond); if let hir::ExprKind::Block(ref then, _) = then.node; @@ -93,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { if let hir::ExprKind::Block(ref else_, _) = else_.node { if let Some(default) = check_assign(cx, canonical_id, else_) { (else_.stmts.len() > 1, default) - } else if let Some(ref default) = decl.init { + } else if let Some(ref default) = local.init { (true, &**default) } else { continue; @@ -101,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { } else { continue; } - } else if let Some(ref default) = decl.init { + } else if let Some(ref default) = local.init { (false, &**default) } else { continue; @@ -178,7 +168,7 @@ fn check_assign<'a, 'tcx>( if_chain! { if block.expr.is_none(); if let Some(expr) = block.stmts.iter().last(); - if let hir::StmtKind::Semi(ref expr, _) = expr.node; + if let hir::StmtKind::Semi(ref expr) = expr.node; if let hir::ExprKind::Assign(ref var, ref value) = expr.node; if let hir::ExprKind::Path(ref qpath) = var.node; if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id); diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 1c362313e77..9d77c3c64a2 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern:cargo-clippy #![feature(box_syntax)] @@ -20,7 +11,6 @@ #![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)] #![feature(crate_visibility_modifier)] #![feature(try_from)] -#![feature(if_while_or_patterns)] // FIXME: switch to something more ergonomic here, once available. // (currently there is no way to opt into sysroot crates w/o `extern crate`) diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 32170c9a7c6..f7512446c87 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::reexport::*; use crate::utils::{last_path_segment, span_lint}; use matches::matches; diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 72bd6b09fea..d6e6ffa61b3 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Lints concerned with the grouping of digits with underscores in integral or //! floating-point literal expressions. diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index d8d95cf9a23..70ff86087ea 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1,18 +1,9 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::reexport::*; use if_chain::if_chain; use itertools::Itertools; use rustc::hir::def::Def; use rustc::hir::def_id; -use rustc::hir::intravisit::{walk_block, walk_decl, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor}; +use rustc::hir::intravisit::{walk_block, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor}; use rustc::hir::*; use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass}; use rustc::middle::region; @@ -574,6 +565,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { && lhs_constructor.ident.name == "Some" && (pat_args.is_empty() || !is_refutable(cx, &pat_args[0]) + && !is_used_inside(cx, iter_expr, &arms[0].body) && !is_iterator_used_after_while_let(cx, iter_expr) && !is_nested(cx, expr, &method_args[0])) { @@ -605,7 +597,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - if let StmtKind::Semi(ref expr, _) = stmt.node { + if let StmtKind::Semi(ref expr) = stmt.node { if let ExprKind::MethodCall(ref method, _, ref args) = expr.node { if args.len() == 1 && method.ident.name == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) { span_lint( @@ -676,13 +668,7 @@ fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult { fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> { match stmt.node { StmtKind::Semi(ref e, ..) | StmtKind::Expr(ref e, ..) => Some(e), - StmtKind::Decl(ref d, ..) => decl_to_expr(d), - } -} - -fn decl_to_expr(decl: &Decl) -> Option<&Expr> { - match decl.node { - DeclKind::Local(ref local) => local.init.as_ref().map(|p| &**p), + StmtKind::Local(ref local) => local.init.as_ref().map(|p| &**p), _ => None, } } @@ -950,8 +936,8 @@ fn get_indexed_assignments<'a, 'tcx>( stmts .iter() .map(|stmt| match stmt.node { - StmtKind::Decl(..) => None, - StmtKind::Expr(ref e, _node_id) | StmtKind::Semi(ref e, _node_id) => Some(get_assignment(cx, e, var)), + StmtKind::Local(..) | StmtKind::Item(..) => None, + StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => Some(get_assignment(cx, e, var)), }) .chain(expr.as_ref().into_iter().map(|e| Some(get_assignment(cx, &*e, var)))) .filter_map(|op| op) @@ -1897,6 +1883,19 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { } } +fn is_used_inside<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, container: &'tcx Expr) -> bool { + let def_id = match var_def_id(cx, expr) { + Some(id) => id, + None => return false, + }; + if let Some(used_mutably) = mutated_variables(container, cx) { + if used_mutably.contains(&def_id) { + return true; + } + } + false +} + fn is_iterator_used_after_while_let<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, iter_expr: &'tcx Expr) -> bool { let def_id = match var_def_id(cx, iter_expr) { Some(id) => id, @@ -1971,13 +1970,9 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> { if block.stmts.is_empty() { return None; } - if let StmtKind::Decl(ref decl, _) = block.stmts[0].node { - if let DeclKind::Local(ref local) = decl.node { - if let Some(ref expr) = local.init { - Some(expr) - } else { - None - } + if let StmtKind::Local(ref local) = block.stmts[0].node { + if let Some(ref expr) = local.init { + Some(expr) } else { None } @@ -1991,8 +1986,8 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> { match block.expr { Some(ref expr) if block.stmts.is_empty() => Some(expr), None if !block.stmts.is_empty() => match block.stmts[0].node { - StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => Some(expr), - StmtKind::Decl(..) => None, + StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => Some(expr), + StmtKind::Local(..) | StmtKind::Item(..) => None, }, _ => None, } @@ -2090,9 +2085,9 @@ struct InitializeVisitor<'a, 'tcx: 'a> { } impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { - fn visit_decl(&mut self, decl: &'tcx Decl) { + fn visit_stmt(&mut self, stmt: &'tcx Stmt) { // Look for declarations of the variable - if let DeclKind::Local(ref local) = decl.node { + if let StmtKind::Local(ref local) = stmt.node { if local.pat.id == self.var_id { if let PatKind::Binding(_, _, ident, _) = local.pat.node { self.name = Some(ident.name); @@ -2109,7 +2104,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { } } } - walk_decl(self, decl); + walk_stmt(self, stmt); } fn visit_expr(&mut self, expr: &'tcx Expr) { @@ -2256,7 +2251,7 @@ struct LoopNestVisitor { impl<'tcx> Visitor<'tcx> for LoopNestVisitor { fn visit_stmt(&mut self, stmt: &'tcx Stmt) { - if stmt.node.id() == self.id { + if stmt.id == self.id { self.nesting = LookFurther; } else if self.nesting == Unknown { walk_stmt(self, stmt); diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 2a7177d1fb9..4db0ca759db 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::{ in_macro, match_trait_method, match_type, remove_blocks, snippet_with_applicability, span_lint_and_sugg, @@ -14,6 +5,7 @@ use crate::utils::{ use if_chain::if_chain; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::ty; use rustc::{declare_tool_lint, lint_array}; use rustc_errors::Applicability; use syntax::ast::Ident; @@ -27,9 +19,7 @@ pub struct Pass; /// /// **Why is this bad?** Readability, this can be written more concisely /// -/// **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). +/// **Known problems:** None /// /// **Example:** /// @@ -78,19 +68,27 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { hir::PatKind::Ref(ref inner, _) => if let hir::PatKind::Binding( hir::BindingAnnotation::Unannotated, _, name, None ) = inner.node { - lint(cx, e.span, args[0].span, name, closure_expr); + if ident_eq(name, closure_expr) { + lint(cx, e.span, args[0].span); + } }, hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => { match closure_expr.node { hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => { - if !cx.tables.expr_ty(inner).is_box() { - lint(cx, e.span, args[0].span, name, inner); + if ident_eq(name, inner) && !cx.tables.expr_ty(inner).is_box() { + lint(cx, e.span, args[0].span); } }, hir::ExprKind::MethodCall(ref method, _, ref obj) => { - if method.ident.as_str() == "clone" + if ident_eq(name, &obj[0]) && method.ident.as_str() == "clone" && match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) { - lint(cx, e.span, args[0].span, name, &obj[0]); + + let obj_ty = cx.tables.expr_ty(&obj[0]); + if let ty::Ref(..) = obj_ty.sty { + lint(cx, e.span, args[0].span); + } else { + lint_needless_cloning(cx, e.span, args[0].span); + } } }, _ => {}, @@ -103,22 +101,38 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } } -fn lint(cx: &LateContext<'_, '_>, replace: Span, root: Span, name: Ident, path: &hir::Expr) { +fn ident_eq(name: Ident, path: &hir::Expr) -> bool { if let hir::ExprKind::Path(hir::QPath::Resolved(None, ref path)) = path.node { - if path.segments.len() == 1 && path.segments[0].ident == name { - let mut applicability = Applicability::MachineApplicable; - span_lint_and_sugg( - cx, - MAP_CLONE, - replace, - "You are using an explicit closure for cloning elements", - "Consider calling the dedicated `cloned` method", - format!( - "{}.cloned()", - snippet_with_applicability(cx, root, "..", &mut applicability) - ), - applicability, - ) - } + path.segments.len() == 1 && path.segments[0].ident == name + } else { + false } } + +fn lint_needless_cloning(cx: &LateContext<'_, '_>, root: Span, receiver: Span) { + span_lint_and_sugg( + cx, + MAP_CLONE, + root.trim_start(receiver).unwrap(), + "You are needlessly cloning iterator elements", + "Remove the map call", + String::new(), + Applicability::MachineApplicable, + ) +} + +fn lint(cx: &LateContext<'_, '_>, replace: Span, root: Span) { + let mut applicability = Applicability::MachineApplicable; + span_lint_and_sugg( + cx, + MAP_CLONE, + replace, + "You are using an explicit closure for cloning elements", + "Consider calling the dedicated `cloned` method", + format!( + "{}.cloned()", + snippet_with_applicability(cx, root, "..", &mut applicability) + ), + applicability, + ) +} diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index eca35422de2..ad5761f5f04 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::{in_macro, iter_input_pats, match_type, method_chain_args, snippet, span_lint_and_then}; use if_chain::if_chain; @@ -140,9 +131,10 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a hir::Expr) -> // If block only contains statements, // reduce `{ X; }` to `X` or `X;` match inner_stmt.node { - hir::StmtKind::Decl(ref d, _) => Some(d.span), - hir::StmtKind::Expr(ref e, _) => Some(e.span), - hir::StmtKind::Semi(_, _) => Some(inner_stmt.span), + hir::StmtKind::Local(ref local) => Some(local.span), + hir::StmtKind::Expr(ref e) => Some(e.span), + hir::StmtKind::Semi(..) => Some(inner_stmt.span), + hir::StmtKind::Item(..) => None, } }, _ => { @@ -259,7 +251,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { return; } - if let hir::StmtKind::Semi(ref expr, _) = stmt.node { + if let hir::StmtKind::Semi(ref expr) = stmt.node { if let Some(arglists) = method_chain_args(expr, &["map"]) { lint_map_unit_fn(cx, stmt, expr, arglists[0]); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 00292eb9603..b003da44236 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant, Constant}; use crate::utils::paths; use crate::utils::sugg::Sugg; diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index 0f8ccc7dedb..a75959e58fa 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_def_path, opt_def_id, paths, snippet, span_lint_and_then, walk_ptrs_ty_depth}; use if_chain::if_chain; use rustc::hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index d231d054610..f83a8b5f7fe 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_def_path, opt_def_id, paths, span_lint}; use rustc::hir::{Expr, ExprKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 0a77b7d2044..d649895e33f 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_def_path, match_qpath, opt_def_id, paths, snippet_with_applicability, span_lint_and_sugg}; use if_chain::if_chain; use rustc::hir::{Expr, ExprKind, MutMutable, QPath}; diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 4473802da3b..6c1befe6e53 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::sugg; use crate::utils::{ @@ -1157,7 +1148,7 @@ fn lint_or_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: Spa /// Checks for the `EXPECT_FUN_CALL` lint. fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: Span, name: &str, args: &[hir::Expr]) { - fn extract_format_args(arg: &hir::Expr) -> Option<&hir::HirVec> { + fn extract_format_args(arg: &hir::Expr) -> Option<(&hir::Expr, &hir::Expr)> { let arg = match &arg.node { hir::ExprKind::AddrOf(_, expr) => expr, hir::ExprKind::MethodCall(method_name, _, args) @@ -1170,8 +1161,8 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: if let hir::ExprKind::Call(ref inner_fun, ref inner_args) = arg.node { if is_expn_of(inner_fun.span, "format").is_some() && inner_args.len() == 1 { - if let hir::ExprKind::Call(_, ref format_args) = inner_args[0].node { - return Some(format_args); + if let hir::ExprKind::Call(_, format_args) = &inner_args[0].node { + return Some((&format_args[0], &format_args[1])); } } } @@ -1183,17 +1174,19 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: cx: &LateContext<'_, '_>, a: &hir::Expr, applicability: &mut Applicability, - ) -> String { + ) -> Vec { if let hir::ExprKind::AddrOf(_, ref format_arg) = a.node { if let hir::ExprKind::Match(ref format_arg_expr, _, _) = format_arg.node { if let hir::ExprKind::Tup(ref format_arg_expr_tup) = format_arg_expr.node { - return snippet_with_applicability(cx, format_arg_expr_tup[0].span, "..", applicability) - .into_owned(); + return format_arg_expr_tup + .iter() + .map(|a| snippet_with_applicability(cx, a.span, "..", applicability).into_owned()) + .collect(); } } }; - snippet(cx, a.span, "..").into_owned() + unreachable!() } fn check_general_case( @@ -1242,14 +1235,11 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: }; let span_replace_word = method_span.with_hi(span.hi()); - if let Some(format_args) = extract_format_args(arg) { + if let Some((fmt_spec, fmt_args)) = extract_format_args(arg) { let mut applicability = Applicability::MachineApplicable; - let args_len = format_args.len(); - let args: Vec = format_args - .into_iter() - .take(args_len - 1) - .map(|a| generate_format_arg_snippet(cx, a, &mut applicability)) - .collect(); + let mut args = vec![snippet(cx, fmt_spec.span, "..").into_owned()]; + + args.extend(generate_format_arg_snippet(cx, fmt_args, &mut applicability)); let sugg = args.join(", "); @@ -1346,12 +1336,10 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp _ => {}, }, hir::Node::Stmt(stmt) => { - if let hir::StmtKind::Decl(ref decl, _) = stmt.node { - if let hir::DeclKind::Local(ref loc) = decl.node { - if let hir::PatKind::Ref(..) = loc.pat.node { - // let ref y = *x borrows x, let ref y = x.clone() does not - return; - } + if let hir::StmtKind::Local(ref loc) = stmt.node { + if let hir::PatKind::Ref(..) = loc.pat.node { + // let ref y = *x borrows x, let ref y = x.clone() does not + return; } } }, diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index c5a22961db9..8d90a4388fc 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::usage::mutated_variables; use crate::utils::{match_qpath, match_trait_method, span_lint}; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 087aa94a7ec..beea667dd43 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant_simple, Constant}; use crate::utils::{match_def_path, opt_def_id, paths, span_lint}; use rustc::hir::*; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index e96261bbe28..88a6d62ee6d 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant, Constant}; use crate::reexport::*; use crate::utils::sugg::Sugg; @@ -286,8 +277,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) { if_chain! { - if let StmtKind::Decl(ref d, _) = s.node; - if let DeclKind::Local(ref l) = d.node; + if let StmtKind::Local(ref l) = s.node; if let PatKind::Binding(an, _, i, None) = l.pat.node; if let Some(ref init) = l.init; then { @@ -325,7 +315,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } }; if_chain! { - if let StmtKind::Semi(ref expr, _) = s.node; + if let StmtKind::Semi(ref expr) = s.node; if let ExprKind::Binary(ref binop, ref a, ref b) = expr.node; if binop.node == BinOpKind::And || binop.node == BinOpKind::Or; if let Some(sugg) = Sugg::hir_opt(cx, a); diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 6b9b90e17a5..2cda1accc56 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{constants, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_then}; use if_chain::if_chain; use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 90503970823..22084bd12cb 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -1,25 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file incorporates work covered by the following copyright and -// permission notice: -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// - // Note: More specifically this lint is largely inspired (aka copied) from // *rustc*'s // [`missing_doc`]. @@ -155,12 +133,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { hir::ItemKind::Struct(..) => "a struct", hir::ItemKind::Trait(..) => "a trait", hir::ItemKind::TraitAlias(..) => "a trait alias", - hir::ItemKind::GlobalAsm(..) => "an assembly blob", hir::ItemKind::Ty(..) => "a type alias", hir::ItemKind::Union(..) => "a union", hir::ItemKind::Existential(..) => "an existential type", hir::ItemKind::ExternCrate(..) | hir::ItemKind::ForeignMod(..) + | hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Impl(..) | hir::ItemKind::Use(..) => return, }; diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 8fb677c7cdf..e9d0d2d77f1 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -1,23 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// - use crate::utils::span_lint; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index c6374afb4de..073d3857c55 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! lint on multiple versions of a crate being used use crate::utils::span_lint; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index e1702cc373b..9aa3cce9d4b 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{higher, span_lint}; use rustc::hir; use rustc::hir::intravisit; diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index ddb8bd30137..5293c80ca2b 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index a114e691228..b85f4b8ad30 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for uses of mutex where an atomic value could be used //! //! This lint is **warn** by default diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 08408c4475c..3b1fea465f5 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for needless boolean results of if-else expressions //! //! This lint is **warn** by default @@ -79,13 +70,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { let reduce = |ret, not| { let mut applicability = Applicability::MachineApplicable; let snip = Sugg::hir_with_applicability(cx, pred, "", &mut applicability); - let snip = if not { !snip } else { snip }; + let mut snip = if not { !snip } else { snip }; - let hint = if ret { - format!("return {}", snip) - } else { - snip.to_string() - }; + if ret { + snip = snip.make_return(); + } + + if parent_node_is_if_expr(&e, &cx) { + snip = snip.blockify() + } span_lint_and_sugg( cx, @@ -93,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { e.span, "this if-then-else expression returns a bool literal", "you can reduce it to", - hint, + snip.to_string(), applicability, ); }; @@ -128,6 +121,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { } } +fn parent_node_is_if_expr<'a, 'b>(expr: &Expr, cx: &LateContext<'a, 'b>) -> bool { + let parent_id = cx.tcx.hir().get_parent_node(expr.id); + let parent_node = cx.tcx.hir().get(parent_id); + + if let rustc::hir::Node::Expr(e) = parent_node { + if let ExprKind::If(_, _, _) = e.node { + return true; + } + } + + false +} + #[derive(Copy, Clone)] pub struct BoolComparison; @@ -276,7 +282,7 @@ fn fetch_bool_block(block: &Block) -> Expression { match (&*block.stmts, block.expr.as_ref()) { (&[], Some(e)) => fetch_bool_expr(&**e), (&[ref e], None) => { - if let StmtKind::Semi(ref e, _) = e.node { + if let StmtKind::Semi(ref e) = e.node { if let ExprKind::Ret(_) = e.node { fetch_bool_expr(&**e) } else { diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index 80c9fc549d9..f21cbe8b9ad 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for needless address of operations (`&`) //! //! This lint is **warn** by default diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index e2801a2e1e0..792e38e1875 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for useless borrowed references. //! //! This lint is **warn** by default diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 9044245c5a6..0b5ea255d7f 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for continue statements in loops that are redundant. //! //! For example, the lint would catch diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 9184a486374..cb1fe475a1e 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::ptr::get_spans; use crate::utils::{ get_trait_def_id, implements_trait, in_macro, is_copy, is_self, match_type, multispan_sugg, paths, snippet, @@ -377,8 +368,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { Node::Stmt(s) => { // `let = x;` if_chain! { - if let StmtKind::Decl(ref decl, _) = s.node; - if let DeclKind::Local(ref local) = decl.node; + if let StmtKind::Local(ref local) = s.node; then { self.spans_need_deref .entry(vid) diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 993aa73f6f7..ab22e2c19b3 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::hir::{Expr, ExprKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index 6642f674da8..919c771ccf5 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use if_chain::if_chain; use rustc::hir::*; use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass}; diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 55edca6cece..846794d8b99 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use if_chain::if_chain; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 832311dc027..37e0446faed 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::paths; use crate::utils::sugg::DiagnosticBuilderExt; use crate::utils::{get_trait_def_id, implements_trait, return_ty, same_tys, span_lint_node_and_then}; diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index c2cffadf6c1..648c198df08 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{has_drop, in_macro, snippet_opt, span_lint, span_lint_and_sugg}; use rustc::hir::def::Def; use rustc::hir::{BinOpKind, BlockCheckMode, Expr, ExprKind, Stmt, StmtKind, UnsafeSource}; @@ -113,7 +104,7 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - if let StmtKind::Semi(ref expr, _) = stmt.node { + if let StmtKind::Semi(ref expr) = stmt.node { if has_no_effect(cx, expr) { span_lint(cx, NO_EFFECT, stmt.span, "statement with no effect"); } else if let Some(reduced) = reduce_expression(cx, expr) { diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 57482ff4179..11295c3c092 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for uses of const which the type is not Freeze (Cell-free). //! //! This lint is **deny** by default. diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 2ab7d7e62f3..f39cae46de0 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{span_lint, span_lint_and_then}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/ok_if_let.rs b/clippy_lints/src/ok_if_let.rs index e060220d56b..5f15662c90c 100644 --- a/clippy_lints/src/ok_if_let.rs +++ b/clippy_lints/src/ok_if_let.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_type, method_chain_args, paths, snippet, span_help_and_lint}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index f6773dcb158..fe572d86c1b 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty}; use rustc::hir::{Expr, ExprKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; @@ -81,7 +72,7 @@ fn get_open_options(cx: &LateContext<'_, '_>, argument: &Expr, options: &mut Vec if let Spanned { node: LitKind::Bool(lit), .. - } = **span + } = *span { if lit { Argument::True diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index 8df3ba4197f..d76a9f96eff 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{span_lint, SpanlessEq}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index 822361175d6..61646613b11 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_direct_expn_of, is_expn_of, match_def_path, opt_def_id, paths, resolve_node, span_lint}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index c33367e7a3f..03d2d5d3bab 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_automatically_derived, span_lint_node}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 20a797937de..44e82984c54 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{in_macro, snippet_with_applicability, span_lint_and_sugg}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index f45bb54d191..87cd9892893 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Checks for usage of `&Vec[_]` and `&String`. use crate::utils::ptr::get_spans; diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 8d6bca8b689..32d330ac171 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils; use rustc::{declare_tool_lint, hir, lint, lint_array}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index c1a76eed928..03f6ea12e00 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::sugg::Sugg; use if_chain::if_chain; use rustc::hir::def::Def; @@ -148,7 +139,7 @@ impl Pass { if_chain! { if block.stmts.len() == 1; if let Some(expr) = block.stmts.iter().last(); - if let StmtKind::Semi(ref expr, _) = expr.node; + if let StmtKind::Semi(ref expr) = expr.node; if let ExprKind::Ret(ref ret_expr) = expr.node; if let &Some(ref ret_expr) = ret_expr; diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index a0870ea72d0..2e01afc2258 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::sugg::Sugg; use crate::utils::{get_trait_def_id, higher, implements_trait, SpanlessEq}; use crate::utils::{is_integer_literal, paths, snippet, snippet_opt, span_lint, span_lint_and_then}; diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 1983cb6cbc4..f584ef19d5a 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -1,12 +1,3 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{ has_drop, in_macro, is_copy, match_def_path, match_type, paths, snippet_opt, span_lint_node, span_lint_node_and_then, walk_ptrs_ty_depth, diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index a53df6a292a..9076d67cb14 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint_and_sugg; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/redundant_pattern_matching.rs b/clippy_lints/src/redundant_pattern_matching.rs index bd194dd7bc3..bc61ee8e7e3 100644 --- a/clippy_lints/src/redundant_pattern_matching.rs +++ b/clippy_lints/src/redundant_pattern_matching.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_qpath, paths, snippet, span_lint_and_then}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index 54a9c0336f0..8d2543ef618 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{snippet_with_applicability, span_lint_and_sugg}; use if_chain::if_chain; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 021237d38c0..6a58a6e73c7 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant, Constant}; use crate::utils::{is_expn_of, match_def_path, match_type, opt_def_id, paths, span_help_and_lint, span_lint}; use if_chain::if_chain; diff --git a/clippy_lints/src/replace_consts.rs b/clippy_lints/src/replace_consts.rs index d905d3dbdf4..ea51e4711cd 100644 --- a/clippy_lints/src/replace_consts.rs +++ b/clippy_lints/src/replace_consts.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{match_def_path, span_lint_and_sugg}; use if_chain::if_chain; use rustc::hir; diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 1ef03a77bd7..d81d04b81d3 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{in_macro, match_path_ast, snippet_opt, span_lint_and_then, span_note_and_lint}; use if_chain::if_chain; use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index d381f8c4419..da8675b38da 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_trait_def_id, paths, span_lint}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 329e83e100b..c99b00bb98f 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::reexport::*; use crate::utils::{contains_name, higher, iter_input_pats, snippet, span_lint_and_then}; use rustc::hir::intravisit::FnKind; @@ -124,8 +115,9 @@ fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, binding let len = bindings.len(); for stmt in &block.stmts { match stmt.node { - StmtKind::Decl(ref decl, _) => check_decl(cx, decl, bindings), - StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => check_expr(cx, e, bindings), + StmtKind::Local(ref local) => check_local(cx, local, bindings), + StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => check_expr(cx, e, bindings), + StmtKind::Item(..) => {}, } } if let Some(ref o) = block.expr { @@ -134,30 +126,28 @@ fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, binding bindings.truncate(len); } -fn check_decl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings: &mut Vec<(Name, Span)>) { - if in_external_macro(cx.sess(), decl.span) { +fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local, bindings: &mut Vec<(Name, Span)>) { + if in_external_macro(cx.sess(), local.span) { return; } - if higher::is_from_for_desugar(decl) { + if higher::is_from_for_desugar(local) { return; } - if let DeclKind::Local(ref local) = decl.node { - let Local { - ref pat, - ref ty, - ref init, - span, - .. - } = **local; - if let Some(ref t) = *ty { - check_ty(cx, t, bindings) - } - if let Some(ref o) = *init { - check_expr(cx, o, bindings); - check_pat(cx, pat, Some(o), span, bindings); - } else { - check_pat(cx, pat, None, span, bindings); - } + let Local { + ref pat, + ref ty, + ref init, + span, + .. + } = *local; + if let Some(ref t) = *ty { + check_ty(cx, t, bindings) + } + if let Some(ref o) = *init { + check_expr(cx, o, bindings); + check_pat(cx, pat, Some(o), span, bindings); + } else { + check_pat(cx, pat, None, span, bindings); } } diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index fde679b6ed2..aea414065d8 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::sugg::Sugg; use crate::utils::{get_enclosing_block, match_qpath, span_lint_and_then, SpanlessEq}; use if_chain::if_chain; @@ -100,8 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { // Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)` if_chain! { - if let StmtKind::Decl(ref decl, _) = stmt.node; - if let DeclKind::Local(ref local) = decl.node; + if let StmtKind::Local(ref local) = stmt.node; if let PatKind::Binding(BindingAnnotation::Mutable, _, variable_name, None) = local.pat.node; if let Some(ref init) = local.init; if let Some(ref len_arg) = Self::is_vec_with_capacity(init); @@ -113,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { len_expr: len_arg, }; - Self::search_initialization(cx, vi, stmt.node.id()); + Self::search_initialization(cx, vi, stmt.id); } } } @@ -296,7 +286,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> { fn visit_stmt(&mut self, stmt: &'tcx Stmt) { if self.initialization_found { match stmt.node { - StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => { + StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => { self.search_slow_extend_filling(expr); self.search_slow_resize_filling(expr); }, diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 5414a1ac0de..ffec764fd5e 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::SpanlessEq; use crate::utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, span_lint_and_sugg, walk_ptrs_ty}; use rustc::hir::*; diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 04f8e4993f0..c6dd9504857 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_trait_def_id, span_lint}; use if_chain::if_chain; use rustc::hir; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 4c4fda26253..ddf33fcc411 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::sugg::Sugg; use crate::utils::{ differing_macro_contexts, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty, SpanlessEq, @@ -80,17 +71,16 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { for w in block.stmts.windows(3) { if_chain! { // let t = foo(); - if let StmtKind::Decl(ref tmp, _) = w[0].node; - if let DeclKind::Local(ref tmp) = tmp.node; + if let StmtKind::Local(ref tmp) = w[0].node; if let Some(ref tmp_init) = tmp.init; if let PatKind::Binding(_, _, ident, None) = tmp.pat.node; // foo() = bar(); - if let StmtKind::Semi(ref first, _) = w[1].node; + if let StmtKind::Semi(ref first) = w[1].node; if let ExprKind::Assign(ref lhs1, ref rhs1) = first.node; // bar() = t; - if let StmtKind::Semi(ref second, _) = w[2].node; + if let StmtKind::Semi(ref second) = w[2].node; if let ExprKind::Assign(ref lhs2, ref rhs2) = second.node; if let ExprKind::Path(QPath::Resolved(None, ref rhs2)) = rhs2.node; if rhs2.segments.len() == 1; @@ -169,8 +159,8 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) { for w in block.stmts.windows(2) { if_chain! { - if let StmtKind::Semi(ref first, _) = w[0].node; - if let StmtKind::Semi(ref second, _) = w[1].node; + if let StmtKind::Semi(ref first) = w[0].node; + if let StmtKind::Semi(ref second) = w[1].node; if !differing_macro_contexts(first.span, second.span); if let ExprKind::Assign(ref lhs0, ref rhs0) = first.node; if let ExprKind::Assign(ref lhs1, ref rhs1) = second.node; diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index 381efd57135..c8a01c3668c 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::is_adjusted; use crate::utils::span_lint; use rustc::hir::def::Def; diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index be3475f6703..02205cfbd68 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{last_path_segment, match_def_path, paths, snippet, span_lint, span_lint_and_then}; use crate::utils::{opt_def_id, sugg}; use if_chain::if_chain; diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index efa6c0486eb..5ab73758301 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::cmp; use crate::utils::{in_macro, is_copy, is_self_ty, snippet, span_lint_and_sugg}; diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index f9ed38e52a0..898fd5a9808 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - #![allow(clippy::default_hash_types)] use crate::consts::{constant, Constant}; @@ -473,28 +463,6 @@ declare_clippy_lint! { "creating a let binding to a value of unit type, which usually can't be used afterwards" } -fn check_let_unit(cx: &LateContext<'_, '_>, decl: &Decl) { - if let DeclKind::Local(ref local) = decl.node { - if is_unit(cx.tables.pat_ty(&local.pat)) { - if in_external_macro(cx.sess(), 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, "..") - ), - ); - } - } -} - impl LintPass for LetPass { fn get_lints(&self) -> LintArray { lint_array!(LET_UNIT_VALUE) @@ -502,8 +470,26 @@ impl LintPass for LetPass { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetPass { - fn check_decl(&mut self, cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl) { - check_let_unit(cx, decl) + fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { + if let StmtKind::Local(ref local) = stmt.node { + if is_unit(cx.tables.pat_ty(&local.pat)) { + if in_external_macro(cx.sess(), stmt.span) || in_macro(local.pat.span) { + return; + } + if higher::is_from_for_desugar(local) { + return; + } + span_lint( + cx, + LET_UNIT_VALUE, + stmt.span, + &format!( + "this let-binding has unit value. Consider omitting `let {} =`", + snippet(cx, local.pat.span, "..") + ), + ); + } + } } } diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index a38fe4a5aa9..d9207fd2131 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_allowed, snippet, span_help_and_lint}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 626b1c31013..6beda8ce706 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index 43f980c72c4..27deb0d9945 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{is_try, match_qpath, match_trait_method, paths, span_lint}; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; @@ -50,7 +41,7 @@ impl LintPass for UnusedIoAmount { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount { fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { let expr = match s.node { - hir::StmtKind::Semi(ref expr, _) | hir::StmtKind::Expr(ref expr, _) => &**expr, + hir::StmtKind::Semi(ref expr) | hir::StmtKind::Expr(ref expr) => &**expr, _ => return, }; diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index 766431c3687..d53fd265d37 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{in_macro, span_lint}; use rustc::hir; use rustc::hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index b61b3b975f5..369b33363b5 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use if_chain::if_chain; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 5ec809f1b76..88cf01987b5 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint_and_sugg; use if_chain::if_chain; use rustc::hir::def::{CtorKind, Def}; @@ -65,10 +56,15 @@ impl LintPass for UseSelf { const SEGMENTS_MSG: &str = "segments should be composed of at least 1 element"; fn span_use_self_lint(cx: &LateContext<'_, '_>, path: &Path) { + // path segments only include actual path, no methods or fields + let last_path_span = path.segments.last().expect(SEGMENTS_MSG).ident.span; + // only take path up to the end of last_path_span + let span = path.span.with_hi(last_path_span.hi()); + span_lint_and_sugg( cx, USE_SELF, - path.span, + span, "unnecessary structure name repetition", "use the applicable keyword", "Self".to_owned(), diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index e13c64b5c78..9623c6cbdad 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -1,19 +1,10 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! A group of attributes that can be attached to Rust code in order //! to generate a clippy lint detecting said code automatically. use crate::utils::get_attr; use rustc::hir; use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; -use rustc::hir::{BindingAnnotation, DeclKind, Expr, ExprKind, Pat, PatKind, QPath, Stmt, StmtKind, TyKind}; +use rustc::hir::{BindingAnnotation, Expr, ExprKind, Pat, PatKind, QPath, Stmt, StmtKind, TyKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; use rustc_data_structures::fx::FxHashMap; @@ -269,6 +260,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { match lit.node { LitKind::Bool(val) => println!(" if let LitKind::Bool({:?}) = {}.node;", val, lit_pat), LitKind::Char(c) => println!(" if let LitKind::Char({:?}) = {}.node;", c, lit_pat), + LitKind::Err(val) => println!(" if let LitKind::Err({}) = {}.node;", val, lit_pat), LitKind::Byte(b) => println!(" if let LitKind::Byte({}) = {}.node;", b, lit_pat), // FIXME: also check int type LitKind::Int(i, _) => println!(" if let LitKind::Int({}, _) = {}.node;", i, lit_pat), @@ -634,35 +626,26 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { print!(" if let StmtKind::"); let current = format!("{}.node", self.current); match s.node { - // Could be an item or a local (let) binding: - StmtKind::Decl(ref decl, _) => { - let decl_pat = self.next("decl"); - println!("Decl(ref {}, _) = {}", decl_pat, current); - print!(" if let DeclKind::"); - let current = format!("{}.node", decl_pat); - match decl.node { - // A local (let) binding: - DeclKind::Local(ref local) => { - let local_pat = self.next("local"); - println!("Local(ref {}) = {};", local_pat, current); - if let Some(ref init) = local.init { - let init_pat = self.next("init"); - println!(" if let Some(ref {}) = {}.init", init_pat, local_pat); - self.current = init_pat; - self.visit_expr(init); - } - self.current = format!("{}.pat", local_pat); - self.visit_pat(&local.pat); - }, - // An item binding: - DeclKind::Item(_) => { - println!("Item(item_id) = {};", current); - }, + // A local (let) binding: + StmtKind::Local(ref local) => { + let local_pat = self.next("local"); + println!("Local(ref {}) = {};", local_pat, current); + if let Some(ref init) = local.init { + let init_pat = self.next("init"); + println!(" if let Some(ref {}) = {}.init", init_pat, local_pat); + self.current = init_pat; + self.visit_expr(init); } + self.current = format!("{}.pat", local_pat); + self.visit_pat(&local.pat); + }, + // An item binding: + StmtKind::Item(_) => { + println!("Item(item_id) = {};", current); }, // Expr without trailing semi-colon (must have unit type): - StmtKind::Expr(ref e, _) => { + StmtKind::Expr(ref e) => { let e_pat = self.next("e"); println!("Expr(ref {}, _) = {}", e_pat, current); self.current = e_pat; @@ -670,7 +653,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { }, // Expr with trailing semi-colon (may have any type): - StmtKind::Semi(ref e, _) => { + StmtKind::Semi(ref e) => { let e_pat = self.next("e"); println!("Semi(ref {}, _) = {}", e_pat, current); self.current = e_pat; diff --git a/clippy_lints/src/utils/camel_case.rs b/clippy_lints/src/utils/camel_case.rs index f58f3e3b98a..b49287b30d1 100644 --- a/clippy_lints/src/utils/camel_case.rs +++ b/clippy_lints/src/utils/camel_case.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - /// Return the index of the character after the first camel-case component of /// `s`. pub fn until(s: &str) -> usize { diff --git a/clippy_lints/src/utils/comparisons.rs b/clippy_lints/src/utils/comparisons.rs index 8b6a97a505c..31e20f37e20 100644 --- a/clippy_lints/src/utils/comparisons.rs +++ b/clippy_lints/src/utils/comparisons.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Utility functions about comparison operators. #![deny(clippy::missing_docs_in_private_items)] diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index da3a256a83d..55256a25427 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Read configurations files. #![deny(clippy::missing_docs_in_private_items)] diff --git a/clippy_lints/src/utils/constants.rs b/clippy_lints/src/utils/constants.rs index dde70d8e2cc..522932f054d 100644 --- a/clippy_lints/src/utils/constants.rs +++ b/clippy_lints/src/utils/constants.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! This module contains some useful constants. #![deny(clippy::missing_docs_in_private_items)] diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 214b3dc10e6..537cdf55eb1 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! This module contains functions for retrieve the original AST from lowered //! `hir`. @@ -157,8 +148,8 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O } } -/// Checks if a `let` decl is from a `for` loop desugaring. -pub fn is_from_for_desugar(decl: &hir::Decl) -> bool { +/// Checks if a `let` statement is from a `for` loop desugaring. +pub fn is_from_for_desugar(local: &hir::Local) -> bool { // This will detect plain for-loops without an actual variable binding: // // ``` @@ -167,8 +158,7 @@ pub fn is_from_for_desugar(decl: &hir::Decl) -> bool { // } // ``` if_chain! { - if let hir::DeclKind::Local(ref loc) = decl.node; - if let Some(ref expr) = loc.init; + if let Some(ref expr) = local.init; if let hir::ExprKind::Match(_, _, hir::MatchSource::ForLoopDesugar) = expr.node; then { return true; @@ -183,12 +173,8 @@ pub fn is_from_for_desugar(decl: &hir::Decl) -> bool { // // anything // } // ``` - if_chain! { - if let hir::DeclKind::Local(ref loc) = decl.node; - if let hir::LocalSource::ForLoopDesugar = loc.source; - then { - return true; - } + if let hir::LocalSource::ForLoopDesugar = local.source { + return true; } false @@ -204,11 +190,10 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)> if let hir::ExprKind::Loop(ref block, _, _) = arms[0].body.node; if block.expr.is_none(); if let [ _, _, ref let_stmt, ref body ] = *block.stmts; - if let hir::StmtKind::Decl(ref decl, _) = let_stmt.node; - if let hir::DeclKind::Local(ref decl) = decl.node; - if let hir::StmtKind::Expr(ref expr, _) = body.node; + if let hir::StmtKind::Local(ref local) = let_stmt.node; + if let hir::StmtKind::Expr(ref expr) = body.node; then { - return Some((&*decl.pat, &iterargs[0], expr)); + return Some((&*local.pat, &iterargs[0], expr)); } } None diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 377e56ddcac..a176830be26 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant_context, constant_simple}; use crate::utils::differing_macro_contexts; use rustc::hir::*; @@ -52,17 +43,14 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { /// Check whether two statements are the same. pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool { match (&left.node, &right.node) { - (&StmtKind::Decl(ref l, _), &StmtKind::Decl(ref r, _)) => { - if let (&DeclKind::Local(ref l), &DeclKind::Local(ref r)) = (&l.node, &r.node) { - self.eq_pat(&l.pat, &r.pat) - && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r)) - && both(&l.init, &r.init, |l, r| self.eq_expr(l, r)) - } else { - false - } + (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => { + self.eq_pat(&l.pat, &r.pat) + && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r)) + && both(&l.init, &r.init, |l, r| self.eq_expr(l, r)) + }, + (&StmtKind::Expr(ref l), &StmtKind::Expr(ref r)) | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => { + self.eq_expr(l, r) }, - (&StmtKind::Expr(ref l, _), &StmtKind::Expr(ref r, _)) - | (&StmtKind::Semi(ref l, _), &StmtKind::Semi(ref r, _)) => self.eq_expr(l, r), _ => false, } } @@ -652,23 +640,24 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { pub fn hash_stmt(&mut self, b: &Stmt) { match b.node { - StmtKind::Decl(ref decl, _) => { - let c: fn(_, _) -> _ = StmtKind::Decl; + StmtKind::Local(ref local) => { + let c: fn(_) -> _ = StmtKind::Local; c.hash(&mut self.s); - - if let DeclKind::Local(ref local) = decl.node { - if let Some(ref init) = local.init { - self.hash_expr(init); - } + if let Some(ref init) = local.init { + self.hash_expr(init); } }, - StmtKind::Expr(ref expr, _) => { - let c: fn(_, _) -> _ = StmtKind::Expr; + StmtKind::Item(..) => { + let c: fn(_) -> _ = StmtKind::Item; + c.hash(&mut self.s); + }, + StmtKind::Expr(ref expr) => { + let c: fn(_) -> _ = StmtKind::Expr; c.hash(&mut self.s); self.hash_expr(expr); }, - StmtKind::Semi(ref expr, _) => { - let c: fn(_, _) -> _ = StmtKind::Semi; + StmtKind::Semi(ref expr) => { + let c: fn(_) -> _ = StmtKind::Semi; c.hash(&mut self.s); self.hash_expr(expr); }, diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 98ddcf945d9..4116f8ffbaf 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! checks for attributes use crate::utils::get_attr; @@ -131,8 +122,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { return; } match stmt.node { - hir::StmtKind::Decl(ref decl, _) => print_decl(cx, decl), - hir::StmtKind::Expr(ref e, _) | hir::StmtKind::Semi(ref e, _) => print_expr(cx, e, 0), + hir::StmtKind::Local(ref local) => { + println!("local variable of type {}", cx.tables.node_id_to_type(local.hir_id)); + println!("pattern:"); + print_pat(cx, &local.pat, 0); + if let Some(ref e) = local.init { + println!("init expression:"); + print_expr(cx, e, 0); + } + }, + hir::StmtKind::Item(_) => println!("item decl"), + hir::StmtKind::Expr(ref e) | hir::StmtKind::Semi(ref e) => print_expr(cx, e, 0), } } // fn check_foreign_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx @@ -148,21 +148,6 @@ fn has_attr(attrs: &[Attribute]) -> bool { get_attr(attrs, "dump").count() > 0 } -fn print_decl(cx: &LateContext<'_, '_>, decl: &hir::Decl) { - match decl.node { - hir::DeclKind::Local(ref local) => { - println!("local variable of type {}", cx.tables.node_id_to_type(local.hir_id)); - println!("pattern:"); - print_pat(cx, &local.pat, 0); - if let Some(ref e) = local.init { - println!("init expression:"); - print_expr(cx, e, 0); - } - }, - hir::DeclKind::Item(_) => println!("item decl"), - } -} - #[allow(clippy::similar_names)] fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) { let ind = " ".repeat(indent); diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index be412f36edd..788fc434d51 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{ match_def_path, match_type, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty, }; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 9b5e18413a2..c83b0f155fc 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::reexport::*; use if_chain::if_chain; use matches::matches; @@ -73,9 +64,25 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool { /// ``` pub fn in_constant(cx: &LateContext<'_, '_>, id: NodeId) -> bool { let parent_id = cx.tcx.hir().get_parent(id); - match cx.tcx.hir().body_owner_kind(parent_id) { - hir::BodyOwnerKind::Fn => false, - hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(..) => true, + match cx.tcx.hir().get(parent_id) { + Node::Item(&Item { + node: ItemKind::Const(..), + .. + }) + | Node::TraitItem(&TraitItem { + node: TraitItemKind::Const(..), + .. + }) + | Node::ImplItem(&ImplItem { + node: ImplItemKind::Const(..), + .. + }) + | Node::AnonConst(_) + | Node::Item(&Item { + node: ItemKind::Static(..), + .. + }) => true, + _ => false, } } diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs index 0779d77936f..d2dc2812575 100644 --- a/clippy_lints/src/utils/paths.rs +++ b/clippy_lints/src/utils/paths.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! This module contains paths to types and functions Clippy needs to know //! about. @@ -35,6 +26,7 @@ pub const DOUBLE_ENDED_ITERATOR: [&str; 4] = ["core", "iter", "traits", "DoubleE pub const DROP: [&str; 3] = ["core", "mem", "drop"]; pub const DURATION: [&str; 3] = ["core", "time", "Duration"]; pub const EARLY_CONTEXT: [&str; 4] = ["rustc", "lint", "context", "EarlyContext"]; +pub const FMT_ARGUMENTS_NEWV1: [&str; 4] = ["core", "fmt", "Arguments", "new_v1"]; pub const FMT_ARGUMENTS_NEWV1FORMATTED: [&str; 4] = ["core", "fmt", "Arguments", "new_v1_formatted"]; pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"]; pub const FROM_TRAIT: [&str; 3] = ["core", "convert", "From"]; diff --git a/clippy_lints/src/utils/ptr.rs b/clippy_lints/src/utils/ptr.rs index 3f589c3b687..3d221fbfb81 100644 --- a/clippy_lints/src/utils/ptr.rs +++ b/clippy_lints/src/utils/ptr.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{get_pat_name, match_var, snippet}; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc::hir::*; diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index a8bc0f3fca1..b95ce17ed93 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Contains utility functions to generate suggestions. #![deny(clippy::missing_docs_in_private_items)] @@ -215,6 +206,17 @@ impl<'a> Sugg<'a> { make_unop("&mut *", self) } + /// Convenience method to transform suggestion into a return call + pub fn make_return(self) -> Sugg<'static> { + Sugg::NonParen(Cow::Owned(format!("return {}", self))) + } + + /// Convenience method to transform suggestion into a block + /// where the suggestion is a trailing expression + pub fn blockify(self) -> Sugg<'static> { + Sugg::NonParen(Cow::Owned(format!("{{ {} }}", self))) + } + /// Convenience method to create the `..` or `...` /// suggestion. #[allow(dead_code)] @@ -587,3 +589,21 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error self.span_suggestion_with_applicability(remove_span, msg, String::new(), applicability); } } + +#[cfg(test)] +mod test { + use super::Sugg; + use std::borrow::Cow; + + const SUGGESTION: Sugg<'static> = Sugg::NonParen(Cow::Borrowed("function_call()")); + + #[test] + fn make_return_transform_sugg_into_a_return_call() { + assert_eq!("return function_call()", SUGGESTION.make_return().to_string()); + } + + #[test] + fn blockify_transforms_sugg_into_a_block() { + assert_eq!("{ function_call() }", SUGGESTION.blockify().to_string()); + } +} diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index e4d3fa29996..a3d3518ef98 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use rustc::lint::LateContext; use rustc::hir::def::Def; diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 2f259bf8bca..407722bc66e 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::constant; use crate::utils::{higher, is_copy, snippet_with_applicability, span_lint_and_sugg}; use if_chain::if_chain; diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index 38bce9da932..e3c35286251 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::span_lint; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 6531e71a9fa..c8c291c8cc8 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::utils::{snippet_with_applicability, span_lint, span_lint_and_sugg}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; @@ -14,7 +5,7 @@ use rustc_errors::Applicability; use std::borrow::Cow; use syntax::ast::*; use syntax::parse::{parser, token}; -use syntax::tokenstream::{ThinTokenStream, TokenStream}; +use syntax::tokenstream::TokenStream; /// **What it does:** This lint warns when you use `println!("")` to /// print a newline. @@ -270,9 +261,9 @@ impl EarlyLintPass for Pass { /// ```rust,ignore /// (Some("string to write: {}"), Some(buf)) /// ``` -fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> (Option, Option) { +fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (Option, Option) { use fmt_macros::*; - let tts = TokenStream::from(tts.clone()); + let tts = tts.clone(); let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, None, false, false); let mut expr: Option = None; if is_write { diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 93606e378d9..962d42e631e 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use crate::consts::{constant_simple, Constant}; use crate::utils::span_help_and_lint; use if_chain::if_chain; diff --git a/clippy_workspace_tests/src/main.rs b/clippy_workspace_tests/src/main.rs index 7af28f80b9b..f79c691f085 100644 --- a/clippy_workspace_tests/src/main.rs +++ b/clippy_workspace_tests/src/main.rs @@ -1,12 +1,2 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - fn main() { } diff --git a/clippy_workspace_tests/subcrate/src/lib.rs b/clippy_workspace_tests/subcrate/src/lib.rs index fd694f68ca6..e69de29bb2d 100644 --- a/clippy_workspace_tests/subcrate/src/lib.rs +++ b/clippy_workspace_tests/subcrate/src/lib.rs @@ -1,10 +0,0 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - diff --git a/mini-macro/src/lib.rs b/mini-macro/src/lib.rs index b6405975862..0a96be71b35 100644 --- a/mini-macro/src/lib.rs +++ b/mini-macro/src/lib.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - #![feature(proc_macro_quote, proc_macro_hygiene)] extern crate proc_macro; diff --git a/pre_publish.sh b/pre_publish.sh index fc7ae212fcf..3602f671e3d 100755 --- a/pre_publish.sh +++ b/pre_publish.sh @@ -1,16 +1,5 @@ #!/bin/bash -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - - set -e ./util/update_lints.py diff --git a/rustc_tools_util/README.md b/rustc_tools_util/README.md index b101f55e509..a88f47e4dbc 100644 --- a/rustc_tools_util/README.md +++ b/rustc_tools_util/README.md @@ -49,7 +49,7 @@ This gives the following output in clippy: ## License -Copyright 2014-2018 The Rust Project Developers +Copyright 2014-2019 The Rust Project Developers Licensed under the Apache License, Version 2.0 or the MIT license diff --git a/rustc_tools_util/src/lib.rs b/rustc_tools_util/src/lib.rs index 49bfb7d8b59..f13fa12ccca 100644 --- a/rustc_tools_util/src/lib.rs +++ b/rustc_tools_util/src/lib.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::env; #[macro_export] diff --git a/src/driver.rs b/src/driver.rs index 269228988f7..2faa77785bb 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern:yummy #![feature(box_syntax)] #![feature(rustc_private)] diff --git a/src/lib.rs b/src/lib.rs index ef6f4cd7b3d..be0c10c8ff2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern:cargo-clippy #![feature(plugin_registrar)] #![feature(rustc_private)] diff --git a/src/main.rs b/src/main.rs index 369528f1954..eefababb96d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern:yummy #![feature(box_syntax)] #![feature(rustc_private)] diff --git a/tests/auxiliary/test_macro.rs b/tests/auxiliary/test_macro.rs index d5fef588971..624ca892add 100644 --- a/tests/auxiliary/test_macro.rs +++ b/tests/auxiliary/test_macro.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - pub trait A {} macro_rules! __implicit_hasher_test_macro { diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 005c2ce33f9..c67b6f08c9f 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(test)] use compiletest_rs as compiletest; diff --git a/tests/dogfood.rs b/tests/dogfood.rs index c1f02b9fcef..87fe5887bcc 100644 --- a/tests/dogfood.rs +++ b/tests/dogfood.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[test] fn dogfood() { if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) { diff --git a/tests/matches.rs b/tests/matches.rs index 7d099665259..15a0ea503bf 100644 --- a/tests/matches.rs +++ b/tests/matches.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(rustc_private)] extern crate syntax; diff --git a/tests/missing-test-files.rs b/tests/missing-test-files.rs new file mode 100644 index 00000000000..558e001d3d1 --- /dev/null +++ b/tests/missing-test-files.rs @@ -0,0 +1,54 @@ +use std::fs::{self, DirEntry}; +use std::path::Path; + +#[test] +fn test_missing_tests() { + let missing_files = explore_directory(Path::new("./tests")); + if !missing_files.is_empty() { + assert!( + false, + format!( + "Didn't see a test file for the following files:\n\n{}\n", + missing_files + .iter() + .map(|s| format!("\t{}", s)) + .collect::>() + .join("\n") + ) + ); + } +} + +/* +Test for missing files. + +Since rs files are alphabetically before stderr/stdout, we can sort by the full name +and iter in that order. If we've seen the file stem for the first time and it's not +a rust file, it means the rust file has to be missing. +*/ +fn explore_directory(dir: &Path) -> Vec { + let mut missing_files: Vec = Vec::new(); + let mut current_file = String::new(); + let mut files: Vec = fs::read_dir(dir).unwrap().filter_map(Result::ok).collect(); + files.sort_by_key(|e| e.path()); + for entry in &files { + let path = entry.path(); + if path.is_dir() { + missing_files.extend(explore_directory(&path)); + } else { + let file_stem = path.file_stem().unwrap().to_str().unwrap().to_string(); + if let Some(ext) = path.extension() { + match ext.to_str().unwrap() { + "rs" => current_file = file_stem.clone(), + "stderr" | "stdout" => { + if file_stem != current_file { + missing_files.push(path.to_str().unwrap().to_string()); + } + }, + _ => continue, + }; + } + } + } + missing_files +} diff --git a/tests/needless_continue_helpers.rs b/tests/needless_continue_helpers.rs index e0dcd035c58..255653b4737 100644 --- a/tests/needless_continue_helpers.rs +++ b/tests/needless_continue_helpers.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // Tests for the various helper functions used by the needless_continue // lint that don't belong in utils. diff --git a/tests/run-pass/associated-constant-ice.rs b/tests/run-pass/associated-constant-ice.rs index df84009c889..2c5c90683cc 100644 --- a/tests/run-pass/associated-constant-ice.rs +++ b/tests/run-pass/associated-constant-ice.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - pub trait Trait { const CONSTANT: u8; } diff --git a/tests/run-pass/cc_seme.rs b/tests/run-pass/cc_seme.rs index 7e1f13d4460..169403df562 100644 --- a/tests/run-pass/cc_seme.rs +++ b/tests/run-pass/cc_seme.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(dead_code)] enum Baz { One, diff --git a/tests/run-pass/enum-glob-import-crate.rs b/tests/run-pass/enum-glob-import-crate.rs index 6e64f174e4c..dca32aa3b56 100644 --- a/tests/run-pass/enum-glob-import-crate.rs +++ b/tests/run-pass/enum-glob-import-crate.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::all)] #![allow(unused_imports)] diff --git a/tests/run-pass/ice-1588.rs b/tests/run-pass/ice-1588.rs index 87f2afaa602..6a5bf429f2d 100644 --- a/tests/run-pass/ice-1588.rs +++ b/tests/run-pass/ice-1588.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::all)] fn main() { diff --git a/tests/run-pass/ice-1782.rs b/tests/run-pass/ice-1782.rs index ddb4367c914..81af88962a6 100644 --- a/tests/run-pass/ice-1782.rs +++ b/tests/run-pass/ice-1782.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code, unused_variables)] /// Should not trigger an ICE in `SpanlessEq` / `consts::constant` diff --git a/tests/run-pass/ice-1969.rs b/tests/run-pass/ice-1969.rs index 2a0cdb19fce..eab4f338f97 100644 --- a/tests/run-pass/ice-1969.rs +++ b/tests/run-pass/ice-1969.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::all)] fn main() {} diff --git a/tests/run-pass/ice-2499.rs b/tests/run-pass/ice-2499.rs index 804f416800c..45b3b1869dd 100644 --- a/tests/run-pass/ice-2499.rs +++ b/tests/run-pass/ice-2499.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)] /// Should not trigger an ICE in `SpanlessHash` / `consts::constant` diff --git a/tests/run-pass/ice-2594.rs b/tests/run-pass/ice-2594.rs index e91b71b3a1c..3f3986b6fc6 100644 --- a/tests/run-pass/ice-2594.rs +++ b/tests/run-pass/ice-2594.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code, unused_variables)] /// Should not trigger an ICE in `SpanlessHash` / `consts::constant` diff --git a/tests/run-pass/ice-2727.rs b/tests/run-pass/ice-2727.rs index 9d00f2bacd0..79c6f1c55db 100644 --- a/tests/run-pass/ice-2727.rs +++ b/tests/run-pass/ice-2727.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - pub fn f(new: fn()) { new(); } diff --git a/tests/run-pass/ice-2760.rs b/tests/run-pass/ice-2760.rs index 533cc3b952a..949e273997c 100644 --- a/tests/run-pass/ice-2760.rs +++ b/tests/run-pass/ice-2760.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( unused_variables, clippy::blacklisted_name, diff --git a/tests/run-pass/ice-2774.rs b/tests/run-pass/ice-2774.rs index ae51f036207..2cc19ae32b8 100644 --- a/tests/run-pass/ice-2774.rs +++ b/tests/run-pass/ice-2774.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::collections::HashSet; // See https://github.com/rust-lang/rust-clippy/issues/2774 diff --git a/tests/run-pass/ice-2865.rs b/tests/run-pass/ice-2865.rs index 970ac5bd3a8..64092afd53d 100644 --- a/tests/run-pass/ice-2865.rs +++ b/tests/run-pass/ice-2865.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(dead_code)] struct Ice { size: String, diff --git a/tests/run-pass/ice-3151.rs b/tests/run-pass/ice-3151.rs index 7a26f4c3925..a03dd05e7d3 100644 --- a/tests/run-pass/ice-3151.rs +++ b/tests/run-pass/ice-3151.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[derive(Clone)] pub struct HashMap { hash_builder: S, diff --git a/tests/run-pass/ice-3462.rs b/tests/run-pass/ice-3462.rs index 8aea905cd80..d4f6f355c85 100644 --- a/tests/run-pass/ice-3462.rs +++ b/tests/run-pass/ice-3462.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2019 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(clippy::blacklisted_name)] #![allow(unused)] diff --git a/tests/run-pass/ice-700.rs b/tests/run-pass/ice-700.rs index b839ac2a214..10546850611 100644 --- a/tests/run-pass/ice-700.rs +++ b/tests/run-pass/ice-700.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::all)] fn core() {} diff --git a/tests/run-pass/ice_exacte_size.rs b/tests/run-pass/ice_exacte_size.rs index b2b331bd342..ac643fafabc 100644 --- a/tests/run-pass/ice_exacte_size.rs +++ b/tests/run-pass/ice_exacte_size.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::all)] #[allow(dead_code)] diff --git a/tests/run-pass/if_same_then_else.rs b/tests/run-pass/if_same_then_else.rs index 0241d2adcf7..e6ab7cc9d8c 100644 --- a/tests/run-pass/if_same_then_else.rs +++ b/tests/run-pass/if_same_then_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::if_same_then_else)] fn main() {} diff --git a/tests/run-pass/issue-2862.rs b/tests/run-pass/issue-2862.rs index a5342492045..b35df667f27 100644 --- a/tests/run-pass/issue-2862.rs +++ b/tests/run-pass/issue-2862.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - pub trait FooMap { fn map B>(&self, f: F) -> B; } diff --git a/tests/run-pass/issue-825.rs b/tests/run-pass/issue-825.rs index 9f1195a4ac0..b1339212e6e 100644 --- a/tests/run-pass/issue-825.rs +++ b/tests/run-pass/issue-825.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(warnings)] // this should compile in a reasonable amount of time diff --git a/tests/run-pass/issues_loop_mut_cond.rs b/tests/run-pass/issues_loop_mut_cond.rs index a81f8f55dc8..bb238c81ebc 100644 --- a/tests/run-pass/issues_loop_mut_cond.rs +++ b/tests/run-pass/issues_loop_mut_cond.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] /// Issue: https://github.com/rust-lang/rust-clippy/issues/2596 diff --git a/tests/run-pass/match_same_arms_const.rs b/tests/run-pass/match_same_arms_const.rs index 661f2ac1dc7..50732475562 100644 --- a/tests/run-pass/match_same_arms_const.rs +++ b/tests/run-pass/match_same_arms_const.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::match_same_arms)] const PRICE_OF_SWEETS: u32 = 5; diff --git a/tests/run-pass/mut_mut_macro.rs b/tests/run-pass/mut_mut_macro.rs index f1a2cad3ae7..af11c29d9b0 100644 --- a/tests/run-pass/mut_mut_macro.rs +++ b/tests/run-pass/mut_mut_macro.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)] #![allow(dead_code)] diff --git a/tests/run-pass/needless_borrow_fp.rs b/tests/run-pass/needless_borrow_fp.rs index 81b77855711..4f61c76828d 100644 --- a/tests/run-pass/needless_borrow_fp.rs +++ b/tests/run-pass/needless_borrow_fp.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[deny(clippy::all)] #[derive(Debug)] pub enum Error { diff --git a/tests/run-pass/needless_lifetimes_impl_trait.rs b/tests/run-pass/needless_lifetimes_impl_trait.rs index 9648f530c2a..676564b2445 100644 --- a/tests/run-pass/needless_lifetimes_impl_trait.rs +++ b/tests/run-pass/needless_lifetimes_impl_trait.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::needless_lifetimes)] #![allow(dead_code)] diff --git a/tests/run-pass/procedural_macro.rs b/tests/run-pass/procedural_macro.rs index 9ac47599ea0..c7468493380 100644 --- a/tests/run-pass/procedural_macro.rs +++ b/tests/run-pass/procedural_macro.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[macro_use] extern crate clippy_mini_macro_test; diff --git a/tests/run-pass/regressions.rs b/tests/run-pass/regressions.rs index b109eecf624..84470addd4a 100644 --- a/tests/run-pass/regressions.rs +++ b/tests/run-pass/regressions.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::blacklisted_name)] pub fn foo(bar: *const u8) { diff --git a/tests/run-pass/returns.rs b/tests/run-pass/returns.rs index 045cf001eb2..d6b2a4ef170 100644 --- a/tests/run-pass/returns.rs +++ b/tests/run-pass/returns.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[deny(warnings)] fn cfg_return() -> i32 { #[cfg(unix)] diff --git a/tests/run-pass/single-match-else.rs b/tests/run-pass/single-match-else.rs index 80fc88f30df..efcc6363eb0 100644 --- a/tests/run-pass/single-match-else.rs +++ b/tests/run-pass/single-match-else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::single_match_else)] fn main() { diff --git a/tests/run-pass/used_underscore_binding_macro.rs b/tests/run-pass/used_underscore_binding_macro.rs index 8b6c6557b49..3030786aea6 100644 --- a/tests/run-pass/used_underscore_binding_macro.rs +++ b/tests/run-pass/used_underscore_binding_macro.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::useless_attribute)] //issue #2910 #[macro_use] diff --git a/tests/run-pass/whitelist/conf_whitelisted.rs b/tests/run-pass/whitelist/conf_whitelisted.rs index e7f5ddb561f..f328e4d9d04 100644 --- a/tests/run-pass/whitelist/conf_whitelisted.rs +++ b/tests/run-pass/whitelist/conf_whitelisted.rs @@ -1,10 +1 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() {} diff --git a/tests/ui-toml/bad_toml/conf_bad_toml.rs b/tests/ui-toml/bad_toml/conf_bad_toml.rs index 31781277ae8..3b9458fc284 100644 --- a/tests/ui-toml/bad_toml/conf_bad_toml.rs +++ b/tests/ui-toml/bad_toml/conf_bad_toml.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern: error reading Clippy's configuration file fn main() {} diff --git a/tests/ui-toml/bad_toml_type/conf_bad_type.rs b/tests/ui-toml/bad_toml_type/conf_bad_type.rs index 2307bfff21c..8a0062423ad 100644 --- a/tests/ui-toml/bad_toml_type/conf_bad_type.rs +++ b/tests/ui-toml/bad_toml_type/conf_bad_type.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a // `Vec < String >` but is a `integer` diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs index b00a21b3f2f..cb35d0e8589 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] #![allow(clippy::single_match)] #![allow(unused_variables)] diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr index 9f35b1751ac..84ba77851f7 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr @@ -1,5 +1,5 @@ error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:15:9 + --> $DIR/conf_french_blacklisted_name.rs:6:9 | LL | fn test(toto: ()) {} | ^^^^ @@ -7,37 +7,37 @@ LL | fn test(toto: ()) {} = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:18:9 + --> $DIR/conf_french_blacklisted_name.rs:9:9 | LL | let toto = 42; | ^^^^ error: use of a blacklisted/placeholder name `tata` - --> $DIR/conf_french_blacklisted_name.rs:19:9 + --> $DIR/conf_french_blacklisted_name.rs:10:9 | LL | let tata = 42; | ^^^^ error: use of a blacklisted/placeholder name `titi` - --> $DIR/conf_french_blacklisted_name.rs:20:9 + --> $DIR/conf_french_blacklisted_name.rs:11:9 | LL | let titi = 42; | ^^^^ error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:26:10 + --> $DIR/conf_french_blacklisted_name.rs:17:10 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `tata` - --> $DIR/conf_french_blacklisted_name.rs:26:21 + --> $DIR/conf_french_blacklisted_name.rs:17:21 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `titi` - --> $DIR/conf_french_blacklisted_name.rs:26:28 + --> $DIR/conf_french_blacklisted_name.rs:17:28 | LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ diff --git a/tests/ui-toml/toml_trivially_copy/test.rs b/tests/ui-toml/toml_trivially_copy/test.rs index 39de0de0dc7..f24fe51d30f 100644 --- a/tests/ui-toml/toml_trivially_copy/test.rs +++ b/tests/ui-toml/toml_trivially_copy/test.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::many_single_char_names)] #[derive(Copy, Clone)] diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index 49cbc0691bc..746b9ffa4af 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,5 +1,5 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:20:11 + --> $DIR/test.rs:11:11 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `u16` @@ -7,7 +7,7 @@ LL | fn bad(x: &u16, y: &Foo) {} = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:20:20 + --> $DIR/test.rs:11:20 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs b/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs index c8e6268e95d..a47569f62a3 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // error-pattern: error reading Clippy's configuration file: unknown key `foobar` fn main() {} diff --git a/tests/ui-toml/update-all-references.sh b/tests/ui-toml/update-all-references.sh index acc38f15fbd..71404b68c45 100755 --- a/tests/ui-toml/update-all-references.sh +++ b/tests/ui-toml/update-all-references.sh @@ -1,15 +1,5 @@ #!/bin/bash # -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - # A script to update the references for all tests. The idea is that # you do a run, which will generate files in the build directory # containing the (normalized) actual output of the compiler. You then diff --git a/tests/ui-toml/update-references.sh b/tests/ui-toml/update-references.sh index aa99d35f7aa..2c4fef43d96 100755 --- a/tests/ui-toml/update-references.sh +++ b/tests/ui-toml/update-references.sh @@ -1,14 +1,4 @@ #!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. # A script to update the references for particular tests. The idea is # that you do a run, which will generate files in the build directory diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index 666c4325706..ae0727fe2ba 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::absurd_extreme_comparisons)] #![allow( unused, diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 5c8d537b21c..b18a943c557 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,5 +1,5 @@ error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:23:5 + --> $DIR/absurd-extreme-comparisons.rs:14:5 | LL | u <= 0; | ^^^^^^ @@ -8,7 +8,7 @@ LL | u <= 0; = help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:24:5 + --> $DIR/absurd-extreme-comparisons.rs:15:5 | LL | u <= Z; | ^^^^^^ @@ -16,7 +16,7 @@ LL | u <= Z; = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:25:5 + --> $DIR/absurd-extreme-comparisons.rs:16:5 | LL | u < Z; | ^^^^^ @@ -24,7 +24,7 @@ LL | u < Z; = help: because Z is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:26:5 + --> $DIR/absurd-extreme-comparisons.rs:17:5 | LL | Z >= u; | ^^^^^^ @@ -32,7 +32,7 @@ LL | Z >= u; = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:27:5 + --> $DIR/absurd-extreme-comparisons.rs:18:5 | LL | Z > u; | ^^^^^ @@ -40,7 +40,7 @@ LL | Z > u; = help: because Z is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:28:5 + --> $DIR/absurd-extreme-comparisons.rs:19:5 | LL | u > std::u32::MAX; | ^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | u > std::u32::MAX; = help: because std::u32::MAX is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:29:5 + --> $DIR/absurd-extreme-comparisons.rs:20:5 | LL | u >= std::u32::MAX; | ^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | u >= std::u32::MAX; = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:30:5 + --> $DIR/absurd-extreme-comparisons.rs:21:5 | LL | std::u32::MAX < u; | ^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | std::u32::MAX < u; = help: because std::u32::MAX is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:31:5 + --> $DIR/absurd-extreme-comparisons.rs:22:5 | LL | std::u32::MAX <= u; | ^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | std::u32::MAX <= u; = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:32:5 + --> $DIR/absurd-extreme-comparisons.rs:23:5 | LL | 1-1 > u; | ^^^^^^^ @@ -80,7 +80,7 @@ LL | 1-1 > u; = help: because 1-1 is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:33:5 + --> $DIR/absurd-extreme-comparisons.rs:24:5 | LL | u >= !0; | ^^^^^^^ @@ -88,7 +88,7 @@ LL | u >= !0; = help: because !0 is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == !0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:34:5 + --> $DIR/absurd-extreme-comparisons.rs:25:5 | LL | u <= 12 - 2*6; | ^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL | u <= 12 - 2*6; = help: because 12 - 2*6 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 12 - 2*6 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:36:5 + --> $DIR/absurd-extreme-comparisons.rs:27:5 | LL | i < -127 - 1; | ^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | i < -127 - 1; = help: because -127 - 1 is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:37:5 + --> $DIR/absurd-extreme-comparisons.rs:28:5 | LL | std::i8::MAX >= i; | ^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | std::i8::MAX >= i; = help: because std::i8::MAX is the maximum value for this type, this comparison is always true error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:38:5 + --> $DIR/absurd-extreme-comparisons.rs:29:5 | LL | 3-7 < std::i32::MIN; | ^^^^^^^^^^^^^^^^^^^ @@ -120,7 +120,7 @@ LL | 3-7 < std::i32::MIN; = help: because std::i32::MIN is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:40:5 + --> $DIR/absurd-extreme-comparisons.rs:31:5 | LL | b >= true; | ^^^^^^^^^ @@ -128,7 +128,7 @@ LL | b >= true; = help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:41:5 + --> $DIR/absurd-extreme-comparisons.rs:32:5 | LL | false > b; | ^^^^^^^^^ @@ -136,7 +136,7 @@ LL | false > b; = help: because false is the minimum value for this type, this comparison is always false error: <-comparison of unit values detected. This will always be false - --> $DIR/absurd-extreme-comparisons.rs:44:5 + --> $DIR/absurd-extreme-comparisons.rs:35:5 | LL | () < {}; | ^^^^^^^ diff --git a/tests/ui/approx_const.rs b/tests/ui/approx_const.rs index 8eefb6af01d..8c295d1438a 100644 --- a/tests/ui/approx_const.rs +++ b/tests/ui/approx_const.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::approx_constant)] #[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)] fn main() { diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index c29ea3d467a..71c1c360e74 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly - --> $DIR/approx_const.rs:13:16 + --> $DIR/approx_const.rs:4:16 | LL | let my_e = 2.7182; | ^^^^^^ @@ -7,109 +7,109 @@ LL | let my_e = 2.7182; = note: `-D clippy::approx-constant` implied by `-D warnings` error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly - --> $DIR/approx_const.rs:14:20 + --> $DIR/approx_const.rs:5:20 | LL | let almost_e = 2.718; | ^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found. Consider using it directly - --> $DIR/approx_const.rs:17:24 + --> $DIR/approx_const.rs:8:24 | LL | let my_1_frac_pi = 0.3183; | ^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:20:28 + --> $DIR/approx_const.rs:11:28 | LL | let my_frac_1_sqrt_2 = 0.70710678; | ^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:21:32 + --> $DIR/approx_const.rs:12:32 | LL | let almost_frac_1_sqrt_2 = 0.70711; | ^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found. Consider using it directly - --> $DIR/approx_const.rs:24:24 + --> $DIR/approx_const.rs:15:24 | LL | let my_frac_2_pi = 0.63661977; | ^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found. Consider using it directly - --> $DIR/approx_const.rs:27:27 + --> $DIR/approx_const.rs:18:27 | LL | let my_frac_2_sq_pi = 1.128379; | ^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found. Consider using it directly - --> $DIR/approx_const.rs:30:24 + --> $DIR/approx_const.rs:21:24 | LL | let my_frac_pi_2 = 1.57079632679; | ^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found. Consider using it directly - --> $DIR/approx_const.rs:33:24 + --> $DIR/approx_const.rs:24:24 | LL | let my_frac_pi_3 = 1.04719755119; | ^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found. Consider using it directly - --> $DIR/approx_const.rs:36:24 + --> $DIR/approx_const.rs:27:24 | LL | let my_frac_pi_4 = 0.785398163397; | ^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found. Consider using it directly - --> $DIR/approx_const.rs:39:24 + --> $DIR/approx_const.rs:30:24 | LL | let my_frac_pi_6 = 0.523598775598; | ^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found. Consider using it directly - --> $DIR/approx_const.rs:42:24 + --> $DIR/approx_const.rs:33:24 | LL | let my_frac_pi_8 = 0.3926990816987; | ^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LN_10` found. Consider using it directly - --> $DIR/approx_const.rs:45:20 + --> $DIR/approx_const.rs:36:20 | LL | let my_ln_10 = 2.302585092994046; | ^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LN_2` found. Consider using it directly - --> $DIR/approx_const.rs:48:19 + --> $DIR/approx_const.rs:39:19 | LL | let my_ln_2 = 0.6931471805599453; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG10_E` found. Consider using it directly - --> $DIR/approx_const.rs:51:22 + --> $DIR/approx_const.rs:42:22 | LL | let my_log10_e = 0.4342944819032518; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly - --> $DIR/approx_const.rs:54:21 + --> $DIR/approx_const.rs:45:21 | LL | let my_log2_e = 1.4426950408889634; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly - --> $DIR/approx_const.rs:57:17 + --> $DIR/approx_const.rs:48:17 | LL | let my_pi = 3.1415; | ^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly - --> $DIR/approx_const.rs:58:21 + --> $DIR/approx_const.rs:49:21 | LL | let almost_pi = 3.14; | ^^^^ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:61:18 + --> $DIR/approx_const.rs:52:18 | LL | let my_sq2 = 1.4142; | ^^^^^^ diff --git a/tests/ui/arithmetic.rs b/tests/ui/arithmetic.rs index 00de38039a7..c3cea997606 100644 --- a/tests/ui/arithmetic.rs +++ b/tests/ui/arithmetic.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] #![allow( unused, @@ -26,6 +17,10 @@ fn main() { i - 2 + 2 - i; -i; + // no error, overflows are checked by `overflowing_literals` + -1; + -(-1); + i & 1; // no wrapping i | 1; i ^ 1; diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index cea9676c2b8..b21efaa849f 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -1,5 +1,5 @@ error: integer arithmetic detected - --> $DIR/arithmetic.rs:22:5 + --> $DIR/arithmetic.rs:13:5 | LL | 1 + i; | ^^^^^ @@ -7,32 +7,32 @@ LL | 1 + i; = note: `-D clippy::integer-arithmetic` implied by `-D warnings` error: integer arithmetic detected - --> $DIR/arithmetic.rs:23:5 + --> $DIR/arithmetic.rs:14:5 | LL | i * 2; | ^^^^^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:24:5 + --> $DIR/arithmetic.rs:15:5 | LL | / 1 % LL | | i / 2; // no error, this is part of the expression in the preceding line | |_________^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:26:5 + --> $DIR/arithmetic.rs:17:5 | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:27:5 + --> $DIR/arithmetic.rs:18:5 | LL | -i; | ^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:37:5 + --> $DIR/arithmetic.rs:32:5 | LL | f * 2.0; | ^^^^^^^ @@ -40,31 +40,31 @@ LL | f * 2.0; = note: `-D clippy::float-arithmetic` implied by `-D warnings` error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:39:5 + --> $DIR/arithmetic.rs:34:5 | LL | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:40:5 + --> $DIR/arithmetic.rs:35:5 | LL | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:41:5 + --> $DIR/arithmetic.rs:36:5 | LL | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:42:5 + --> $DIR/arithmetic.rs:37:5 | LL | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:43:5 + --> $DIR/arithmetic.rs:38:5 | LL | -f; | ^^ diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index 75cd7543823..c7b4865f5c2 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(dead_code, unused_assignments)] #[warn(clippy::assign_op_pattern)] fn main() { diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 194033981e1..646f9970122 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,5 +1,5 @@ error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:14:5 + --> $DIR/assign_ops.rs:5:5 | LL | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` @@ -7,49 +7,49 @@ LL | a = a + 1; = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:15:5 + --> $DIR/assign_ops.rs:6:5 | LL | a = 1 + a; | ^^^^^^^^^ help: replace it with: `a += 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:16:5 + --> $DIR/assign_ops.rs:7:5 | LL | a = a - 1; | ^^^^^^^^^ help: replace it with: `a -= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:17:5 + --> $DIR/assign_ops.rs:8:5 | LL | a = a * 99; | ^^^^^^^^^^ help: replace it with: `a *= 99` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:18:5 + --> $DIR/assign_ops.rs:9:5 | LL | a = 42 * a; | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:19:5 + --> $DIR/assign_ops.rs:10:5 | LL | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:20:5 + --> $DIR/assign_ops.rs:11:5 | LL | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:21:5 + --> $DIR/assign_ops.rs:12:5 | LL | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:27:5 + --> $DIR/assign_ops.rs:18:5 | LL | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index 24d0d77a20d..4703a8c7777 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(unused_assignments)] #[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)] fn main() { diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 99983c0d054..872d6e0d734 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,5 +1,5 @@ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:14:5 + --> $DIR/assign_ops2.rs:5:5 | LL | a += a + 1; | ^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | a = a + a + 1; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:15:5 + --> $DIR/assign_ops2.rs:6:5 | LL | a += 1 + a; | ^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | a = a + 1 + a; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:16:5 + --> $DIR/assign_ops2.rs:7:5 | LL | a -= a - 1; | ^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | a = a - (a - 1); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:17:5 + --> $DIR/assign_ops2.rs:8:5 | LL | a *= a * 99; | ^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | a = a * a * 99; | ^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:18:5 + --> $DIR/assign_ops2.rs:9:5 | LL | a *= 42 * a; | ^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | a = a * 42 * a; | ^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:19:5 + --> $DIR/assign_ops2.rs:10:5 | LL | a /= a / 2; | ^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | a = a / (a / 2); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:20:5 + --> $DIR/assign_ops2.rs:11:5 | LL | a %= a % 5; | ^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | a = a % (a % 5); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:21:5 + --> $DIR/assign_ops2.rs:12:5 | LL | a &= a & 1; | ^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | a = a & a & 1; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:22:5 + --> $DIR/assign_ops2.rs:13:5 | LL | a *= a * a; | ^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | a = a * a * a; | ^^^^^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/assign_ops2.rs:59:5 + --> $DIR/assign_ops2.rs:50:5 | LL | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index 2c7f67d4505..df7eafc6551 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::inline_always, clippy::deprecated_semver)] #![allow(clippy::assertions_on_constants::assertions_on_constants)] #[inline(always)] diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index bc40cb8c86d..39ddf6f226d 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,5 +1,5 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea - --> $DIR/attrs.rs:12:1 + --> $DIR/attrs.rs:3:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[inline(always)] = note: `-D clippy::inline-always` implied by `-D warnings` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:32:14 + --> $DIR/attrs.rs:23:14 | LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[deprecated(since = "forever")] = note: `-D clippy::deprecated-semver` implied by `-D warnings` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:35:14 + --> $DIR/attrs.rs:26:14 | LL | #[deprecated(since = "1")] | ^^^^^^^^^^^ diff --git a/tests/ui/author.rs b/tests/ui/author.rs index 4b7729e23b1..0a1be356896 100644 --- a/tests/ui/author.rs +++ b/tests/ui/author.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() { #[clippy::author] let x: char = 0x45 as char; diff --git a/tests/ui/author.stdout b/tests/ui/author.stdout index b06fb1d21e3..87593fafb46 100644 --- a/tests/ui/author.stdout +++ b/tests/ui/author.stdout @@ -1,6 +1,5 @@ if_chain! { - if let StmtKind::Decl(ref decl, _) = stmt.node - if let DeclKind::Local(ref local) = decl.node; + if let StmtKind::Local(ref local) = stmt.node; if let Some(ref init) = local.init if let ExprKind::Cast(ref expr, ref cast_ty) = init.node; if let TyKind::Path(ref qp) = cast_ty.node; diff --git a/tests/ui/author/call.rs b/tests/ui/author/call.rs index 40cc0d7a919..e99c3c41dc4 100644 --- a/tests/ui/author/call.rs +++ b/tests/ui/author/call.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() { #[clippy::author] let _ = ::std::cmp::min(3, 4); diff --git a/tests/ui/author/call.stdout b/tests/ui/author/call.stdout index 1c25708fb48..d9322d618bf 100644 --- a/tests/ui/author/call.stdout +++ b/tests/ui/author/call.stdout @@ -1,6 +1,5 @@ if_chain! { - if let StmtKind::Decl(ref decl, _) = stmt.node - if let DeclKind::Local(ref local) = decl.node; + if let StmtKind::Local(ref local) = stmt.node; if let Some(ref init) = local.init if let ExprKind::Call(ref func, ref args) = init.node; if let ExprKind::Path(ref path) = func.node; diff --git a/tests/ui/author/for_loop.rs b/tests/ui/author/for_loop.rs index 4acd0b452bb..b3dec876535 100644 --- a/tests/ui/author/for_loop.rs +++ b/tests/ui/author/for_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(stmt_expr_attributes)] fn main() { diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout index b99e8e0ade5..1611f419e5d 100644 --- a/tests/ui/author/for_loop.stdout +++ b/tests/ui/author/for_loop.stdout @@ -1,7 +1,6 @@ if_chain! { if let ExprKind::Block(ref block) = expr.node; - if let StmtKind::Decl(ref decl, _) = block.node - if let DeclKind::Local(ref local) = decl.node; + if let StmtKind::Local(ref local) = block.node; if let Some(ref init) = local.init if let ExprKind::Match(ref expr, ref arms, MatchSource::ForLoopDesugar) = init.node; if let ExprKind::Call(ref func, ref args) = expr.node; @@ -14,8 +13,7 @@ if_chain! { // unimplemented: field checks if arms.len() == 1; if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.node; - if let StmtKind::Decl(ref decl1, _) = body.node - if let DeclKind::Local(ref local1) = decl1.node; + if let StmtKind::Local(ref local1) = body.node; if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local1.pat.node; if name.node.as_str() == "__next"; if let StmtKind::Expr(ref e, _) = local1.pat.node @@ -42,8 +40,7 @@ if_chain! { if arms1[1].pats.len() == 1; if let PatKind::Path(ref path7) = arms1[1].pats[0].node; if match_qpath(path7, &["{{root}}", "std", "option", "Option", "None"]); - if let StmtKind::Decl(ref decl2, _) = path7.node - if let DeclKind::Local(ref local2) = decl2.node; + if let StmtKind::Local(ref local2) = path7.node; if let Some(ref init1) = local2.init if let ExprKind::Path(ref path8) = init1.node; if match_qpath(path8, &["__next"]); @@ -51,8 +48,7 @@ if_chain! { if name1.node.as_str() == "y"; if let StmtKind::Expr(ref e1, _) = local2.pat.node if let ExprKind::Block(ref block1) = e1.node; - if let StmtKind::Decl(ref decl3, _) = block1.node - if let DeclKind::Local(ref local3) = decl3.node; + if let StmtKind::Local(ref local3) = block1.node; if let Some(ref init2) = local3.init if let ExprKind::Path(ref path9) = init2.node; if match_qpath(path9, &["y"]); diff --git a/tests/ui/author/matches.rs b/tests/ui/author/matches.rs index 4c220dded8a..e6bf229103f 100644 --- a/tests/ui/author/matches.rs +++ b/tests/ui/author/matches.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(tool_attributes)] fn main() { diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr index 5fb2a01f1b2..fa7e5cce43c 100644 --- a/tests/ui/author/matches.stderr +++ b/tests/ui/author/matches.stderr @@ -1,12 +1,12 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/matches.rs:18:13 + --> $DIR/matches.rs:9:13 | LL | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned - --> $DIR/matches.rs:17:21 + --> $DIR/matches.rs:8:21 | LL | let x = 3; | ^ diff --git a/tests/ui/bit_masks.rs b/tests/ui/bit_masks.rs index bda952db723..cfb493fb52a 100644 --- a/tests/ui/bit_masks.rs +++ b/tests/ui/bit_masks.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - const THREE_BITS: i64 = 7; const EVEN_MORE_REDIRECTION: i64 = THREE_BITS; diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index da883dcbfc4..159db0374d2 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,5 +1,5 @@ error: &-masking with zero - --> $DIR/bit_masks.rs:23:5 + --> $DIR/bit_masks.rs:14:5 | LL | x & 0 == 0; | ^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | x & 0 == 0; = note: `-D clippy::bad-bit-mask` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:23:5 + --> $DIR/bit_masks.rs:14:5 | LL | x & 0 == 0; | ^^^^^ @@ -15,73 +15,73 @@ LL | x & 0 == 0; = note: #[deny(clippy::erasing_op)] on by default error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:26:5 + --> $DIR/bit_masks.rs:17:5 | LL | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:30:5 + --> $DIR/bit_masks.rs:21:5 | LL | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` - --> $DIR/bit_masks.rs:32:5 + --> $DIR/bit_masks.rs:23:5 | LL | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:36:5 + --> $DIR/bit_masks.rs:27:5 | LL | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` - --> $DIR/bit_masks.rs:43:5 + --> $DIR/bit_masks.rs:34:5 | LL | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` - --> $DIR/bit_masks.rs:44:5 + --> $DIR/bit_masks.rs:35:5 | LL | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero - --> $DIR/bit_masks.rs:46:5 + --> $DIR/bit_masks.rs:37:5 | LL | 0 & x == 0; | ^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:46:5 + --> $DIR/bit_masks.rs:37:5 | LL | 0 & x == 0; | ^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:50:5 + --> $DIR/bit_masks.rs:41:5 | LL | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:51:5 + --> $DIR/bit_masks.rs:42:5 | LL | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:52:5 + --> $DIR/bit_masks.rs:43:5 | LL | 1 == x & 2; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:63:5 + --> $DIR/bit_masks.rs:54:5 | LL | x | 1 > 3; | ^^^^^^^^^ @@ -89,19 +89,19 @@ LL | x | 1 > 3; = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly - --> $DIR/bit_masks.rs:64:5 + --> $DIR/bit_masks.rs:55:5 | LL | x | 1 < 4; | ^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:65:5 + --> $DIR/bit_masks.rs:56:5 | LL | x | 1 <= 3; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly - --> $DIR/bit_masks.rs:66:5 + --> $DIR/bit_masks.rs:57:5 | LL | x | 1 >= 8; | ^^^^^^^^^^ diff --git a/tests/ui/blacklisted_name.rs b/tests/ui/blacklisted_name.rs index fef73e9d84f..ca9d8d16b78 100644 --- a/tests/ui/blacklisted_name.rs +++ b/tests/ui/blacklisted_name.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( dead_code, clippy::similar_names, diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 5b65d4ed13f..44123829fb0 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -1,5 +1,5 @@ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:20:9 + --> $DIR/blacklisted_name.rs:11:9 | LL | fn test(foo: ()) {} | ^^^ @@ -7,79 +7,79 @@ LL | fn test(foo: ()) {} = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:23:9 + --> $DIR/blacklisted_name.rs:14:9 | LL | let foo = 42; | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:24:9 + --> $DIR/blacklisted_name.rs:15:9 | LL | let bar = 42; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:25:9 + --> $DIR/blacklisted_name.rs:16:9 | LL | let baz = 42; | ^^^ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:31:10 + --> $DIR/blacklisted_name.rs:22:10 | LL | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:31:20 + --> $DIR/blacklisted_name.rs:22:20 | LL | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:31:26 + --> $DIR/blacklisted_name.rs:22:26 | LL | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:36:19 + --> $DIR/blacklisted_name.rs:27:19 | LL | fn issue_1647(mut foo: u8) { | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:37:13 + --> $DIR/blacklisted_name.rs:28:13 | LL | let mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:38:21 + --> $DIR/blacklisted_name.rs:29:21 | LL | if let Some(mut baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:42:13 + --> $DIR/blacklisted_name.rs:33:13 | LL | let ref bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:43:21 + --> $DIR/blacklisted_name.rs:34:21 | LL | if let Some(ref baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:47:17 + --> $DIR/blacklisted_name.rs:38:17 | LL | let ref mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:48:25 + --> $DIR/blacklisted_name.rs:39:25 | LL | if let Some(ref mut baz) = Some(42) {} | ^^^ diff --git a/tests/ui/block_in_if_condition.rs b/tests/ui/block_in_if_condition.rs index eaaf5e050bf..17ee1cd6873 100644 --- a/tests/ui/block_in_if_condition.rs +++ b/tests/ui/block_in_if_condition.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::block_in_if_condition_expr)] #![warn(clippy::block_in_if_condition_stmt)] #![allow(unused, clippy::let_and_return)] diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index 522c7dc779e..34c0454b782 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -1,5 +1,5 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:35:8 + --> $DIR/block_in_if_condition.rs:26:8 | LL | if { | ________^ @@ -19,7 +19,7 @@ LL | | } { } ... error: omit braces around single expression condition - --> $DIR/block_in_if_condition.rs:46:8 + --> $DIR/block_in_if_condition.rs:37:8 | LL | if { true } { | ^^^^^^^^ @@ -31,7 +31,7 @@ LL | if { true } { } ... error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:66:17 + --> $DIR/block_in_if_condition.rs:57:17 | LL | |x| { | _________________^ @@ -41,7 +41,7 @@ LL | | }, | |_____________^ error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:75:13 + --> $DIR/block_in_if_condition.rs:66:13 | LL | |x| { | _____________^ @@ -51,7 +51,7 @@ LL | | }, | |_________^ error: this boolean expression can be simplified - --> $DIR/block_in_if_condition.rs:85:8 + --> $DIR/block_in_if_condition.rs:76:8 | LL | if true && x == 3 { | ^^^^^^^^^^^^^^ help: try: `x == 3` diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index 2a28d0af1b2..48c5e9d6d0c 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::bool_comparison)] fn main() { let x = true; diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 7bd48f2e3dc..2d473d91d66 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -1,5 +1,5 @@ error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:13:8 + --> $DIR/bool_comparison.rs:4:8 | LL | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -7,79 +7,79 @@ LL | if x == true { = note: `-D clippy::bool-comparison` implied by `-D warnings` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:18:8 + --> $DIR/bool_comparison.rs:9:8 | LL | if x == false { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:23:8 + --> $DIR/bool_comparison.rs:14:8 | LL | if true == x { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:28:8 + --> $DIR/bool_comparison.rs:19:8 | LL | if false == x { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:33:8 + --> $DIR/bool_comparison.rs:24:8 | LL | if x != true { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:38:8 + --> $DIR/bool_comparison.rs:29:8 | LL | if x != false { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:43:8 + --> $DIR/bool_comparison.rs:34:8 | LL | if true != x { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:48:8 + --> $DIR/bool_comparison.rs:39:8 | LL | if false != x { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: less than comparison against true can be replaced by a negation - --> $DIR/bool_comparison.rs:53:8 + --> $DIR/bool_comparison.rs:44:8 | LL | if x < true { | ^^^^^^^^ help: try simplifying it as shown: `!x` error: greater than checks against false are unnecessary - --> $DIR/bool_comparison.rs:58:8 + --> $DIR/bool_comparison.rs:49:8 | LL | if false < x { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: greater than checks against false are unnecessary - --> $DIR/bool_comparison.rs:63:8 + --> $DIR/bool_comparison.rs:54:8 | LL | if x > false { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: less than comparison against true can be replaced by a negation - --> $DIR/bool_comparison.rs:68:8 + --> $DIR/bool_comparison.rs:59:8 | LL | if true > x { | ^^^^^^^^ help: try simplifying it as shown: `!x` error: order comparisons between booleans can be simplified - --> $DIR/bool_comparison.rs:74:8 + --> $DIR/bool_comparison.rs:65:8 | LL | if x < y { | ^^^^^ help: try simplifying it as shown: `!x & y` error: order comparisons between booleans can be simplified - --> $DIR/bool_comparison.rs:79:8 + --> $DIR/bool_comparison.rs:70:8 | LL | if x > y { | ^^^^^ help: try simplifying it as shown: `x & !y` diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index 8eb1b52577c..c8e01d4b258 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::nonminimal_bool, clippy::logic_bug)] #[allow(unused, clippy::many_single_char_names)] diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index c9446f5e4bc..eebab8c3e25 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -1,18 +1,18 @@ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:19:13 + --> $DIR/booleans.rs:10:13 | LL | let _ = a && b || a; | ^^^^^^^^^^^ help: it would look like the following: `a` | = note: `-D clippy::logic-bug` implied by `-D warnings` help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:19:18 + --> $DIR/booleans.rs:10:18 | LL | let _ = a && b || a; | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:21:13 + --> $DIR/booleans.rs:12:13 | LL | let _ = !true; | ^^^^^ help: try: `false` @@ -20,55 +20,55 @@ LL | let _ = !true; = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: this boolean expression can be simplified - --> $DIR/booleans.rs:22:13 + --> $DIR/booleans.rs:13:13 | LL | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/booleans.rs:23:13 + --> $DIR/booleans.rs:14:13 | LL | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:24:13 + --> $DIR/booleans.rs:15:13 | LL | let _ = false && a; | ^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:24:22 + --> $DIR/booleans.rs:15:22 | LL | let _ = false && a; | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:25:13 + --> $DIR/booleans.rs:16:13 | LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/booleans.rs:30:13 + --> $DIR/booleans.rs:21:13 | LL | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `!b || a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:40:13 + --> $DIR/booleans.rs:31:13 | LL | let _ = a == b && a != b; | ^^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:40:13 + --> $DIR/booleans.rs:31:13 | LL | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:41:13 + --> $DIR/booleans.rs:32:13 | LL | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | let _ = !(c != 5 || a != b); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:42:13 + --> $DIR/booleans.rs:33:13 | LL | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,31 +92,31 @@ LL | let _ = !(c != 5 || a != b); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:43:13 + --> $DIR/booleans.rs:34:13 | LL | let _ = a < b && a >= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:43:13 + --> $DIR/booleans.rs:34:13 | LL | let _ = a < b && a >= b; | ^^^^^ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:44:13 + --> $DIR/booleans.rs:35:13 | LL | let _ = a > b && a <= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:44:13 + --> $DIR/booleans.rs:35:13 | LL | let _ = a > b && a <= b; | ^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:46:13 + --> $DIR/booleans.rs:37:13 | LL | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -128,73 +128,73 @@ LL | let _ = !(a == b && c == d); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:54:13 + --> $DIR/booleans.rs:45:13 | LL | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:56:13 + --> $DIR/booleans.rs:47:13 | LL | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:58:13 + --> $DIR/booleans.rs:49:13 | LL | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:60:13 + --> $DIR/booleans.rs:51:13 | LL | let _ = !b.is_ok(); | ^^^^^^^^^^ help: try: `b.is_err()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:62:13 + --> $DIR/booleans.rs:53:13 | LL | let _ = !(a.is_some() && !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:63:13 + --> $DIR/booleans.rs:54:13 | LL | let _ = !(!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:64:13 + --> $DIR/booleans.rs:55:13 | LL | let _ = (!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!c ^ c) || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:65:13 + --> $DIR/booleans.rs:56:13 | LL | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `!c ^ c || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:137:8 + --> $DIR/booleans.rs:128:8 | LL | if !res.is_ok() {} | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:138:8 + --> $DIR/booleans.rs:129:8 | LL | if !res.is_err() {} | ^^^^^^^^^^^^^ help: try: `res.is_ok()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:141:8 + --> $DIR/booleans.rs:132:8 | LL | if !res.is_some() {} | ^^^^^^^^^^^^^^ help: try: `res.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:142:8 + --> $DIR/booleans.rs:133:8 | LL | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` diff --git a/tests/ui/borrow_box.rs b/tests/ui/borrow_box.rs index cf204150f8b..3b53aab7e23 100644 --- a/tests/ui/borrow_box.rs +++ b/tests/ui/borrow_box.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::borrowed_box)] #![allow(clippy::blacklisted_name)] #![allow(unused_variables)] diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 33bd50286a5..0cb455433c4 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -1,29 +1,29 @@ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:15:19 + --> $DIR/borrow_box.rs:6:19 | LL | pub fn test1(foo: &mut Box) { | ^^^^^^^^^^^^^^ help: try: `&mut bool` | note: lint level defined here - --> $DIR/borrow_box.rs:10:9 + --> $DIR/borrow_box.rs:1:9 | LL | #![deny(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:20:14 + --> $DIR/borrow_box.rs:11:14 | LL | let foo: &Box; | ^^^^^^^^^^ help: try: `&bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:24:10 + --> $DIR/borrow_box.rs:15:10 | LL | foo: &'a Box, | ^^^^^^^^^^^^^ help: try: `&'a bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:28:17 + --> $DIR/borrow_box.rs:19:17 | LL | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` diff --git a/tests/ui/box_vec.rs b/tests/ui/box_vec.rs index 48523054097..af3ba5b4d35 100644 --- a/tests/ui/box_vec.rs +++ b/tests/ui/box_vec.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::blacklisted_name)] diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index 8b5fc24a371..fca12eddd57 100644 --- a/tests/ui/box_vec.stderr +++ b/tests/ui/box_vec.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `Box>`. Consider using just `Vec` - --> $DIR/box_vec.rs:23:18 + --> $DIR/box_vec.rs:14:18 | LL | pub fn test(foo: Box>) { | ^^^^^^^^^^^^^^ diff --git a/tests/ui/builtin-type-shadow.rs b/tests/ui/builtin-type-shadow.rs index e9df0992c5e..69b8b6a0e68 100644 --- a/tests/ui/builtin-type-shadow.rs +++ b/tests/ui/builtin-type-shadow.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::builtin_type_shadow)] #![allow(non_camel_case_types)] diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 940a6dc2bcc..5714f2094da 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -1,5 +1,5 @@ error: This generic shadows the built-in type `u32` - --> $DIR/builtin-type-shadow.rs:13:8 + --> $DIR/builtin-type-shadow.rs:4:8 | LL | fn foo(a: u32) -> u32 { | ^^^ @@ -7,7 +7,7 @@ LL | fn foo(a: u32) -> u32 { = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` error[E0308]: mismatched types - --> $DIR/builtin-type-shadow.rs:14:5 + --> $DIR/builtin-type-shadow.rs:5:5 | LL | fn foo(a: u32) -> u32 { | --- expected `u32` because of return type diff --git a/tests/ui/bytecount.rs b/tests/ui/bytecount.rs index 6bc9b5ddecd..c724ee21be3 100644 --- a/tests/ui/bytecount.rs +++ b/tests/ui/bytecount.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[deny(clippy::naive_bytecount)] fn main() { let x = vec![0_u8; 16]; diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index a2890fe5a6d..43bc4b3c61e 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -1,23 +1,23 @@ error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:14:13 + --> $DIR/bytecount.rs:5:13 | LL | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, 0)` | note: lint level defined here - --> $DIR/bytecount.rs:10:8 + --> $DIR/bytecount.rs:1:8 | LL | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:16:13 + --> $DIR/bytecount.rs:7:13 | LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count((&x[..]), 0)` error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:28:13 + --> $DIR/bytecount.rs:19:13 | LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)` diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 51e41b70172..5f4de9894c7 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 78631ffa8c8..92587312a53 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,5 +1,5 @@ error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:20:5 + --> $DIR/cast.rs:11:5 | LL | 1i32 as f32; | ^^^^^^^^^^^ @@ -7,37 +7,37 @@ LL | 1i32 as f32; = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:21:5 + --> $DIR/cast.rs:12:5 | LL | 1i64 as f32; | ^^^^^^^^^^^ error: casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast.rs:22:5 + --> $DIR/cast.rs:13:5 | LL | 1i64 as f64; | ^^^^^^^^^^^ error: casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:23:5 + --> $DIR/cast.rs:14:5 | LL | 1u32 as f32; | ^^^^^^^^^^^ error: casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:24:5 + --> $DIR/cast.rs:15:5 | LL | 1u64 as f32; | ^^^^^^^^^^^ error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast.rs:25:5 + --> $DIR/cast.rs:16:5 | LL | 1u64 as f64; | ^^^^^^^^^^^ error: casting f32 to i32 may truncate the value - --> $DIR/cast.rs:27:5 + --> $DIR/cast.rs:18:5 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -45,13 +45,13 @@ LL | 1f32 as i32; = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting f32 to u32 may truncate the value - --> $DIR/cast.rs:28:5 + --> $DIR/cast.rs:19:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ error: casting f32 to u32 may lose the sign of the value - --> $DIR/cast.rs:28:5 + --> $DIR/cast.rs:19:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -59,49 +59,49 @@ LL | 1f32 as u32; = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting f64 to f32 may truncate the value - --> $DIR/cast.rs:29:5 + --> $DIR/cast.rs:20:5 | LL | 1f64 as f32; | ^^^^^^^^^^^ error: casting i32 to i8 may truncate the value - --> $DIR/cast.rs:30:5 + --> $DIR/cast.rs:21:5 | LL | 1i32 as i8; | ^^^^^^^^^^ error: casting i32 to u8 may lose the sign of the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:22:5 | LL | 1i32 as u8; | ^^^^^^^^^^ error: casting i32 to u8 may truncate the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:22:5 | LL | 1i32 as u8; | ^^^^^^^^^^ error: casting f64 to isize may truncate the value - --> $DIR/cast.rs:32:5 + --> $DIR/cast.rs:23:5 | LL | 1f64 as isize; | ^^^^^^^^^^^^^ error: casting f64 to usize may truncate the value - --> $DIR/cast.rs:33:5 + --> $DIR/cast.rs:24:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting f64 to usize may lose the sign of the value - --> $DIR/cast.rs:33:5 + --> $DIR/cast.rs:24:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting u8 to i8 may wrap around the value - --> $DIR/cast.rs:35:5 + --> $DIR/cast.rs:26:5 | LL | 1u8 as i8; | ^^^^^^^^^ @@ -109,31 +109,31 @@ LL | 1u8 as i8; = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting u16 to i16 may wrap around the value - --> $DIR/cast.rs:36:5 + --> $DIR/cast.rs:27:5 | LL | 1u16 as i16; | ^^^^^^^^^^^ error: casting u32 to i32 may wrap around the value - --> $DIR/cast.rs:37:5 + --> $DIR/cast.rs:28:5 | LL | 1u32 as i32; | ^^^^^^^^^^^ error: casting u64 to i64 may wrap around the value - --> $DIR/cast.rs:38:5 + --> $DIR/cast.rs:29:5 | LL | 1u64 as i64; | ^^^^^^^^^^^ error: casting usize to isize may wrap around the value - --> $DIR/cast.rs:39:5 + --> $DIR/cast.rs:30:5 | LL | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting f32 to f64 may become silently lossy if types change - --> $DIR/cast.rs:41:5 + --> $DIR/cast.rs:32:5 | LL | 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` @@ -141,25 +141,25 @@ LL | 1.0f32 as f64; = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast.rs:43:5 + --> $DIR/cast.rs:34:5 | LL | (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: casting i32 to u32 may lose the sign of the value - --> $DIR/cast.rs:45:5 + --> $DIR/cast.rs:36:5 | LL | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value - --> $DIR/cast.rs:46:5 + --> $DIR/cast.rs:37:5 | LL | 1isize as usize; | ^^^^^^^^^^^^^^^ error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/cast.rs:49:5 + --> $DIR/cast.rs:40:5 | LL | 1i32 as i32; | ^^^^^^^^^^^ @@ -167,13 +167,13 @@ LL | 1i32 as i32; = note: `-D clippy::unnecessary-cast` implied by `-D warnings` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/cast.rs:50:5 + --> $DIR/cast.rs:41:5 | LL | 1f32 as f32; | ^^^^^^^^^^^ error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/cast.rs:51:5 + --> $DIR/cast.rs:42:5 | LL | false as bool; | ^^^^^^^^^^^^^ diff --git a/tests/ui/cast_alignment.rs b/tests/ui/cast_alignment.rs index dba19dfd023..2814fe6c03d 100644 --- a/tests/ui/cast_alignment.rs +++ b/tests/ui/cast_alignment.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! Test casts for alignment issues #![feature(rustc_private)] diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index 261bce613bf..0077be1b570 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,5 +1,5 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) - --> $DIR/cast_alignment.rs:21:5 + --> $DIR/cast_alignment.rs:12:5 | LL | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | (&1u8 as *const u8) as *const u16; = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) - --> $DIR/cast_alignment.rs:22:5 + --> $DIR/cast_alignment.rs:13:5 | LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_lossless_float.fixed b/tests/ui/cast_lossless_float.fixed index 5f4e54eb565..22df1137922 100644 --- a/tests/ui/cast_lossless_float.fixed +++ b/tests/ui/cast_lossless_float.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs index b818010feb2..c86b4d05f28 100644 --- a/tests/ui/cast_lossless_float.rs +++ b/tests/ui/cast_lossless_float.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index aa48bd4d1c7..c2b01e83bbe 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,5 +1,5 @@ error: casting i8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:16:5 + --> $DIR/cast_lossless_float.rs:7:5 | LL | 1i8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1i8)` @@ -7,55 +7,55 @@ LL | 1i8 as f32; = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:17:5 + --> $DIR/cast_lossless_float.rs:8:5 | LL | 1i8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1i8)` error: casting u8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:18:5 + --> $DIR/cast_lossless_float.rs:9:5 | LL | 1u8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1u8)` error: casting u8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:19:5 + --> $DIR/cast_lossless_float.rs:10:5 | LL | 1u8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1u8)` error: casting i16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:20:5 + --> $DIR/cast_lossless_float.rs:11:5 | LL | 1i16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1i16)` error: casting i16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:21:5 + --> $DIR/cast_lossless_float.rs:12:5 | LL | 1i16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i16)` error: casting u16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:22:5 + --> $DIR/cast_lossless_float.rs:13:5 | LL | 1u16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1u16)` error: casting u16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:23:5 + --> $DIR/cast_lossless_float.rs:14:5 | LL | 1u16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u16)` error: casting i32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:24:5 + --> $DIR/cast_lossless_float.rs:15:5 | LL | 1i32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i32)` error: casting u32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:25:5 + --> $DIR/cast_lossless_float.rs:16:5 | LL | 1u32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u32)` diff --git a/tests/ui/cast_lossless_integer.fixed b/tests/ui/cast_lossless_integer.fixed index 83f3e024209..e5b33d5e1b0 100644 --- a/tests/ui/cast_lossless_integer.fixed +++ b/tests/ui/cast_lossless_integer.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs index 75c63957001..61170625c8a 100644 --- a/tests/ui/cast_lossless_integer.rs +++ b/tests/ui/cast_lossless_integer.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index f49dc0d9eff..ac385298ecb 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,5 +1,5 @@ error: casting i8 to i16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:16:5 + --> $DIR/cast_lossless_integer.rs:7:5 | LL | 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` @@ -7,103 +7,103 @@ LL | 1i8 as i16; = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:17:5 + --> $DIR/cast_lossless_integer.rs:8:5 | LL | 1i8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1i8)` error: casting i8 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:18:5 + --> $DIR/cast_lossless_integer.rs:9:5 | LL | 1i8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1i8)` error: casting u8 to i16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:19:5 + --> $DIR/cast_lossless_integer.rs:10:5 | LL | 1u8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1u8)` error: casting u8 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:20:5 + --> $DIR/cast_lossless_integer.rs:11:5 | LL | 1u8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1u8)` error: casting u8 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:21:5 + --> $DIR/cast_lossless_integer.rs:12:5 | LL | 1u8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1u8)` error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:22:5 + --> $DIR/cast_lossless_integer.rs:13:5 | LL | 1u8 as u16; | ^^^^^^^^^^ help: try: `u16::from(1u8)` error: casting u8 to u32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:23:5 + --> $DIR/cast_lossless_integer.rs:14:5 | LL | 1u8 as u32; | ^^^^^^^^^^ help: try: `u32::from(1u8)` error: casting u8 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:24:5 + --> $DIR/cast_lossless_integer.rs:15:5 | LL | 1u8 as u64; | ^^^^^^^^^^ help: try: `u64::from(1u8)` error: casting i16 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:25:5 + --> $DIR/cast_lossless_integer.rs:16:5 | LL | 1i16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1i16)` error: casting i16 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:26:5 + --> $DIR/cast_lossless_integer.rs:17:5 | LL | 1i16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i16)` error: casting u16 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:27:5 + --> $DIR/cast_lossless_integer.rs:18:5 | LL | 1u16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1u16)` error: casting u16 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:28:5 + --> $DIR/cast_lossless_integer.rs:19:5 | LL | 1u16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u16)` error: casting u16 to u32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:29:5 + --> $DIR/cast_lossless_integer.rs:20:5 | LL | 1u16 as u32; | ^^^^^^^^^^^ help: try: `u32::from(1u16)` error: casting u16 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:30:5 + --> $DIR/cast_lossless_integer.rs:21:5 | LL | 1u16 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u16)` error: casting i32 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:31:5 + --> $DIR/cast_lossless_integer.rs:22:5 | LL | 1i32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i32)` error: casting u32 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:32:5 + --> $DIR/cast_lossless_integer.rs:23:5 | LL | 1u32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u32)` error: casting u32 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:33:5 + --> $DIR/cast_lossless_integer.rs:24:5 | LL | 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` diff --git a/tests/ui/cast_size.rs b/tests/ui/cast_size.rs index 8f691104c51..fde178b1874 100644 --- a/tests/ui/cast_size.rs +++ b/tests/ui/cast_size.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index eab1014128a..9346deb19ec 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -1,5 +1,5 @@ error: casting isize to i8 may truncate the value - --> $DIR/cast_size.rs:20:5 + --> $DIR/cast_size.rs:11:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | 1isize as i8; = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:21:5 + --> $DIR/cast_size.rs:12:5 | LL | 1isize as f64; | ^^^^^^^^^^^^^ @@ -15,31 +15,31 @@ LL | 1isize as f64; = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:22:5 + --> $DIR/cast_size.rs:13:5 | LL | 1usize as f64; | ^^^^^^^^^^^^^ error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:23:5 + --> $DIR/cast_size.rs:14:5 | LL | 1isize as f32; | ^^^^^^^^^^^^^ error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:24:5 + --> $DIR/cast_size.rs:15:5 | LL | 1usize as f32; | ^^^^^^^^^^^^^ error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> $DIR/cast_size.rs:16:5 | LL | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value - --> $DIR/cast_size.rs:26:5 + --> $DIR/cast_size.rs:17:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ @@ -47,25 +47,25 @@ LL | 1isize as u32; = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:26:5 + --> $DIR/cast_size.rs:17:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> $DIR/cast_size.rs:18:5 | LL | 1usize as u32; | ^^^^^^^^^^^^^ error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> $DIR/cast_size.rs:19:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> $DIR/cast_size.rs:19:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -73,49 +73,49 @@ LL | 1usize as i32; = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> $DIR/cast_size.rs:21:5 | LL | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value - --> $DIR/cast_size.rs:31:5 + --> $DIR/cast_size.rs:22:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:31:5 + --> $DIR/cast_size.rs:22:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:32:5 + --> $DIR/cast_size.rs:23:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:32:5 + --> $DIR/cast_size.rs:23:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:33:5 + --> $DIR/cast_size.rs:24:5 | LL | 1u64 as usize; | ^^^^^^^^^^^^^ error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:34:5 + --> $DIR/cast_size.rs:25:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value - --> $DIR/cast_size.rs:37:5 + --> $DIR/cast_size.rs:28:5 | LL | 1i32 as usize; | ^^^^^^^^^^^^^ diff --git a/tests/ui/cfg_attr_rustfmt.fixed b/tests/ui/cfg_attr_rustfmt.fixed new file mode 100644 index 00000000000..4e583a25b94 --- /dev/null +++ b/tests/ui/cfg_attr_rustfmt.fixed @@ -0,0 +1,31 @@ +// run-rustfix +#![feature(stmt_expr_attributes)] + +#![allow(unused, clippy::no_effect)] +#![warn(clippy::deprecated_cfg_attr)] + +// This doesn't get linted, see known problems +#![cfg_attr(rustfmt, rustfmt_skip)] + +#[rustfmt::skip] +trait Foo +{ +fn foo( +); +} + +fn skip_on_statements() { + #[rustfmt::skip] + 5+3; +} + +#[rustfmt::skip] +fn main() { + foo::f(); +} + +mod foo { + #![cfg_attr(rustfmt, rustfmt_skip)] + + pub fn f() {} +} diff --git a/tests/ui/cfg_attr_rustfmt.rs b/tests/ui/cfg_attr_rustfmt.rs index 614cd3e30ec..9c0fcf6fb45 100644 --- a/tests/ui/cfg_attr_rustfmt.rs +++ b/tests/ui/cfg_attr_rustfmt.rs @@ -1,14 +1,7 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![feature(stmt_expr_attributes)] +#![allow(unused, clippy::no_effect)] #![warn(clippy::deprecated_cfg_attr)] // This doesn't get linted, see known problems diff --git a/tests/ui/cfg_attr_rustfmt.stderr b/tests/ui/cfg_attr_rustfmt.stderr index 233aafc3c79..09971caceea 100644 --- a/tests/ui/cfg_attr_rustfmt.stderr +++ b/tests/ui/cfg_attr_rustfmt.stderr @@ -1,5 +1,5 @@ error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes - --> $DIR/cfg_attr_rustfmt.rs:25:5 + --> $DIR/cfg_attr_rustfmt.rs:18:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` @@ -7,16 +7,10 @@ LL | #[cfg_attr(rustfmt, rustfmt::skip)] = note: `-D clippy::deprecated-cfg-attr` implied by `-D warnings` error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes - --> $DIR/cfg_attr_rustfmt.rs:29:1 + --> $DIR/cfg_attr_rustfmt.rs:22:1 | LL | #[cfg_attr(rustfmt, rustfmt_skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` -error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes - --> $DIR/cfg_attr_rustfmt.rs:35:5 - | -LL | #![cfg_attr(rustfmt, rustfmt_skip)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#![rustfmt::skip]` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/char_lit_as_u8.rs b/tests/ui/char_lit_as_u8.rs index 663962afeae..211cbfe98f3 100644 --- a/tests/ui/char_lit_as_u8.rs +++ b/tests/ui/char_lit_as_u8.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::char_lit_as_u8)] #![allow(unused_variables)] fn main() { diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index a577c55d261..52f29a3f553 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -1,5 +1,5 @@ error: casting character literal to u8. `char`s are 4 bytes wide in rust, so casting to u8 truncates them - --> $DIR/char_lit_as_u8.rs:13:13 + --> $DIR/char_lit_as_u8.rs:4:13 | LL | let c = 'a' as u8; | ^^^^^^^^^ diff --git a/tests/ui/checked_unwrap.rs b/tests/ui/checked_unwrap.rs index 4d250a80e90..21f9e33201f 100644 --- a/tests/ui/checked_unwrap.rs +++ b/tests/ui/checked_unwrap.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] #![allow(clippy::if_same_then_else)] diff --git a/tests/ui/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index 7e6a487ad1e..514814b0ee0 100644 --- a/tests/ui/checked_unwrap.stderr +++ b/tests/ui/checked_unwrap.stderr @@ -1,5 +1,5 @@ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:16:9 + --> $DIR/checked_unwrap.rs:7:9 | LL | if x.is_some() { | ----------- the check is happening here @@ -7,13 +7,13 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:10:35 + --> $DIR/checked_unwrap.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:18:9 + --> $DIR/checked_unwrap.rs:9:9 | LL | if x.is_some() { | ----------- because of this check @@ -22,13 +22,13 @@ LL | x.unwrap(); // will panic | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:10:9 + --> $DIR/checked_unwrap.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:21:9 + --> $DIR/checked_unwrap.rs:12:9 | LL | if x.is_none() { | ----------- because of this check @@ -36,7 +36,7 @@ LL | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:23:9 + --> $DIR/checked_unwrap.rs:14:9 | LL | if x.is_none() { | ----------- the check is happening here @@ -45,7 +45,7 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:27:9 + --> $DIR/checked_unwrap.rs:18:9 | LL | if x.is_ok() { | --------- the check is happening here @@ -53,52 +53,52 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. + --> $DIR/checked_unwrap.rs:19:9 + | +LL | if x.is_ok() { + | --------- because of this check +LL | x.unwrap(); // unnecessary +LL | x.unwrap_err(); // will panic + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:21:9 + | +LL | if x.is_ok() { + | --------- because of this check +... +LL | x.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:22:9 + | +LL | if x.is_ok() { + | --------- the check is happening here +... +LL | x.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:25:9 + | +LL | if x.is_err() { + | ---------- because of this check +LL | x.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:26:9 + | +LL | if x.is_err() { + | ---------- the check is happening here +LL | x.unwrap(); // will panic +LL | x.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ + +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:28:9 | -LL | if x.is_ok() { - | --------- because of this check -LL | x.unwrap(); // unnecessary -LL | x.unwrap_err(); // will panic - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:30:9 - | -LL | if x.is_ok() { - | --------- because of this check -... -LL | x.unwrap(); // will panic - | ^^^^^^^^^^ - -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:31:9 - | -LL | if x.is_ok() { - | --------- the check is happening here -... -LL | x.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:34:9 - | -LL | if x.is_err() { - | ---------- because of this check -LL | x.unwrap(); // will panic - | ^^^^^^^^^^ - -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:35:9 - | -LL | if x.is_err() { - | ---------- the check is happening here -LL | x.unwrap(); // will panic -LL | x.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ - -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:37:9 - | LL | if x.is_err() { | ---------- the check is happening here ... @@ -106,7 +106,7 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:38:9 + --> $DIR/checked_unwrap.rs:29:9 | LL | if x.is_err() { | ---------- because of this check @@ -115,7 +115,7 @@ LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:55:9 + --> $DIR/checked_unwrap.rs:46:9 | LL | if x.is_ok() && y.is_err() { | --------- the check is happening here @@ -123,7 +123,7 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:56:9 + --> $DIR/checked_unwrap.rs:47:9 | LL | if x.is_ok() && y.is_err() { | --------- because of this check @@ -132,7 +132,7 @@ LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:57:9 + --> $DIR/checked_unwrap.rs:48:9 | LL | if x.is_ok() && y.is_err() { | ---------- because of this check @@ -141,7 +141,7 @@ LL | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:58:9 + --> $DIR/checked_unwrap.rs:49:9 | LL | if x.is_ok() && y.is_err() { | ---------- the check is happening here @@ -150,7 +150,7 @@ LL | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:72:9 + --> $DIR/checked_unwrap.rs:63:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -159,7 +159,7 @@ LL | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:73:9 + --> $DIR/checked_unwrap.rs:64:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -168,7 +168,7 @@ LL | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:74:9 + --> $DIR/checked_unwrap.rs:65:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -177,7 +177,7 @@ LL | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:75:9 + --> $DIR/checked_unwrap.rs:66:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -186,7 +186,7 @@ LL | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:79:9 + --> $DIR/checked_unwrap.rs:70:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -194,7 +194,7 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:80:9 + --> $DIR/checked_unwrap.rs:71:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -203,7 +203,7 @@ LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:81:9 + --> $DIR/checked_unwrap.rs:72:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -212,7 +212,7 @@ LL | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:82:9 + --> $DIR/checked_unwrap.rs:73:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -221,7 +221,7 @@ LL | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:83:9 + --> $DIR/checked_unwrap.rs:74:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here @@ -230,7 +230,7 @@ LL | z.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:84:9 + --> $DIR/checked_unwrap.rs:75:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check @@ -239,7 +239,7 @@ LL | z.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:92:9 + --> $DIR/checked_unwrap.rs:83:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -248,7 +248,7 @@ LL | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:93:9 + --> $DIR/checked_unwrap.rs:84:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -257,7 +257,7 @@ LL | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:94:9 + --> $DIR/checked_unwrap.rs:85:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -266,7 +266,7 @@ LL | y.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:95:9 + --> $DIR/checked_unwrap.rs:86:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -275,7 +275,7 @@ LL | y.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:96:9 + --> $DIR/checked_unwrap.rs:87:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check @@ -284,7 +284,7 @@ LL | z.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:97:9 + --> $DIR/checked_unwrap.rs:88:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- the check is happening here @@ -293,7 +293,7 @@ LL | z.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:105:13 + --> $DIR/checked_unwrap.rs:96:13 | LL | if x.is_some() { | ----------- the check is happening here @@ -301,7 +301,7 @@ LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:107:13 + --> $DIR/checked_unwrap.rs:98:13 | LL | if x.is_some() { | ----------- because of this check diff --git a/tests/ui/clone_on_copy_impl.rs b/tests/ui/clone_on_copy_impl.rs index 058cbf7a16c..8f9f2a0db8c 100644 --- a/tests/ui/clone_on_copy_impl.rs +++ b/tests/ui/clone_on_copy_impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::fmt; use std::marker::PhantomData; diff --git a/tests/ui/clone_on_copy_mut.rs b/tests/ui/clone_on_copy_mut.rs index 82f411d5c9d..3cbbcb7c083 100644 --- a/tests/ui/clone_on_copy_mut.rs +++ b/tests/ui/clone_on_copy_mut.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - pub fn dec_read_dec(i: &mut i32) -> i32 { *i -= 1; let ret = *i; diff --git a/tests/ui/cmp_nan.rs b/tests/ui/cmp_nan.rs index d6bdb5894d5..33e039308ec 100644 --- a/tests/ui/cmp_nan.rs +++ b/tests/ui/cmp_nan.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::cmp_nan)] #[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)] fn main() { diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index 2a7772308b8..421f3451823 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -1,5 +1,5 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:14:5 + --> $DIR/cmp_nan.rs:5:5 | LL | x == std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ @@ -7,67 +7,67 @@ LL | x == std::f32::NAN; = note: `-D clippy::cmp-nan` implied by `-D warnings` error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:15:5 + --> $DIR/cmp_nan.rs:6:5 | LL | x != std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:16:5 + --> $DIR/cmp_nan.rs:7:5 | LL | x < std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:17:5 + --> $DIR/cmp_nan.rs:8:5 | LL | x > std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:18:5 + --> $DIR/cmp_nan.rs:9:5 | LL | x <= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:19:5 + --> $DIR/cmp_nan.rs:10:5 | LL | x >= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:22:5 + --> $DIR/cmp_nan.rs:13:5 | LL | y == std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:23:5 + --> $DIR/cmp_nan.rs:14:5 | LL | y != std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:24:5 + --> $DIR/cmp_nan.rs:15:5 | LL | y < std::f64::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:25:5 + --> $DIR/cmp_nan.rs:16:5 | LL | y > std::f64::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:26:5 + --> $DIR/cmp_nan.rs:17:5 | LL | y <= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:27:5 + --> $DIR/cmp_nan.rs:18:5 | LL | y >= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmp_null.rs b/tests/ui/cmp_null.rs index 37615c9e113..2d2d04178c3 100644 --- a/tests/ui/cmp_null.rs +++ b/tests/ui/cmp_null.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::cmp_null)] #![allow(unused_mut)] diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 68789b5b635..063e716676c 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,5 +1,5 @@ error: Comparing with null is better expressed by the .is_null() method - --> $DIR/cmp_null.rs:18:8 + --> $DIR/cmp_null.rs:9:8 | LL | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | if p == ptr::null() { = note: `-D clippy::cmp-null` implied by `-D warnings` error: Comparing with null is better expressed by the .is_null() method - --> $DIR/cmp_null.rs:23:8 + --> $DIR/cmp_null.rs:14:8 | LL | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmp_owned.rs b/tests/ui/cmp_owned.rs index 53de5136105..a5f92b30bc2 100644 --- a/tests/ui/cmp_owned.rs +++ b/tests/ui/cmp_owned.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::cmp_owned)] #[allow(clippy::unnecessary_operation)] fn main() { diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index 9177c6bd73e..9be749f8d04 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:14:14 + --> $DIR/cmp_owned.rs:5:14 | LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` @@ -7,49 +7,49 @@ LL | x != "foo".to_string(); = note: `-D clippy::cmp-owned` implied by `-D warnings` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:16:9 + --> $DIR/cmp_owned.rs:7:9 | LL | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:23:10 + --> $DIR/cmp_owned.rs:14:10 | LL | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:25:10 + --> $DIR/cmp_owned.rs:16:10 | LL | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:29:5 + --> $DIR/cmp_owned.rs:20:5 | LL | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:31:30 + --> $DIR/cmp_owned.rs:22:30 | LL | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:38:5 + --> $DIR/cmp_owned.rs:29:5 | LL | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:43:5 + --> $DIR/cmp_owned.rs:34:5 | LL | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:50:9 + --> $DIR/cmp_owned.rs:41:9 | LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating diff --git a/tests/ui/collapsible_if.fixed b/tests/ui/collapsible_if.fixed new file mode 100644 index 00000000000..2c6dd95a637 --- /dev/null +++ b/tests/ui/collapsible_if.fixed @@ -0,0 +1,175 @@ +// run-rustfix +#![allow(clippy::cyclomatic_complexity)] + +#[rustfmt::skip] +#[warn(clippy::collapsible_if)] +fn main() { + let x = "hello"; + let y = "world"; + if x == "hello" && y == "world" { + println!("Hello world!"); +} + + if (x == "hello" || x == "world") && (y == "world" || y == "hello") { + println!("Hello world!"); +} + + if x == "hello" && x == "world" && (y == "world" || y == "hello") { + println!("Hello world!"); +} + + if (x == "hello" || x == "world") && y == "world" && y == "hello" { + println!("Hello world!"); +} + + if x == "hello" && x == "world" && y == "world" && y == "hello" { + println!("Hello world!"); +} + + if 42 == 1337 && 'a' != 'A' { + println!("world!") +} + + // Collapse `else { if .. }` to `else if ..` + if x == "hello" { + print!("Hello "); + } else if y == "world" { + println!("world!") +} + + if x == "hello" { + print!("Hello "); + } else if let Some(42) = Some(42) { + println!("world!") +} + + if x == "hello" { + print!("Hello "); + } else if y == "world" { + println!("world") +} +else { + println!("!") +} + + if x == "hello" { + print!("Hello "); + } else if let Some(42) = Some(42) { + println!("world") +} +else { + println!("!") +} + + if let Some(42) = Some(42) { + print!("Hello "); + } else if let Some(42) = Some(42) { + println!("world") +} +else { + println!("!") +} + + if let Some(42) = Some(42) { + print!("Hello "); + } else if x == "hello" { + println!("world") +} +else { + println!("!") +} + + if let Some(42) = Some(42) { + print!("Hello "); + } else if let Some(42) = Some(42) { + println!("world") +} +else { + println!("!") +} + + // Works because any if with an else statement cannot be collapsed. + if x == "hello" { + if y == "world" { + println!("Hello world!"); + } + } else { + println!("Not Hello world"); + } + + if x == "hello" { + if y == "world" { + println!("Hello world!"); + } else { + println!("Hello something else"); + } + } + + if x == "hello" { + print!("Hello "); + if y == "world" { + println!("world!") + } + } + + if true { + } else { + assert!(true); // assert! is just an `if` + } + + + // The following tests check for the fix of https://github.com/rust-lang/rust-clippy/issues/798 + if x == "hello" {// Not collapsible + if y == "world" { + println!("Hello world!"); + } + } + + if x == "hello" { // Not collapsible + if y == "world" { + println!("Hello world!"); + } + } + + if x == "hello" { + // Not collapsible + if y == "world" { + println!("Hello world!"); + } + } + + if x == "hello" && y == "world" { // Collapsible + println!("Hello world!"); +} + + if x == "hello" { + print!("Hello "); + } else { + // Not collapsible + if y == "world" { + println!("world!") + } + } + + if x == "hello" { + print!("Hello "); + } else { + // Not collapsible + if let Some(42) = Some(42) { + println!("world!") + } + } + + if x == "hello" { + /* Not collapsible */ + if y == "world" { + println!("Hello world!"); + } + } + + if x == "hello" { /* Not collapsible */ + if y == "world" { + println!("Hello world!"); + } + } +} diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index 6828743abf3..f482d7704de 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -1,11 +1,5 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// run-rustfix +#![allow(clippy::cyclomatic_complexity)] #[rustfmt::skip] #[warn(clippy::collapsible_if)] diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 2c60234eb5d..d6d0b9d5d4e 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,5 +1,5 @@ error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:15:5 + --> $DIR/collapsible_if.rs:9:5 | LL | / if x == "hello" { LL | | if y == "world" { @@ -17,7 +17,7 @@ LL | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:21:5 + --> $DIR/collapsible_if.rs:15:5 | LL | / if x == "hello" || x == "world" { LL | | if y == "world" || y == "hello" { @@ -33,7 +33,7 @@ LL | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:27:5 + --> $DIR/collapsible_if.rs:21:5 | LL | / if x == "hello" && x == "world" { LL | | if y == "world" || y == "hello" { @@ -49,7 +49,7 @@ LL | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:33:5 + --> $DIR/collapsible_if.rs:27:5 | LL | / if x == "hello" || x == "world" { LL | | if y == "world" && y == "hello" { @@ -65,7 +65,7 @@ LL | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:39:5 + --> $DIR/collapsible_if.rs:33:5 | LL | / if x == "hello" && x == "world" { LL | | if y == "world" && y == "hello" { @@ -81,7 +81,7 @@ LL | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:45:5 + --> $DIR/collapsible_if.rs:39:5 | LL | / if 42 == 1337 { LL | | if 'a' != 'A' { @@ -97,7 +97,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:54:12 + --> $DIR/collapsible_if.rs:48:12 | LL | } else { | ____________^ @@ -114,7 +114,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:62:12 + --> $DIR/collapsible_if.rs:56:12 | LL | } else { | ____________^ @@ -131,7 +131,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:70:12 + --> $DIR/collapsible_if.rs:64:12 | LL | } else { | ____________^ @@ -153,7 +153,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:81:12 + --> $DIR/collapsible_if.rs:75:12 | LL | } else { | ____________^ @@ -175,7 +175,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:92:12 + --> $DIR/collapsible_if.rs:86:12 | LL | } else { | ____________^ @@ -197,7 +197,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:103:12 + --> $DIR/collapsible_if.rs:97:12 | LL | } else { | ____________^ @@ -219,7 +219,7 @@ LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:114:12 + --> $DIR/collapsible_if.rs:108:12 | LL | } else { | ____________^ @@ -241,7 +241,7 @@ LL | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:173:5 + --> $DIR/collapsible_if.rs:167:5 | LL | / if x == "hello" { LL | | if y == "world" { // Collapsible diff --git a/tests/ui/complex_types.rs b/tests/ui/complex_types.rs index 9d75de62d74..cfece3768ef 100644 --- a/tests/ui/complex_types.rs +++ b/tests/ui/complex_types.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(unused, clippy::needless_pass_by_value)] #![feature(associated_type_defaults)] diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index 8f46d38921d..8f5dbd27956 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -1,5 +1,5 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:16:12 + --> $DIR/complex_types.rs:7:12 | LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,85 +7,85 @@ LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); = note: `-D clippy::type-complexity` implied by `-D warnings` error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:17:12 + --> $DIR/complex_types.rs:8:12 | LL | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:20:8 + --> $DIR/complex_types.rs:11:8 | LL | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:23:11 + --> $DIR/complex_types.rs:14:11 | LL | struct TS(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:26:11 + --> $DIR/complex_types.rs:17:11 | LL | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:27:17 + --> $DIR/complex_types.rs:18:17 | LL | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:31:14 + --> $DIR/complex_types.rs:22:14 | LL | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:32:30 + --> $DIR/complex_types.rs:23:30 | LL | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:36:14 + --> $DIR/complex_types.rs:27:14 | LL | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:37:14 + --> $DIR/complex_types.rs:28:14 | LL | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:38:25 + --> $DIR/complex_types.rs:29:25 | LL | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:39:29 + --> $DIR/complex_types.rs:30:29 | LL | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:42:15 + --> $DIR/complex_types.rs:33:15 | LL | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:46:14 + --> $DIR/complex_types.rs:37:14 | LL | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:49:13 + --> $DIR/complex_types.rs:40:13 | LL | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const_static_lifetime.rs b/tests/ui/const_static_lifetime.rs index 3e1aa94f969..745821a1503 100644 --- a/tests/ui/const_static_lifetime.rs +++ b/tests/ui/const_static_lifetime.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[derive(Debug)] struct Foo {} diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index b3fabb3522f..c329e860558 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -1,5 +1,5 @@ error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:13:17 + --> $DIR/const_static_lifetime.rs:4:17 | LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` @@ -7,73 +7,73 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removin = note: `-D clippy::const-static-lifetime` implied by `-D warnings` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:17:21 + --> $DIR/const_static_lifetime.rs:8:21 | LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:19:32 + --> $DIR/const_static_lifetime.rs:10:32 | LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:19:47 + --> $DIR/const_static_lifetime.rs:10:47 | LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:21:18 + --> $DIR/const_static_lifetime.rs:12:18 | LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:21:30 + --> $DIR/const_static_lifetime.rs:12:30 | LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:23:17 + --> $DIR/const_static_lifetime.rs:14:17 | LL | const VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:25:29 + --> $DIR/const_static_lifetime.rs:16:29 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:25:39 + --> $DIR/const_static_lifetime.rs:16:39 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:27:20 + --> $DIR/const_static_lifetime.rs:18:20 | LL | const VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:29:19 + --> $DIR/const_static_lifetime.rs:20:19 | LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:31:19 + --> $DIR/const_static_lifetime.rs:22:19 | LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:33:19 + --> $DIR/const_static_lifetime.rs:24:19 | LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index 5db82006dea..a78209bcce8 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( clippy::blacklisted_name, clippy::collapsible_if, diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index 3fbc279b537..a0a5c3890ed 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/copies.rs:50:12 + --> $DIR/copies.rs:41:12 | LL | } else { | ____________^ @@ -13,7 +13,7 @@ LL | | } | = note: `-D clippy::if-same-then-else` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:42:13 + --> $DIR/copies.rs:33:13 | LL | if true { | _____________^ @@ -26,7 +26,7 @@ LL | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:96:14 + --> $DIR/copies.rs:87:14 | LL | _ => { | ______________^ @@ -40,7 +40,7 @@ LL | | }, | = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:87:15 + --> $DIR/copies.rs:78:15 | LL | 42 => { | _______________^ @@ -52,7 +52,7 @@ LL | | a LL | | }, | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:87:15 + --> $DIR/copies.rs:78:15 | LL | 42 => { | _______________^ @@ -65,24 +65,24 @@ LL | | }, | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:111:14 + --> $DIR/copies.rs:102:14 | LL | _ => 0, //~ ERROR match arms have same body | ^ | note: same as this - --> $DIR/copies.rs:109:19 + --> $DIR/copies.rs:100:19 | LL | Abc::A => 0, | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:109:19 + --> $DIR/copies.rs:100:19 | LL | Abc::A => 0, | ^ error: this `if` has identical blocks - --> $DIR/copies.rs:120:12 + --> $DIR/copies.rs:111:12 | LL | } else { | ____________^ @@ -92,7 +92,7 @@ LL | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:118:21 + --> $DIR/copies.rs:109:21 | LL | let _ = if true { | _____________________^ @@ -101,7 +101,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:134:12 + --> $DIR/copies.rs:125:12 | LL | } else { | ____________^ @@ -114,7 +114,7 @@ LL | | } | |_____^ | note: same as this - --> $DIR/copies.rs:125:13 + --> $DIR/copies.rs:116:13 | LL | if true { | _____________^ @@ -127,7 +127,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:153:12 + --> $DIR/copies.rs:144:12 | LL | } else { | ____________^ @@ -140,7 +140,7 @@ LL | | } | |_____^ | note: same as this - --> $DIR/copies.rs:146:13 + --> $DIR/copies.rs:137:13 | LL | if true { | _____________^ @@ -153,7 +153,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:183:12 + --> $DIR/copies.rs:174:12 | LL | } else { | ____________^ @@ -163,7 +163,7 @@ LL | | } | |_____^ | note: same as this - --> $DIR/copies.rs:181:13 + --> $DIR/copies.rs:172:13 | LL | if true { | _____________^ @@ -172,7 +172,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:190:12 + --> $DIR/copies.rs:181:12 | LL | } else { | ____________^ @@ -182,7 +182,7 @@ LL | | } | |_____^ | note: same as this - --> $DIR/copies.rs:188:13 + --> $DIR/copies.rs:179:13 | LL | if true { | _____________^ @@ -191,92 +191,92 @@ LL | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:239:15 + --> $DIR/copies.rs:230:15 | LL | 51 => foo(), //~ ERROR match arms have same body | ^^^^^ | note: same as this - --> $DIR/copies.rs:238:15 + --> $DIR/copies.rs:229:15 | LL | 42 => foo(), | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:238:15 + --> $DIR/copies.rs:229:15 | LL | 42 => foo(), | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:245:17 + --> $DIR/copies.rs:236:17 | LL | None => 24, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:244:20 + --> $DIR/copies.rs:235:20 | LL | Some(_) => 24, | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:244:20 + --> $DIR/copies.rs:235:20 | LL | Some(_) => 24, | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:267:28 + --> $DIR/copies.rs:258:28 | LL | (None, Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:266:28 + --> $DIR/copies.rs:257:28 | LL | (Some(a), None) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:266:28 + --> $DIR/copies.rs:257:28 | LL | (Some(a), None) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:273:26 + --> $DIR/copies.rs:264:26 | LL | (.., Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:272:26 + --> $DIR/copies.rs:263:26 | LL | (Some(a), ..) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:272:26 + --> $DIR/copies.rs:263:26 | LL | (Some(a), ..) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:279:20 + --> $DIR/copies.rs:270:20 | LL | (.., 3) => 42, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:278:23 + --> $DIR/copies.rs:269:23 | LL | (1, .., 3) => 42, | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:278:23 + --> $DIR/copies.rs:269:23 | LL | (1, .., 3) => 42, | ^^ error: this `if` has identical blocks - --> $DIR/copies.rs:285:12 + --> $DIR/copies.rs:276:12 | LL | } else { | ____________^ @@ -286,7 +286,7 @@ LL | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:283:21 + --> $DIR/copies.rs:274:21 | LL | let _ = if true { | _____________________^ @@ -295,7 +295,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:292:12 + --> $DIR/copies.rs:283:12 | LL | } else { | ____________^ @@ -305,7 +305,7 @@ LL | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:290:21 + --> $DIR/copies.rs:281:21 | LL | let _ = if true { | _____________________^ @@ -314,7 +314,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:305:12 + --> $DIR/copies.rs:296:12 | LL | } else { | ____________^ @@ -324,7 +324,7 @@ LL | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:303:21 + --> $DIR/copies.rs:294:21 | LL | let _ = if true { | _____________________^ @@ -333,7 +333,7 @@ LL | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:323:12 + --> $DIR/copies.rs:314:12 | LL | } else { | ____________^ @@ -343,7 +343,7 @@ LL | | } | |_____^ | note: same as this - --> $DIR/copies.rs:321:13 + --> $DIR/copies.rs:312:13 | LL | if true { | _____________^ diff --git a/tests/ui/copy_iterator.rs b/tests/ui/copy_iterator.rs index 22d3e138898..e3d5928be23 100644 --- a/tests/ui/copy_iterator.rs +++ b/tests/ui/copy_iterator.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::copy_iterator)] #[derive(Copy, Clone)] diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index 34606df8595..f8ce6af7961 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,5 +1,5 @@ error: you are implementing `Iterator` on a `Copy` type - --> $DIR/copy_iterator.rs:15:1 + --> $DIR/copy_iterator.rs:6:1 | LL | / impl Iterator for Countdown { LL | | type Item = u8; diff --git a/tests/ui/cstring.rs b/tests/ui/cstring.rs index 5fe915a8368..6cc36518e27 100644 --- a/tests/ui/cstring.rs +++ b/tests/ui/cstring.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() {} #[allow(clippy::result_unwrap_used)] diff --git a/tests/ui/cstring.stderr b/tests/ui/cstring.stderr index d2968eb9d18..a2fc07d4af0 100644 --- a/tests/ui/cstring.stderr +++ b/tests/ui/cstring.stderr @@ -1,5 +1,5 @@ error: you are getting the inner pointer of a temporary `CString` - --> $DIR/cstring.rs:16:5 + --> $DIR/cstring.rs:7:5 | LL | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | CString::new("foo").unwrap().as_ptr(); = note: #[deny(clippy::temporary_cstring_as_ptr)] on by default = note: that pointer will be invalid outside this expression help: assign the `CString` to a variable to extend its lifetime - --> $DIR/cstring.rs:16:5 + --> $DIR/cstring.rs:7:5 | LL | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cyclomatic_complexity.rs b/tests/ui/cyclomatic_complexity.rs index fff67762924..d552ef50ff0 100644 --- a/tests/ui/cyclomatic_complexity.rs +++ b/tests/ui/cyclomatic_complexity.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::all)] #![warn(clippy::cyclomatic_complexity)] #![allow(unused)] diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index f8e3a54debd..944bba6e488 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -1,5 +1,5 @@ error: the function has a cyclomatic complexity of 28 - --> $DIR/cyclomatic_complexity.rs:15:1 + --> $DIR/cyclomatic_complexity.rs:6:1 | LL | / fn main() { LL | | if true { @@ -14,7 +14,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 7 - --> $DIR/cyclomatic_complexity.rs:100:1 + --> $DIR/cyclomatic_complexity.rs:91:1 | LL | / fn kaboom() { LL | | let n = 0; @@ -28,7 +28,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:146:1 + --> $DIR/cyclomatic_complexity.rs:137:1 | LL | / fn lots_of_short_circuits() -> bool { LL | | true && false && true && false && true && false && true @@ -38,7 +38,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:151:1 + --> $DIR/cyclomatic_complexity.rs:142:1 | LL | / fn lots_of_short_circuits2() -> bool { LL | | true || false || true || false || true || false || true @@ -48,7 +48,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:156:1 + --> $DIR/cyclomatic_complexity.rs:147:1 | LL | / fn baa() { LL | | let x = || match 99 { @@ -62,7 +62,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:157:13 + --> $DIR/cyclomatic_complexity.rs:148:13 | LL | let x = || match 99 { | _____________^ @@ -77,7 +77,7 @@ LL | | }; = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:174:1 + --> $DIR/cyclomatic_complexity.rs:165:1 | LL | / fn bar() { LL | | match 99 { @@ -90,7 +90,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:193:1 + --> $DIR/cyclomatic_complexity.rs:184:1 | LL | / fn barr() { LL | | match 99 { @@ -104,7 +104,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:203:1 + --> $DIR/cyclomatic_complexity.rs:194:1 | LL | / fn barr2() { LL | | match 99 { @@ -118,7 +118,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:219:1 + --> $DIR/cyclomatic_complexity.rs:210:1 | LL | / fn barrr() { LL | | match 99 { @@ -132,7 +132,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:229:1 + --> $DIR/cyclomatic_complexity.rs:220:1 | LL | / fn barrr2() { LL | | match 99 { @@ -146,7 +146,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:245:1 + --> $DIR/cyclomatic_complexity.rs:236:1 | LL | / fn barrrr() { LL | | match 99 { @@ -160,7 +160,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:255:1 + --> $DIR/cyclomatic_complexity.rs:246:1 | LL | / fn barrrr2() { LL | | match 99 { @@ -174,7 +174,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:271:1 + --> $DIR/cyclomatic_complexity.rs:262:1 | LL | / fn cake() { LL | | if 4 == 5 { @@ -188,7 +188,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 4 - --> $DIR/cyclomatic_complexity.rs:281:1 + --> $DIR/cyclomatic_complexity.rs:272:1 | LL | / pub fn read_file(input_path: &str) -> String { LL | | use std::fs::File; @@ -202,7 +202,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:312:1 + --> $DIR/cyclomatic_complexity.rs:303:1 | LL | / fn void(void: Void) { LL | | if true { @@ -214,7 +214,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:325:1 + --> $DIR/cyclomatic_complexity.rs:316:1 | LL | / fn try() -> Result { LL | | match 5 { @@ -227,7 +227,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:333:1 + --> $DIR/cyclomatic_complexity.rs:324:1 | LL | / fn try_again() -> Result { LL | | let _ = try!(Ok(42)); @@ -241,7 +241,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:349:1 + --> $DIR/cyclomatic_complexity.rs:340:1 | LL | / fn early() -> Result { LL | | return Ok(5); @@ -255,7 +255,7 @@ LL | | } = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 8 - --> $DIR/cyclomatic_complexity.rs:363:1 + --> $DIR/cyclomatic_complexity.rs:354:1 | LL | / fn early_ret() -> i32 { LL | | let a = if true { 42 } else { return 0; }; diff --git a/tests/ui/cyclomatic_complexity_attr_used.rs b/tests/ui/cyclomatic_complexity_attr_used.rs index b1da9649f90..8b5028557d9 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.rs +++ b/tests/ui/cyclomatic_complexity_attr_used.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::cyclomatic_complexity)] #![warn(unused)] diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index dde803880ca..7b732119774 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -1,5 +1,5 @@ error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity_attr_used.rs:18:1 + --> $DIR/cyclomatic_complexity_attr_used.rs:9:1 | LL | / fn kaboom() { LL | | if 42 == 43 { diff --git a/tests/ui/decimal_literal_representation.rs b/tests/ui/decimal_literal_representation.rs index d7823b0b819..d841f16757a 100644 --- a/tests/ui/decimal_literal_representation.rs +++ b/tests/ui/decimal_literal_representation.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::decimal_literal_representation)] #[allow(unused_variables)] #[rustfmt::skip] diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index cc908ca11f3..3a535def197 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,5 +1,5 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:25:9 + --> $DIR/decimal_literal_representation.rs:16:9 | LL | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` @@ -7,25 +7,25 @@ LL | 32_773, // 0x8005 = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:26:9 + --> $DIR/decimal_literal_representation.rs:17:9 | LL | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:27:9 + --> $DIR/decimal_literal_representation.rs:18:9 | LL | 2_131_750_927, // 0x7F0F_F00F | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:28:9 + --> $DIR/decimal_literal_representation.rs:19:9 | LL | 2_147_483_647, // 0x7FFF_FFFF | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:29:9 + --> $DIR/decimal_literal_representation.rs:20:9 | LL | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index eaa367b0cb3..2f1490a7036 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::default_trait_access)] use std::default; diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index 9fcf359b72f..1f115aecca1 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,5 +1,5 @@ error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:17:22 + --> $DIR/default_trait_access.rs:8:22 | LL | let s1: String = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` @@ -7,43 +7,43 @@ LL | let s1: String = Default::default(); = note: `-D clippy::default-trait-access` implied by `-D warnings` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:21:22 + --> $DIR/default_trait_access.rs:12:22 | LL | let s3: String = D2::default(); | ^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:23:22 + --> $DIR/default_trait_access.rs:14:22 | LL | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:27:22 + --> $DIR/default_trait_access.rs:18:22 | LL | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling GenericDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:37:46 + --> $DIR/default_trait_access.rs:28:46 | LL | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` error: Calling TupleDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:43:36 + --> $DIR/default_trait_access.rs:34:36 | LL | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` error: Calling ArrayDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:45:36 + --> $DIR/default_trait_access.rs:36:36 | LL | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` error: Calling TupleStructDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:49:42 + --> $DIR/default_trait_access.rs:40:42 | LL | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` diff --git a/tests/ui/deprecated.rs b/tests/ui/deprecated.rs index 7a1657424ed..2e5c5b7ead1 100644 --- a/tests/ui/deprecated.rs +++ b/tests/ui/deprecated.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(str_to_string)] #[warn(string_to_string)] #[warn(unstable_as_slice)] diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index 3d1f016b9b9..4dbca0dea64 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -1,5 +1,5 @@ error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon` - --> $DIR/deprecated.rs:10:8 + --> $DIR/deprecated.rs:1:8 | LL | #[warn(str_to_string)] | ^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | #[warn(str_to_string)] = note: `-D renamed-and-removed-lints` implied by `-D warnings` error: lint `string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon` - --> $DIR/deprecated.rs:11:8 + --> $DIR/deprecated.rs:2:8 | LL | #[warn(string_to_string)] | ^^^^^^^^^^^^^^^^ error: lint `unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7` - --> $DIR/deprecated.rs:12:8 + --> $DIR/deprecated.rs:3:8 | LL | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ error: lint `unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7` - --> $DIR/deprecated.rs:13:8 + --> $DIR/deprecated.rs:4:8 | LL | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ error: lint `misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr` - --> $DIR/deprecated.rs:14:8 + --> $DIR/deprecated.rs:5:8 | LL | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index a6020b61337..b7a672cd80a 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(untagged_unions)] #![allow(dead_code)] #![warn(clippy::expl_impl_clone_on_copy)] diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index b9629005597..fc87c7d1596 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -1,12 +1,12 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derive.rs:25:10 + --> $DIR/derive.rs:16:10 | LL | #[derive(Hash)] | ^^^^ | = note: #[deny(clippy::derive_hash_xor_eq)] on by default note: `PartialEq` implemented here - --> $DIR/derive.rs:28:1 + --> $DIR/derive.rs:19:1 | LL | / impl PartialEq for Bar { LL | | fn eq(&self, _: &Bar) -> bool { @@ -16,13 +16,13 @@ LL | | } | |_^ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derive.rs:34:10 + --> $DIR/derive.rs:25:10 | LL | #[derive(Hash)] | ^^^^ | note: `PartialEq` implemented here - --> $DIR/derive.rs:37:1 + --> $DIR/derive.rs:28:1 | LL | / impl PartialEq for Baz { LL | | fn eq(&self, _: &Baz) -> bool { @@ -32,7 +32,7 @@ LL | | } | |_^ error: you are implementing `Hash` explicitly but have derived `PartialEq` - --> $DIR/derive.rs:46:1 + --> $DIR/derive.rs:37:1 | LL | / impl Hash for Bah { LL | | fn hash(&self, _: &mut H) {} @@ -40,13 +40,13 @@ LL | | } | |_^ | note: `PartialEq` implemented here - --> $DIR/derive.rs:43:10 + --> $DIR/derive.rs:34:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:53:1 + --> $DIR/derive.rs:44:1 | LL | / impl Clone for Qux { LL | | fn clone(&self) -> Self { @@ -57,7 +57,7 @@ LL | | } | = note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings` note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:53:1 + --> $DIR/derive.rs:44:1 | LL | / impl Clone for Qux { LL | | fn clone(&self) -> Self { @@ -67,7 +67,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:77:1 + --> $DIR/derive.rs:68:1 | LL | / impl<'a> Clone for Lt<'a> { LL | | fn clone(&self) -> Self { @@ -77,7 +77,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:77:1 + --> $DIR/derive.rs:68:1 | LL | / impl<'a> Clone for Lt<'a> { LL | | fn clone(&self) -> Self { @@ -87,7 +87,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:89:1 + --> $DIR/derive.rs:80:1 | LL | / impl Clone for BigArray { LL | | fn clone(&self) -> Self { @@ -97,7 +97,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:89:1 + --> $DIR/derive.rs:80:1 | LL | / impl Clone for BigArray { LL | | fn clone(&self) -> Self { @@ -107,7 +107,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:101:1 + --> $DIR/derive.rs:92:1 | LL | / impl Clone for FnPtr { LL | | fn clone(&self) -> Self { @@ -117,7 +117,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:101:1 + --> $DIR/derive.rs:92:1 | LL | / impl Clone for FnPtr { LL | | fn clone(&self) -> Self { diff --git a/tests/ui/diverging_sub_expression.rs b/tests/ui/diverging_sub_expression.rs index 3399dba7189..746afa47503 100644 --- a/tests/ui/diverging_sub_expression.rs +++ b/tests/ui/diverging_sub_expression.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(never_type)] #![warn(clippy::diverging_sub_expression)] #![allow(clippy::match_same_arms, clippy::logic_bug)] diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 1cfec07c560..70ff3cdd046 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -1,5 +1,5 @@ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:30:10 + --> $DIR/diverging_sub_expression.rs:21:10 | LL | b || diverge(); | ^^^^^^^^^ @@ -7,31 +7,31 @@ LL | b || diverge(); = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:31:10 + --> $DIR/diverging_sub_expression.rs:22:10 | LL | b || A.foo(); | ^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:40:26 + --> $DIR/diverging_sub_expression.rs:31:26 | LL | 6 => true || return, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:41:26 + --> $DIR/diverging_sub_expression.rs:32:26 | LL | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:44:26 + --> $DIR/diverging_sub_expression.rs:35:26 | LL | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:49:26 + --> $DIR/diverging_sub_expression.rs:40:26 | LL | _ => true || break, | ^^^^^ diff --git a/tests/ui/dlist.rs b/tests/ui/dlist.rs index dfc8be24a8b..7634341ba84 100644 --- a/tests/ui/dlist.rs +++ b/tests/ui/dlist.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(alloc)] #![feature(associated_type_defaults)] #![warn(clippy::linkedlist)] diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index 6b0413fdf23..cc4b8e7a3b4 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -1,5 +1,5 @@ error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:19:16 + --> $DIR/dlist.rs:10:16 | LL | type Baz = LinkedList; | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | type Baz = LinkedList; = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:20:12 + --> $DIR/dlist.rs:11:12 | LL | fn foo(LinkedList); | ^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | fn foo(LinkedList); = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:21:23 + --> $DIR/dlist.rs:12:23 | LL | const BAR: Option>; | ^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | const BAR: Option>; = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:32:15 + --> $DIR/dlist.rs:23:15 | LL | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | fn foo(_: LinkedList) {} = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:35:39 + --> $DIR/dlist.rs:26:39 | LL | pub fn test(my_favourite_linked_list: LinkedList) { | ^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | pub fn test(my_favourite_linked_list: LinkedList) { = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:39:29 + --> $DIR/dlist.rs:30:29 | LL | pub fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ diff --git a/tests/ui/doc.rs b/tests/ui/doc.rs index d4ba83a86f3..915fb3aae89 100644 --- a/tests/ui/doc.rs +++ b/tests/ui/doc.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! This file tests for the DOC_MARKDOWN lint #![allow(dead_code)] diff --git a/tests/ui/doc.stderr b/tests/ui/doc.stderr index 964e351348a..4a2ef448e84 100644 --- a/tests/ui/doc.stderr +++ b/tests/ui/doc.stderr @@ -1,5 +1,5 @@ error: you should put `DOC_MARKDOWN` between ticks in the documentation - --> $DIR/doc.rs:10:29 + --> $DIR/doc.rs:1:29 | LL | //! This file tests for the DOC_MARKDOWN lint | ^^^^^^^^^^^^ @@ -7,181 +7,181 @@ LL | //! This file tests for the DOC_MARKDOWN lint = note: `-D clippy::doc-markdown` implied by `-D warnings` error: you should put `foo_bar` between ticks in the documentation - --> $DIR/doc.rs:15:9 + --> $DIR/doc.rs:6:9 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^ error: you should put `foo::bar` between ticks in the documentation - --> $DIR/doc.rs:15:51 + --> $DIR/doc.rs:6:51 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^^ error: you should put `Foo::some_fun` between ticks in the documentation - --> $DIR/doc.rs:16:84 + --> $DIR/doc.rs:7:84 | LL | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun | ^^^^^^^^^^^^^ error: you should put `a::global:path` between ticks in the documentation - --> $DIR/doc.rs:18:15 + --> $DIR/doc.rs:9:15 | LL | /// Here be ::a::global:path. | ^^^^^^^^^^^^^^ error: you should put `NotInCodeBlock` between ticks in the documentation - --> $DIR/doc.rs:19:22 + --> $DIR/doc.rs:10:22 | LL | /// That's not code ~NotInCodeBlock~. | ^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:20:5 + --> $DIR/doc.rs:11:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:34:5 + --> $DIR/doc.rs:25:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:41:5 + --> $DIR/doc.rs:32:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:55:5 + --> $DIR/doc.rs:46:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `link_with_underscores` between ticks in the documentation - --> $DIR/doc.rs:59:22 + --> $DIR/doc.rs:50:22 | LL | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. | ^^^^^^^^^^^^^^^^^^^^^ error: you should put `inline_link2` between ticks in the documentation - --> $DIR/doc.rs:62:21 + --> $DIR/doc.rs:53:21 | LL | /// It can also be [inline_link2]. | ^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:72:5 + --> $DIR/doc.rs:63:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:80:8 + --> $DIR/doc.rs:71:8 | LL | /// ## CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:83:7 + --> $DIR/doc.rs:74:7 | LL | /// # CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:85:22 + --> $DIR/doc.rs:76:22 | LL | /// Not a title #897 CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:86:5 + --> $DIR/doc.rs:77:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:93:5 + --> $DIR/doc.rs:84:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:106:5 + --> $DIR/doc.rs:97:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `FooBar` between ticks in the documentation - --> $DIR/doc.rs:117:42 + --> $DIR/doc.rs:108:42 | LL | /** E.g. serialization of an empty list: FooBar | ^^^^^^ error: you should put `BarQuz` between ticks in the documentation - --> $DIR/doc.rs:122:5 + --> $DIR/doc.rs:113:5 | LL | And BarQuz too. | ^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:123:1 + --> $DIR/doc.rs:114:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `FooBar` between ticks in the documentation - --> $DIR/doc.rs:128:42 + --> $DIR/doc.rs:119:42 | LL | /** E.g. serialization of an empty list: FooBar | ^^^^^^ error: you should put `BarQuz` between ticks in the documentation - --> $DIR/doc.rs:133:5 + --> $DIR/doc.rs:124:5 | LL | And BarQuz too. | ^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:134:1 + --> $DIR/doc.rs:125:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:145:5 + --> $DIR/doc.rs:136:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put bare URLs between `<`/`>` or make a proper Markdown link - --> $DIR/doc.rs:172:13 + --> $DIR/doc.rs:163:13 | LL | /// Not ok: http://www.unicode.org | ^^^^^^^^^^^^^^^^^^^^^^ error: you should put bare URLs between `<`/`>` or make a proper Markdown link - --> $DIR/doc.rs:173:13 + --> $DIR/doc.rs:164:13 | LL | /// Not ok: https://www.unicode.org | ^^^^^^^^^^^^^^^^^^^^^^^ error: you should put bare URLs between `<`/`>` or make a proper Markdown link - --> $DIR/doc.rs:174:13 + --> $DIR/doc.rs:165:13 | LL | /// Not ok: http://www.unicode.org/ | ^^^^^^^^^^^^^^^^^^^^^^ error: you should put bare URLs between `<`/`>` or make a proper Markdown link - --> $DIR/doc.rs:175:13 + --> $DIR/doc.rs:166:13 | LL | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `mycrate::Collection` between ticks in the documentation - --> $DIR/doc.rs:181:22 + --> $DIR/doc.rs:172:22 | LL | /// An iterator over mycrate::Collection's values. | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/double_comparison.fixed b/tests/ui/double_comparison.fixed index fd98edb7555..bb6cdaa667d 100644 --- a/tests/ui/double_comparison.fixed +++ b/tests/ui/double_comparison.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix fn main() { diff --git a/tests/ui/double_comparison.rs b/tests/ui/double_comparison.rs index 5d201a13ff2..9a2a9068a28 100644 --- a/tests/ui/double_comparison.rs +++ b/tests/ui/double_comparison.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix fn main() { diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index 31bab8f0112..5dcda7b3af4 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -1,5 +1,5 @@ error: This binary expression can be simplified - --> $DIR/double_comparison.rs:15:8 + --> $DIR/double_comparison.rs:6:8 | LL | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` @@ -7,43 +7,43 @@ LL | if x == y || x < y { = note: `-D clippy::double-comparisons` implied by `-D warnings` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:18:8 + --> $DIR/double_comparison.rs:9:8 | LL | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:21:8 + --> $DIR/double_comparison.rs:12:8 | LL | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:24:8 + --> $DIR/double_comparison.rs:15:8 | LL | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:27:8 + --> $DIR/double_comparison.rs:18:8 | LL | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:30:8 + --> $DIR/double_comparison.rs:21:8 | LL | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:33:8 + --> $DIR/double_comparison.rs:24:8 | LL | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:36:8 + --> $DIR/double_comparison.rs:27:8 | LL | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` diff --git a/tests/ui/double_neg.rs b/tests/ui/double_neg.rs index 7d65122cb5e..d47dfcb5ba1 100644 --- a/tests/ui/double_neg.rs +++ b/tests/ui/double_neg.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::double_neg)] fn main() { let x = 1; diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index 6ff18e5504d..d82ed05f054 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,5 +1,5 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op - --> $DIR/double_neg.rs:15:5 + --> $DIR/double_neg.rs:6:5 | LL | --x; | ^^^ diff --git a/tests/ui/double_parens.rs b/tests/ui/double_parens.rs index 773179b2d46..c6f9bf77e12 100644 --- a/tests/ui/double_parens.rs +++ b/tests/ui/double_parens.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::double_parens)] #![allow(dead_code)] fn dummy_fn(_: T) {} diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index 0e7f62ca3e3..6336b1c259a 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -1,5 +1,5 @@ error: Consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:21:5 + --> $DIR/double_parens.rs:12:5 | LL | ((0)) | ^^^^^ @@ -7,31 +7,31 @@ LL | ((0)) = note: `-D clippy::double-parens` implied by `-D warnings` error: Consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:25:14 + --> $DIR/double_parens.rs:16:14 | LL | dummy_fn((0)); | ^^^ error: Consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:29:20 + --> $DIR/double_parens.rs:20:20 | LL | x.dummy_method((0)); | ^^^ error: Consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:33:5 + --> $DIR/double_parens.rs:24:5 | LL | ((1, 2)) | ^^^^^^^^ error: Consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:37:5 + --> $DIR/double_parens.rs:28:5 | LL | (()) | ^^^^ error: Consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:59:16 + --> $DIR/double_parens.rs:50:16 | LL | assert_eq!(((1, 2)), (1, 2), "Error"); | ^^^^^^^^ diff --git a/tests/ui/drop_forget_copy.rs b/tests/ui/drop_forget_copy.rs index 2ea8954ff59..9ddd6d64701 100644 --- a/tests/ui/drop_forget_copy.rs +++ b/tests/ui/drop_forget_copy.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::drop_copy, clippy::forget_copy)] #![allow(clippy::toplevel_ref_arg, clippy::drop_ref, clippy::forget_ref, unused_mut)] diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index 6fc69c4bcda..55c840d3480 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -1,73 +1,73 @@ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:42:5 + --> $DIR/drop_forget_copy.rs:33:5 | LL | drop(s1); | ^^^^^^^^ | = note: `-D clippy::drop-copy` implied by `-D warnings` note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:42:10 + --> $DIR/drop_forget_copy.rs:33:10 | LL | drop(s1); | ^^ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:43:5 + --> $DIR/drop_forget_copy.rs:34:5 | LL | drop(s2); | ^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:43:10 + --> $DIR/drop_forget_copy.rs:34:10 | LL | drop(s2); | ^^ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:45:5 + --> $DIR/drop_forget_copy.rs:36:5 | LL | drop(s4); | ^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:45:10 + --> $DIR/drop_forget_copy.rs:36:10 | LL | drop(s4); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:48:5 + --> $DIR/drop_forget_copy.rs:39:5 | LL | forget(s1); | ^^^^^^^^^^ | = note: `-D clippy::forget-copy` implied by `-D warnings` note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:48:12 + --> $DIR/drop_forget_copy.rs:39:12 | LL | forget(s1); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:49:5 + --> $DIR/drop_forget_copy.rs:40:5 | LL | forget(s2); | ^^^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:49:12 + --> $DIR/drop_forget_copy.rs:40:12 | LL | forget(s2); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:51:5 + --> $DIR/drop_forget_copy.rs:42:5 | LL | forget(s4); | ^^^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:51:12 + --> $DIR/drop_forget_copy.rs:42:12 | LL | forget(s4); | ^^ diff --git a/tests/ui/drop_forget_ref.rs b/tests/ui/drop_forget_ref.rs index 6821d403322..b3c75bc5764 100644 --- a/tests/ui/drop_forget_ref.rs +++ b/tests/ui/drop_forget_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::drop_ref, clippy::forget_ref)] #![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)] diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 005adceca50..8ffc369b882 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -1,217 +1,217 @@ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:18:5 + --> $DIR/drop_forget_ref.rs:9:5 | LL | drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::drop-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:18:10 + --> $DIR/drop_forget_ref.rs:9:10 | LL | drop(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:19:5 + --> $DIR/drop_forget_ref.rs:10:5 | LL | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:19:12 + --> $DIR/drop_forget_ref.rs:10:12 | LL | forget(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:22:5 + --> $DIR/drop_forget_ref.rs:13:5 | LL | drop(&owned1); | ^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:22:10 + --> $DIR/drop_forget_ref.rs:13:10 | LL | drop(&owned1); | ^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:23:5 + --> $DIR/drop_forget_ref.rs:14:5 | LL | drop(&&owned1); | ^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct - --> $DIR/drop_forget_ref.rs:23:10 + --> $DIR/drop_forget_ref.rs:14:10 | LL | drop(&&owned1); | ^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:24:5 + --> $DIR/drop_forget_ref.rs:15:5 | LL | drop(&mut owned1); | ^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:24:10 + --> $DIR/drop_forget_ref.rs:15:10 | LL | drop(&mut owned1); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:27:5 + --> $DIR/drop_forget_ref.rs:18:5 | LL | forget(&owned2); | ^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:27:12 + --> $DIR/drop_forget_ref.rs:18:12 | LL | forget(&owned2); | ^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:28:5 + --> $DIR/drop_forget_ref.rs:19:5 | LL | forget(&&owned2); | ^^^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct - --> $DIR/drop_forget_ref.rs:28:12 + --> $DIR/drop_forget_ref.rs:19:12 | LL | forget(&&owned2); | ^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:29:5 + --> $DIR/drop_forget_ref.rs:20:5 | LL | forget(&mut owned2); | ^^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:29:12 + --> $DIR/drop_forget_ref.rs:20:12 | LL | forget(&mut owned2); | ^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:33:5 + --> $DIR/drop_forget_ref.rs:24:5 | LL | drop(reference1); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:33:10 + --> $DIR/drop_forget_ref.rs:24:10 | LL | drop(reference1); | ^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:34:5 + --> $DIR/drop_forget_ref.rs:25:5 | LL | forget(&*reference1); | ^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:34:12 + --> $DIR/drop_forget_ref.rs:25:12 | LL | forget(&*reference1); | ^^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:37:5 + --> $DIR/drop_forget_ref.rs:28:5 | LL | drop(reference2); | ^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:37:10 + --> $DIR/drop_forget_ref.rs:28:10 | LL | drop(reference2); | ^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. + --> $DIR/drop_forget_ref.rs:30:5 + | +LL | forget(reference3); + | ^^^^^^^^^^^^^^^^^^ + | +note: argument has type &mut SomeStruct + --> $DIR/drop_forget_ref.rs:30:12 + | +LL | forget(reference3); + | ^^^^^^^^^^ + +error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. + --> $DIR/drop_forget_ref.rs:33:5 + | +LL | drop(reference4); + | ^^^^^^^^^^^^^^^^ + | +note: argument has type &SomeStruct + --> $DIR/drop_forget_ref.rs:33:10 + | +LL | drop(reference4); + | ^^^^^^^^^^ + +error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. + --> $DIR/drop_forget_ref.rs:34:5 + | +LL | forget(reference4); + | ^^^^^^^^^^^^^^^^^^ + | +note: argument has type &SomeStruct + --> $DIR/drop_forget_ref.rs:34:12 + | +LL | forget(reference4); + | ^^^^^^^^^^ + +error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. --> $DIR/drop_forget_ref.rs:39:5 | -LL | forget(reference3); - | ^^^^^^^^^^^^^^^^^^ - | -note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:39:12 - | -LL | forget(reference3); - | ^^^^^^^^^^ - -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:42:5 - | -LL | drop(reference4); - | ^^^^^^^^^^^^^^^^ - | -note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:42:10 - | -LL | drop(reference4); - | ^^^^^^^^^^ - -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:43:5 - | -LL | forget(reference4); - | ^^^^^^^^^^^^^^^^^^ - | -note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:43:12 - | -LL | forget(reference4); - | ^^^^^^^^^^ - -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:48:5 - | LL | drop(&val); | ^^^^^^^^^^ | note: argument has type &T - --> $DIR/drop_forget_ref.rs:48:10 + --> $DIR/drop_forget_ref.rs:39:10 | LL | drop(&val); | ^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:54:5 + --> $DIR/drop_forget_ref.rs:45:5 | LL | forget(&val); | ^^^^^^^^^^^^ | note: argument has type &T - --> $DIR/drop_forget_ref.rs:54:12 + --> $DIR/drop_forget_ref.rs:45:12 | LL | forget(&val); | ^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:62:5 + --> $DIR/drop_forget_ref.rs:53:5 | LL | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:62:20 + --> $DIR/drop_forget_ref.rs:53:20 | LL | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:65:5 + --> $DIR/drop_forget_ref.rs:56:5 | LL | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:65:22 + --> $DIR/drop_forget_ref.rs:56:22 | LL | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ diff --git a/tests/ui/duplicate_underscore_argument.rs b/tests/ui/duplicate_underscore_argument.rs index da4e2a6dc8a..54d748c7ce2 100644 --- a/tests/ui/duplicate_underscore_argument.rs +++ b/tests/ui/duplicate_underscore_argument.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::duplicate_underscore_argument)] #[allow(dead_code, unused)] diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index e4bdd3f96b2..f71614a5fd1 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -1,5 +1,5 @@ error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult - --> $DIR/duplicate_underscore_argument.rs:13:23 + --> $DIR/duplicate_underscore_argument.rs:4:23 | LL | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ diff --git a/tests/ui/duration_subsec.fixed b/tests/ui/duration_subsec.fixed new file mode 100644 index 00000000000..ee5c7863eff --- /dev/null +++ b/tests/ui/duration_subsec.fixed @@ -0,0 +1,29 @@ +// run-rustfix +#![allow(dead_code)] +#![warn(clippy::duration_subsec)] + +use std::time::Duration; + +fn main() { + let dur = Duration::new(5, 0); + + let bad_millis_1 = dur.subsec_millis(); + let bad_millis_2 = dur.subsec_millis(); + let good_millis = dur.subsec_millis(); + assert_eq!(bad_millis_1, good_millis); + assert_eq!(bad_millis_2, good_millis); + + let bad_micros = dur.subsec_micros(); + let good_micros = dur.subsec_micros(); + assert_eq!(bad_micros, good_micros); + + // Handle refs + let _ = (&dur).subsec_micros(); + + // Handle constants + const NANOS_IN_MICRO: u32 = 1_000; + let _ = dur.subsec_micros(); + + // Other literals aren't linted + let _ = dur.subsec_nanos() / 699; +} diff --git a/tests/ui/duration_subsec.rs b/tests/ui/duration_subsec.rs index 8c2dade34c0..3c9d2a28621 100644 --- a/tests/ui/duration_subsec.rs +++ b/tests/ui/duration_subsec.rs @@ -1,12 +1,5 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix +#![allow(dead_code)] #![warn(clippy::duration_subsec)] use std::time::Duration; diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index e87c9839b33..bd8adc2c570 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,5 +1,5 @@ error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:17:24 + --> $DIR/duration_subsec.rs:10:24 | LL | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` @@ -7,25 +7,25 @@ LL | let bad_millis_1 = dur.subsec_micros() / 1_000; = note: `-D clippy::duration-subsec` implied by `-D warnings` error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:18:24 + --> $DIR/duration_subsec.rs:11:24 | LL | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:23:22 + --> $DIR/duration_subsec.rs:16:22 | LL | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:28:13 + --> $DIR/duration_subsec.rs:21:13 | LL | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:32:13 + --> $DIR/duration_subsec.rs:25:13 | LL | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` diff --git a/tests/ui/else_if_without_else.rs b/tests/ui/else_if_without_else.rs index 0776eae310c..879b3ac398e 100644 --- a/tests/ui/else_if_without_else.rs +++ b/tests/ui/else_if_without_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![warn(clippy::else_if_without_else)] diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index 2c1ecbfdb86..27000906754 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -1,5 +1,5 @@ error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:54:12 + --> $DIR/else_if_without_else.rs:45:12 | LL | } else if bla2() { | ____________^ @@ -12,7 +12,7 @@ LL | | } = help: add an `else` block here error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:63:12 + --> $DIR/else_if_without_else.rs:54:12 | LL | } else if bla3() { | ____________^ diff --git a/tests/ui/empty_enum.rs b/tests/ui/empty_enum.rs index b47afc822f8..12428f29625 100644 --- a/tests/ui/empty_enum.rs +++ b/tests/ui/empty_enum.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] #![warn(clippy::empty_enum)] diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index d2e3688eb4d..223a14ed877 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,12 +1,12 @@ error: enum with no variants - --> $DIR/empty_enum.rs:13:1 + --> $DIR/empty_enum.rs:4:1 | LL | enum Empty {} | ^^^^^^^^^^^^^ | = note: `-D clippy::empty-enum` implied by `-D warnings` help: consider using the uninhabited type `!` or a wrapper around it - --> $DIR/empty_enum.rs:13:1 + --> $DIR/empty_enum.rs:4:1 | LL | enum Empty {} | ^^^^^^^^^^^^^ diff --git a/tests/ui/empty_line_after_outer_attribute.rs b/tests/ui/empty_line_after_outer_attribute.rs index 2bb5037614d..3af8e3eeac0 100644 --- a/tests/ui/empty_line_after_outer_attribute.rs +++ b/tests/ui/empty_line_after_outer_attribute.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::empty_line_after_outer_attr)] #![allow(clippy::assertions_on_constants::assertions_on_constants)] // This should produce a warning diff --git a/tests/ui/empty_line_after_outer_attribute.stderr b/tests/ui/empty_line_after_outer_attribute.stderr index 59939ea2858..0fb8dd8dbb1 100644 --- a/tests/ui/empty_line_after_outer_attribute.stderr +++ b/tests/ui/empty_line_after_outer_attribute.stderr @@ -1,5 +1,5 @@ error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:13:1 + --> $DIR/empty_line_after_outer_attribute.rs:4:1 | LL | / #[crate_type = "lib"] LL | | @@ -10,7 +10,7 @@ LL | | fn with_one_newline_and_comment() { assert!(true) } = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:25:1 + --> $DIR/empty_line_after_outer_attribute.rs:16:1 | LL | / #[crate_type = "lib"] LL | | @@ -18,7 +18,7 @@ LL | | fn with_one_newline() { assert!(true) } | |_ error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:30:1 + --> $DIR/empty_line_after_outer_attribute.rs:21:1 | LL | / #[crate_type = "lib"] LL | | @@ -27,7 +27,7 @@ LL | | fn with_two_newlines() { assert!(true) } | |_ error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:37:1 + --> $DIR/empty_line_after_outer_attribute.rs:28:1 | LL | / #[crate_type = "lib"] LL | | @@ -35,7 +35,7 @@ LL | | enum Baz { | |_ error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:45:1 + --> $DIR/empty_line_after_outer_attribute.rs:36:1 | LL | / #[crate_type = "lib"] LL | | @@ -43,7 +43,7 @@ LL | | struct Foo { | |_ error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:53:1 + --> $DIR/empty_line_after_outer_attribute.rs:44:1 | LL | / #[crate_type = "lib"] LL | | diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index 6c826716650..00d496e36f6 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused, clippy::needless_pass_by_value)] #![warn(clippy::map_entry)] diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 78a179d07ef..efacec1e777 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:19:5 + --> $DIR/entry.rs:10:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -9,7 +9,7 @@ LL | | } = note: `-D clippy::map-entry` implied by `-D warnings` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:25:5 + --> $DIR/entry.rs:16:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -18,7 +18,7 @@ LL | | } | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:32:5 + --> $DIR/entry.rs:23:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v) @@ -28,7 +28,7 @@ LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:40:5 + --> $DIR/entry.rs:31:5 | LL | / if m.contains_key(&k) { LL | | None @@ -38,7 +38,7 @@ LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:48:5 + --> $DIR/entry.rs:39:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -49,7 +49,7 @@ LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:57:5 + --> $DIR/entry.rs:48:5 | LL | / if m.contains_key(&k) { LL | | None @@ -60,7 +60,7 @@ LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `BTreeMap` - --> $DIR/entry.rs:66:5 + --> $DIR/entry.rs:57:5 | LL | / if !m.contains_key(&k) { LL | | foo(); diff --git a/tests/ui/enum_glob_use.rs b/tests/ui/enum_glob_use.rs index dde2896e415..e7b2526ca50 100644 --- a/tests/ui/enum_glob_use.rs +++ b/tests/ui/enum_glob_use.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all, clippy::pedantic)] #![allow(unused_imports, dead_code, clippy::missing_docs_in_private_items)] diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 8b89856d4a4..a301703c298 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,5 +1,5 @@ error: don't use glob imports for enum variants - --> $DIR/enum_glob_use.rs:13:1 + --> $DIR/enum_glob_use.rs:4:1 | LL | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | use std::cmp::Ordering::*; = note: `-D clippy::enum-glob-use` implied by `-D warnings` error: don't use glob imports for enum variants - --> $DIR/enum_glob_use.rs:19:1 + --> $DIR/enum_glob_use.rs:10:1 | LL | use self::Enum::*; | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/enum_variants.rs b/tests/ui/enum_variants.rs index 33472a7f83c..f3bbd3d9626 100644 --- a/tests/ui/enum_variants.rs +++ b/tests/ui/enum_variants.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(non_ascii_idents)] #![warn(clippy::all, clippy::pub_enum_variant_names)] #![allow(non_camel_case_types)] diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 4555e1d0649..2835391de7f 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,5 +1,5 @@ error: Variant name ends with the enum's name - --> $DIR/enum_variants.rs:25:5 + --> $DIR/enum_variants.rs:16:5 | LL | cFoo, | ^^^^ @@ -7,25 +7,25 @@ LL | cFoo, = note: `-D clippy::enum-variant-names` implied by `-D warnings` error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:36:5 + --> $DIR/enum_variants.rs:27:5 | LL | FoodGood, | ^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:37:5 + --> $DIR/enum_variants.rs:28:5 | LL | FoodMiddle, | ^^^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:38:5 + --> $DIR/enum_variants.rs:29:5 | LL | FoodBad, | ^^^^^^^ error: All variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:35:1 + --> $DIR/enum_variants.rs:26:1 | LL | / enum Food { LL | | FoodGood, @@ -37,7 +37,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `CallType` - --> $DIR/enum_variants.rs:45:1 + --> $DIR/enum_variants.rs:36:1 | LL | / enum BadCallType { LL | | CallTypeCall, @@ -49,7 +49,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `Constant` - --> $DIR/enum_variants.rs:57:1 + --> $DIR/enum_variants.rs:48:1 | LL | / enum Consts { LL | | ConstantInt, @@ -61,7 +61,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `With` - --> $DIR/enum_variants.rs:91:1 + --> $DIR/enum_variants.rs:82:1 | LL | / enum Seallll { LL | | WithOutCake, @@ -73,7 +73,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `Prefix` - --> $DIR/enum_variants.rs:97:1 + --> $DIR/enum_variants.rs:88:1 | LL | / enum NonCaps { LL | | Prefix的, @@ -85,7 +85,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `With` - --> $DIR/enum_variants.rs:103:1 + --> $DIR/enum_variants.rs:94:1 | LL | / pub enum PubSeall { LL | | WithOutCake, diff --git a/tests/ui/enums_clike.rs b/tests/ui/enums_clike.rs index 9c1cf8e8614..789542b1351 100644 --- a/tests/ui/enums_clike.rs +++ b/tests/ui/enums_clike.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // ignore-x86 #![warn(clippy::all)] diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index f883529b996..c3390405094 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -1,5 +1,5 @@ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:17:5 + --> $DIR/enums_clike.rs:8:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ @@ -7,17 +7,35 @@ LL | X = 0x1_0000_0000, = note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings` error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:24:5 + --> $DIR/enums_clike.rs:15:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:27:5 + --> $DIR/enums_clike.rs:18:5 | LL | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ +error: Clike enum variant discriminant is not portable to 32-bit targets + --> $DIR/enums_clike.rs:25:5 + | +LL | Z = 0xFFFF_FFFF, + | ^^^^^^^^^^^^^^^ + +error: Clike enum variant discriminant is not portable to 32-bit targets + --> $DIR/enums_clike.rs:26:5 + | +LL | A = 0x1_0000_0000, + | ^^^^^^^^^^^^^^^^^ + +error: Clike enum variant discriminant is not portable to 32-bit targets + --> $DIR/enums_clike.rs:28:5 + | +LL | C = (std::i32::MIN as isize) - 1, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:34:5 | @@ -30,23 +48,5 @@ error: Clike enum variant discriminant is not portable to 32-bit targets LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ -error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:37:5 - | -LL | C = (std::i32::MIN as isize) - 1, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:43:5 - | -LL | Z = 0xFFFF_FFFF, - | ^^^^^^^^^^^^^^^ - -error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:44:5 - | -LL | A = 0x1_0000_0000, - | ^^^^^^^^^^^^^^^^^ - error: aborting due to 8 previous errors diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index 020c7d795a4..cc0935ddb79 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[rustfmt::skip] #[warn(clippy::eq_op)] #[allow(clippy::identity_op, clippy::double_parens, clippy::many_single_char_names)] diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index a1a257095c2..2dabaf0d4db 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/eq_op.rs:44:5 + --> $DIR/eq_op.rs:35:5 | LL | true && true; | ^^^^^^^^^^^^ help: try: `true` @@ -7,37 +7,37 @@ LL | true && true; = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:46:5 + --> $DIR/eq_op.rs:37:5 | LL | true || true; | ^^^^^^^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:52:5 + --> $DIR/eq_op.rs:43:5 | LL | a == b && b == a; | ^^^^^^^^^^^^^^^^ help: try: `a == b` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:53:5 + --> $DIR/eq_op.rs:44:5 | LL | a != b && b != a; | ^^^^^^^^^^^^^^^^ help: try: `a != b` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:54:5 + --> $DIR/eq_op.rs:45:5 | LL | a < b && b > a; | ^^^^^^^^^^^^^^ help: try: `a < b` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:55:5 + --> $DIR/eq_op.rs:46:5 | LL | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ help: try: `a <= b` error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:17:5 + --> $DIR/eq_op.rs:8:5 | LL | 1 == 1; | ^^^^^^ @@ -45,157 +45,157 @@ LL | 1 == 1; = note: `-D clippy::eq-op` implied by `-D warnings` error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:18:5 + --> $DIR/eq_op.rs:9:5 | LL | "no" == "no"; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:20:5 + --> $DIR/eq_op.rs:11:5 | LL | false != false; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> $DIR/eq_op.rs:21:5 + --> $DIR/eq_op.rs:12:5 | LL | 1.5 < 1.5; | ^^^^^^^^^ error: equal expressions as operands to `>=` - --> $DIR/eq_op.rs:22:5 + --> $DIR/eq_op.rs:13:5 | LL | 1u64 >= 1u64; | ^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:25:5 + --> $DIR/eq_op.rs:16:5 | LL | (1 as u64) & (1 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `^` - --> $DIR/eq_op.rs:26:5 + --> $DIR/eq_op.rs:17:5 | LL | 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> $DIR/eq_op.rs:29:5 + --> $DIR/eq_op.rs:20:5 | LL | (-(2) < -(2)); | ^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:30:5 + --> $DIR/eq_op.rs:21:5 | LL | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:30:6 + --> $DIR/eq_op.rs:21:6 | LL | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:30:27 + --> $DIR/eq_op.rs:21:27 | LL | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:31:5 + --> $DIR/eq_op.rs:22:5 | LL | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:34:5 + --> $DIR/eq_op.rs:25:5 | LL | ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:35:5 + --> $DIR/eq_op.rs:26:5 | LL | ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:39:5 + --> $DIR/eq_op.rs:30:5 | LL | 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:40:5 + --> $DIR/eq_op.rs:31:5 | LL | 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:40:5 + --> $DIR/eq_op.rs:31:5 | LL | 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:42:5 + --> $DIR/eq_op.rs:33:5 | LL | 1 - 1; | ^^^^^ error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:43:5 + --> $DIR/eq_op.rs:34:5 | LL | 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:44:5 + --> $DIR/eq_op.rs:35:5 | LL | true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` - --> $DIR/eq_op.rs:46:5 + --> $DIR/eq_op.rs:37:5 | LL | true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:52:5 + --> $DIR/eq_op.rs:43:5 | LL | a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:53:5 + --> $DIR/eq_op.rs:44:5 | LL | a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:54:5 + --> $DIR/eq_op.rs:45:5 | LL | a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:55:5 + --> $DIR/eq_op.rs:46:5 | LL | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:58:5 + --> $DIR/eq_op.rs:49:5 | LL | a == a; | ^^^^^^ error: taken reference of right operand - --> $DIR/eq_op.rs:96:13 + --> $DIR/eq_op.rs:87:13 | LL | let z = x & &y; | ^^^^-- @@ -205,7 +205,7 @@ LL | let z = x & &y; = note: `-D clippy::op-ref` implied by `-D warnings` error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:104:20 + --> $DIR/eq_op.rs:95:20 | LL | const D: u32 = A / A; | ^^^^^ diff --git a/tests/ui/erasing_op.rs b/tests/ui/erasing_op.rs index d7166213194..1540062a4bc 100644 --- a/tests/ui/erasing_op.rs +++ b/tests/ui/erasing_op.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(clippy::no_effect)] #[warn(clippy::erasing_op)] fn main() { diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 85548eefba7..e54ce85f98e 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,5 +1,5 @@ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:15:5 + --> $DIR/erasing_op.rs:6:5 | LL | x * 0; | ^^^^^ @@ -7,13 +7,13 @@ LL | x * 0; = note: `-D clippy::erasing-op` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:16:5 + --> $DIR/erasing_op.rs:7:5 | LL | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:17:5 + --> $DIR/erasing_op.rs:8:5 | LL | 0 / x; | ^^^^^ diff --git a/tests/ui/escape_analysis.rs b/tests/ui/escape_analysis.rs index cc65c6e6306..f582596eb56 100644 --- a/tests/ui/escape_analysis.rs +++ b/tests/ui/escape_analysis.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(box_syntax)] #![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)] #![warn(clippy::boxed_local)] diff --git a/tests/ui/escape_analysis.stderr b/tests/ui/escape_analysis.stderr index ed7819ed429..8af211f8a1a 100644 --- a/tests/ui/escape_analysis.stderr +++ b/tests/ui/escape_analysis.stderr @@ -1,5 +1,5 @@ error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:43:13 + --> $DIR/escape_analysis.rs:34:13 | LL | fn warn_arg(x: Box) { | ^ @@ -7,7 +7,7 @@ LL | fn warn_arg(x: Box) { = note: `-D clippy::boxed-local` implied by `-D warnings` error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:134:12 + --> $DIR/escape_analysis.rs:125:12 | LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index 7b39d1c4054..b39de4c15a4 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( unused, clippy::no_effect, diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index fb7daba1578..218e46b40a8 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,5 +1,5 @@ error: redundant closure found - --> $DIR/eta.rs:22:27 + --> $DIR/eta.rs:13:27 | LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` @@ -7,19 +7,19 @@ LL | let a = Some(1u8).map(|a| foo(a)); = note: `-D clippy::redundant-closure` implied by `-D warnings` error: redundant closure found - --> $DIR/eta.rs:23:10 + --> $DIR/eta.rs:14:10 | LL | meta(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` error: redundant closure found - --> $DIR/eta.rs:24:27 + --> $DIR/eta.rs:15:27 | LL | let c = Some(1u8).map(|a| {1+2; foo}(a)); | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/eta.rs:26:21 + --> $DIR/eta.rs:17:21 | LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^ help: change this to: `&2` @@ -27,7 +27,7 @@ LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted = note: `-D clippy::needless-borrow` implied by `-D warnings` error: redundant closure found - --> $DIR/eta.rs:33:27 + --> $DIR/eta.rs:24:27 | LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` diff --git a/tests/ui/eval_order_dependence.rs b/tests/ui/eval_order_dependence.rs index 82110d5e4f3..d806bc6d401 100644 --- a/tests/ui/eval_order_dependence.rs +++ b/tests/ui/eval_order_dependence.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::eval_order_dependence)] #[allow( unused_assignments, diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index 929650a7da8..8f4fa2228f7 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -1,48 +1,48 @@ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:24:9 + --> $DIR/eval_order_dependence.rs:15:9 | LL | } + x; | ^ | = note: `-D clippy::eval-order-dependence` implied by `-D warnings` note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:22:9 + --> $DIR/eval_order_dependence.rs:13:9 | LL | x = 1; | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:27:5 + --> $DIR/eval_order_dependence.rs:18:5 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:28:9 + --> $DIR/eval_order_dependence.rs:19:9 | LL | x = 20; | ^^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:40:12 + --> $DIR/eval_order_dependence.rs:31:12 | LL | a: x, | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:42:13 + --> $DIR/eval_order_dependence.rs:33:13 | LL | x = 6; | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:49:9 + --> $DIR/eval_order_dependence.rs:40:9 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:50:13 + --> $DIR/eval_order_dependence.rs:41:13 | LL | x = 20; | ^^^^^^ diff --git a/tests/ui/excessive_precision.fixed b/tests/ui/excessive_precision.fixed new file mode 100644 index 00000000000..1646dff9064 --- /dev/null +++ b/tests/ui/excessive_precision.fixed @@ -0,0 +1,63 @@ +// run-rustfix +#![warn(clippy::excessive_precision)] +#![allow(dead_code, unused_variables, clippy::print_literal)] + +fn main() { + // Consts + const GOOD32: f32 = 0.123_456; + const GOOD32_SM: f32 = 0.000_000_000_1; + const GOOD32_DOT: f32 = 10_000_000_000.0; + const GOOD32_EDGE: f32 = 1.000_000_8; + const GOOD64: f64 = 0.123_456_789_012; + const GOOD64_SM: f32 = 0.000_000_000_000_000_1; + const GOOD64_DOT: f32 = 10_000_000_000_000_000.0; + + const BAD32_1: f32 = 0.123_456_79; + const BAD32_2: f32 = 0.123_456_79; + const BAD32_3: f32 = 0.1; + const BAD32_EDGE: f32 = 1.000_001; + + const BAD64_1: f64 = 0.123_456_789_012_345_66; + const BAD64_2: f64 = 0.123_456_789_012_345_66; + const BAD64_3: f64 = 0.1; + + // Literal as param + println!("{:?}", 8.888_888_888_888_89); + + // // TODO add inferred type tests for f32 + // Locals + let good32: f32 = 0.123_456_f32; + let good32_2: f32 = 0.123_456; + + let good64: f64 = 0.123_456_789_012; + let good64_suf: f64 = 0.123_456_789_012f64; + let good64_inf = 0.123_456_789_012; + + let bad32: f32 = 1.123_456_8; + let bad32_suf: f32 = 1.123_456_8; + let bad32_inf = 1.123_456_8; + + let bad64: f64 = 0.123_456_789_012_345_66; + let bad64_suf: f64 = 0.123_456_789_012_345_66; + let bad64_inf = 0.123_456_789_012_345_66; + + // Vectors + let good_vec32: Vec = vec![0.123_456]; + let good_vec64: Vec = vec![0.123_456_789]; + + let bad_vec32: Vec = vec![0.123_456_79]; + let bad_vec64: Vec = vec![0.123_456_789_123_456_78]; + + // Exponential float notation + let good_e32: f32 = 1e-10; + let bad_e32: f32 = 1.123_456_8e-10; + + let good_bige32: f32 = 1E-10; + let bad_bige32: f32 = 1.123_456_8E-10; + + // Inferred type + let good_inferred: f32 = 1f32 * 1_000_000_000.; + + // issue #2840 + let num = 0.000_000_000_01e-10f64; +} diff --git a/tests/ui/excessive_precision.rs b/tests/ui/excessive_precision.rs index 59b252a3a80..ce4722a90f9 100644 --- a/tests/ui/excessive_precision.rs +++ b/tests/ui/excessive_precision.rs @@ -1,14 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![warn(clippy::excessive_precision)] -#![allow(clippy::print_literal)] +#![allow(dead_code, unused_variables, clippy::print_literal)] fn main() { // Consts diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 57c33c4719b..12f8a61b75c 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -1,5 +1,5 @@ error: float has excessive precision - --> $DIR/excessive_precision.rs:23:26 + --> $DIR/excessive_precision.rs:15:26 | LL | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` @@ -7,103 +7,103 @@ LL | const BAD32_1: f32 = 0.123_456_789_f32; = note: `-D clippy::excessive-precision` implied by `-D warnings` error: float has excessive precision - --> $DIR/excessive_precision.rs:24:26 + --> $DIR/excessive_precision.rs:16:26 | LL | const BAD32_2: f32 = 0.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:25:26 + --> $DIR/excessive_precision.rs:17:26 | LL | const BAD32_3: f32 = 0.100_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:26:29 + --> $DIR/excessive_precision.rs:18:29 | LL | const BAD32_EDGE: f32 = 1.000_000_9; | ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` error: float has excessive precision - --> $DIR/excessive_precision.rs:28:26 + --> $DIR/excessive_precision.rs:20:26 | LL | const BAD64_1: f64 = 0.123_456_789_012_345_67f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:29:26 + --> $DIR/excessive_precision.rs:21:26 | LL | const BAD64_2: f64 = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:30:26 + --> $DIR/excessive_precision.rs:22:26 | LL | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:33:22 + --> $DIR/excessive_precision.rs:25:22 | LL | println!("{:?}", 8.888_888_888_888_888_888_888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` error: float has excessive precision - --> $DIR/excessive_precision.rs:44:22 + --> $DIR/excessive_precision.rs:36:22 | LL | let bad32: f32 = 1.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:45:26 + --> $DIR/excessive_precision.rs:37:26 | LL | let bad32_suf: f32 = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:46:21 + --> $DIR/excessive_precision.rs:38:21 | LL | let bad32_inf = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:48:22 + --> $DIR/excessive_precision.rs:40:22 | LL | let bad64: f64 = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:49:26 + --> $DIR/excessive_precision.rs:41:26 | LL | let bad64_suf: f64 = 0.123_456_789_012_345_67f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:50:21 + --> $DIR/excessive_precision.rs:42:21 | LL | let bad64_inf = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:56:36 + --> $DIR/excessive_precision.rs:48:36 | LL | let bad_vec32: Vec = vec![0.123_456_789]; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:57:36 + --> $DIR/excessive_precision.rs:49:36 | LL | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` error: float has excessive precision - --> $DIR/excessive_precision.rs:61:24 + --> $DIR/excessive_precision.rs:53:24 | LL | let bad_e32: f32 = 1.123_456_788_888e-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:64:27 + --> $DIR/excessive_precision.rs:56:27 | LL | let bad_bige32: f32 = 1.123_456_788_888E-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` diff --git a/tests/ui/expect_fun_call.rs b/tests/ui/expect_fun_call.rs index 8afffa4d843..7f0ca0fe809 100644 --- a/tests/ui/expect_fun_call.rs +++ b/tests/ui/expect_fun_call.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::expect_fun_call)] #![allow(clippy::useless_format)] @@ -66,6 +57,8 @@ fn expect_fun_call() { Some("foo").expect({ &format!("error") }); Some("foo").expect(format!("error").as_ref()); + + Some("foo").expect(format!("{} {}", 1, 2).as_ref()); } fn main() {} diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr index 72a6995c1ce..a60bd7e4ed3 100644 --- a/tests/ui/expect_fun_call.stderr +++ b/tests/ui/expect_fun_call.stderr @@ -1,5 +1,5 @@ error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:36:26 + --> $DIR/expect_fun_call.rs:27:26 | LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` @@ -7,34 +7,40 @@ LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code = note: `-D clippy::expect-fun-call` implied by `-D warnings` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:39:26 + --> $DIR/expect_fun_call.rs:30:26 | LL | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:49:25 + --> $DIR/expect_fun_call.rs:40:25 | LL | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:52:25 + --> $DIR/expect_fun_call.rs:43:25 | LL | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:67:17 + --> $DIR/expect_fun_call.rs:58:17 | LL | Some("foo").expect({ &format!("error") }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { let msg = { &format!("error") }; panic!(msg) }))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:68:17 + --> $DIR/expect_fun_call.rs:59:17 | LL | Some("foo").expect(format!("error").as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("error"))` -error: aborting due to 6 previous errors +error: use of `expect` followed by a function call + --> $DIR/expect_fun_call.rs:61:17 + | +LL | Some("foo").expect(format!("{} {}", 1, 2).as_ref()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{} {}", 1, 2))` + +error: aborting due to 7 previous errors diff --git a/tests/ui/explicit_counter_loop.rs b/tests/ui/explicit_counter_loop.rs index 75d905659d9..5efac85cf22 100644 --- a/tests/ui/explicit_counter_loop.rs +++ b/tests/ui/explicit_counter_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::explicit_counter_loop)] fn main() { diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index caccaee84b9..b1cfb31432f 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -1,5 +1,5 @@ error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:15:15 + --> $DIR/explicit_counter_loop.rs:6:15 | LL | for _v in &vec { | ^^^^ @@ -7,19 +7,19 @@ LL | for _v in &vec { = note: `-D clippy::explicit-counter-loop` implied by `-D warnings` error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:21:15 + --> $DIR/explicit_counter_loop.rs:12:15 | LL | for _v in &vec { | ^^^^ error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:60:19 + --> $DIR/explicit_counter_loop.rs:51:19 | LL | for ch in text.chars() { | ^^^^^^^^^^^^ error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:71:19 + --> $DIR/explicit_counter_loop.rs:62:19 | LL | for ch in text.chars() { | ^^^^^^^^^^^^ diff --git a/tests/ui/explicit_write.fixed b/tests/ui/explicit_write.fixed new file mode 100644 index 00000000000..692d2ca675f --- /dev/null +++ b/tests/ui/explicit_write.fixed @@ -0,0 +1,51 @@ +// run-rustfix +#![allow(unused_imports)] +#![warn(clippy::explicit_write)] + +fn stdout() -> String { + String::new() +} + +fn stderr() -> String { + String::new() +} + +fn main() { + // these should warn + { + use std::io::Write; + print!("test"); + eprint!("test"); + println!("test"); + eprintln!("test"); + print!("test"); + eprint!("test"); + + // including newlines + println!("test\ntest"); + eprintln!("test\ntest"); + } + // these should not warn, different destination + { + use std::fmt::Write; + let mut s = String::new(); + write!(s, "test").unwrap(); + write!(s, "test").unwrap(); + writeln!(s, "test").unwrap(); + writeln!(s, "test").unwrap(); + s.write_fmt(format_args!("test")).unwrap(); + s.write_fmt(format_args!("test")).unwrap(); + write!(stdout(), "test").unwrap(); + write!(stderr(), "test").unwrap(); + writeln!(stdout(), "test").unwrap(); + writeln!(stderr(), "test").unwrap(); + stdout().write_fmt(format_args!("test")).unwrap(); + stderr().write_fmt(format_args!("test")).unwrap(); + } + // these should not warn, no unwrap + { + use std::io::Write; + std::io::stdout().write_fmt(format_args!("test")).expect("no stdout"); + std::io::stderr().write_fmt(format_args!("test")).expect("no stderr"); + } +} diff --git a/tests/ui/explicit_write.rs b/tests/ui/explicit_write.rs index 01a63b3a95f..455c5ef55d0 100644 --- a/tests/ui/explicit_write.rs +++ b/tests/ui/explicit_write.rs @@ -1,12 +1,5 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix +#![allow(unused_imports)] #![warn(clippy::explicit_write)] fn stdout() -> String { diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index 1072d9bd0d2..9feef9c0dc8 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,5 +1,5 @@ error: use of `write!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:24:9 + --> $DIR/explicit_write.rs:17:9 | LL | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")` @@ -7,43 +7,43 @@ LL | write!(std::io::stdout(), "test").unwrap(); = note: `-D clippy::explicit-write` implied by `-D warnings` error: use of `write!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:25:9 + --> $DIR/explicit_write.rs:18:9 | LL | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:26:9 + --> $DIR/explicit_write.rs:19:9 | LL | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:27:9 + --> $DIR/explicit_write.rs:20:9 | LL | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test")` error: use of `stdout().write_fmt(...).unwrap()` - --> $DIR/explicit_write.rs:28:9 + --> $DIR/explicit_write.rs:21:9 | LL | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")` error: use of `stderr().write_fmt(...).unwrap()` - --> $DIR/explicit_write.rs:29:9 + --> $DIR/explicit_write.rs:22:9 | LL | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:32:9 + --> $DIR/explicit_write.rs:25:9 | LL | writeln!(std::io::stdout(), "test/ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test/ntest")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:33:9 + --> $DIR/explicit_write.rs:26:9 | LL | writeln!(std::io::stderr(), "test/ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test/ntest")` diff --git a/tests/ui/fallible_impl_from.rs b/tests/ui/fallible_impl_from.rs index 0d8c369660b..679f4a7dc35 100644 --- a/tests/ui/fallible_impl_from.rs +++ b/tests/ui/fallible_impl_from.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::fallible_impl_from)] // docs example diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 55efac7951a..8b847df65cd 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,5 +1,5 @@ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:14:1 + --> $DIR/fallible_impl_from.rs:5:1 | LL | / impl From for Foo { LL | | fn from(s: String) -> Self { @@ -9,19 +9,19 @@ LL | | } | |_^ | note: lint level defined here - --> $DIR/fallible_impl_from.rs:10:9 + --> $DIR/fallible_impl_from.rs:1:9 | LL | #![deny(clippy::fallible_impl_from)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:16:13 + --> $DIR/fallible_impl_from.rs:7:13 | LL | Foo(s.parse().unwrap()) | ^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:35:1 + --> $DIR/fallible_impl_from.rs:26:1 | LL | / impl From for Invalid { LL | | fn from(i: usize) -> Invalid { @@ -34,14 +34,14 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:38:13 + --> $DIR/fallible_impl_from.rs:29:13 | LL | panic!(); | ^^^^^^^^^ = 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: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:44:1 + --> $DIR/fallible_impl_from.rs:35:1 | LL | / impl From> for Invalid { LL | | fn from(s: Option) -> Invalid { @@ -54,7 +54,7 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:46:17 + --> $DIR/fallible_impl_from.rs:37:17 | LL | let s = s.unwrap(); | ^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | panic!("{:?}", 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: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:62:1 + --> $DIR/fallible_impl_from.rs:53:1 | LL | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { LL | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { @@ -81,7 +81,7 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:64:12 + --> $DIR/fallible_impl_from.rs:55:12 | LL | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/filter_methods.rs b/tests/ui/filter_methods.rs index 7ca74fd4b99..ef434245fd7 100644 --- a/tests/ui/filter_methods.rs +++ b/tests/ui/filter_methods.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::missing_docs_in_private_items)] diff --git a/tests/ui/filter_methods.stderr b/tests/ui/filter_methods.stderr index c10d673148a..9dfd91f6d64 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -1,5 +1,5 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.filter_map(..)` instead. - --> $DIR/filter_methods.rs:14:21 + --> $DIR/filter_methods.rs:5:21 | LL | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * = note: `-D clippy::filter-map` implied by `-D warnings` error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. - --> $DIR/filter_methods.rs:16:21 + --> $DIR/filter_methods.rs:7:21 | LL | let _: Vec<_> = vec![5_i8; 6] | _____________________^ @@ -17,7 +17,7 @@ LL | | .flat_map(|x| x.checked_mul(2)) | |_______________________________________^ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. - --> $DIR/filter_methods.rs:22:21 + --> $DIR/filter_methods.rs:13:21 | LL | let _: Vec<_> = vec![5_i8; 6] | _____________________^ @@ -27,7 +27,7 @@ LL | | .flat_map(|x| x.checked_mul(2)) | |_______________________________________^ error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly expressed by only calling `.filter_map(..)` instead. - --> $DIR/filter_methods.rs:28:21 + --> $DIR/filter_methods.rs:19:21 | LL | let _: Vec<_> = vec![5_i8; 6] | _____________________^ diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 2d55e30a2d3..92d38527bbf 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::float_cmp)] #![allow(unused, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)] diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index bdbbccee714..ddaf4b82497 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,36 +1,36 @@ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:69:5 + --> $DIR/float_cmp.rs:60:5 | LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE as f64 - 2.0).abs() < error` | = note: `-D clippy::float-cmp` implied by `-D warnings` note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:69:5 + --> $DIR/float_cmp.rs:60:5 | LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:74:5 + --> $DIR/float_cmp.rs:65:5 | LL | x == 1.0; | ^^^^^^^^ help: consider comparing them within some error: `(x - 1.0).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:74:5 + --> $DIR/float_cmp.rs:65:5 | LL | x == 1.0; | ^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:77:5 + --> $DIR/float_cmp.rs:68:5 | LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(twice(x) - twice(ONE as f64)).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:77:5 + --> $DIR/float_cmp.rs:68:5 | LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/float_cmp_const.rs b/tests/ui/float_cmp_const.rs index e02671e0dcc..887275c5e88 100644 --- a/tests/ui/float_cmp_const.rs +++ b/tests/ui/float_cmp_const.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::float_cmp_const)] #![allow(clippy::float_cmp)] #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index 2b434f31814..9ec921e536a 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -1,84 +1,84 @@ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:27:5 + --> $DIR/float_cmp_const.rs:18:5 | LL | 1f32 == ONE; | ^^^^^^^^^^^ help: consider comparing them within some error: `(1f32 - ONE).abs() < error` | = note: `-D clippy::float-cmp-const` implied by `-D warnings` note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:27:5 + --> $DIR/float_cmp_const.rs:18:5 | LL | 1f32 == ONE; | ^^^^^^^^^^^ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:28:5 + --> $DIR/float_cmp_const.rs:19:5 | LL | TWO == ONE; | ^^^^^^^^^^ help: consider comparing them within some error: `(TWO - ONE).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:28:5 + --> $DIR/float_cmp_const.rs:19:5 | LL | TWO == ONE; | ^^^^^^^^^^ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:29:5 + --> $DIR/float_cmp_const.rs:20:5 | LL | TWO != ONE; | ^^^^^^^^^^ help: consider comparing them within some error: `(TWO - ONE).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:29:5 + --> $DIR/float_cmp_const.rs:20:5 | LL | TWO != ONE; | ^^^^^^^^^^ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:30:5 + --> $DIR/float_cmp_const.rs:21:5 | LL | ONE + ONE == TWO; | ^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE + ONE - TWO).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:30:5 + --> $DIR/float_cmp_const.rs:21:5 | LL | ONE + ONE == TWO; | ^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:31:5 + --> $DIR/float_cmp_const.rs:22:5 | LL | 1 as f32 == ONE; | ^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(1 as f32 - ONE).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:31:5 + --> $DIR/float_cmp_const.rs:22:5 | LL | 1 as f32 == ONE; | ^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:34:5 + --> $DIR/float_cmp_const.rs:25:5 | LL | v == ONE; | ^^^^^^^^ help: consider comparing them within some error: `(v - ONE).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:34:5 + --> $DIR/float_cmp_const.rs:25:5 | LL | v == ONE; | ^^^^^^^^ error: strict comparison of f32 or f64 constant - --> $DIR/float_cmp_const.rs:35:5 + --> $DIR/float_cmp_const.rs:26:5 | LL | v != ONE; | ^^^^^^^^ help: consider comparing them within some error: `(v - ONE).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp_const.rs:35:5 + --> $DIR/float_cmp_const.rs:26:5 | LL | v != ONE; | ^^^^^^^^ diff --git a/tests/ui/fn_to_numeric_cast.rs b/tests/ui/fn_to_numeric_cast.rs index 9b48a965cb3..21573af870a 100644 --- a/tests/ui/fn_to_numeric_cast.rs +++ b/tests/ui/fn_to_numeric_cast.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // only-64bit #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] diff --git a/tests/ui/fn_to_numeric_cast.stderr b/tests/ui/fn_to_numeric_cast.stderr index 16605fd344a..e9549e157cd 100644 --- a/tests/ui/fn_to_numeric_cast.stderr +++ b/tests/ui/fn_to_numeric_cast.stderr @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:19:13 + --> $DIR/fn_to_numeric_cast.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` @@ -7,19 +7,19 @@ LL | let _ = foo as i8; = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings` error: casting function pointer `foo` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:20:13 + --> $DIR/fn_to_numeric_cast.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:21:13 + --> $DIR/fn_to_numeric_cast.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast.rs:22:13 + --> $DIR/fn_to_numeric_cast.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` @@ -27,115 +27,115 @@ LL | let _ = foo as i64; = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings` error: casting function pointer `foo` to `i128` - --> $DIR/fn_to_numeric_cast.rs:23:13 + --> $DIR/fn_to_numeric_cast.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast.rs:24:13 + --> $DIR/fn_to_numeric_cast.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:26:13 + --> $DIR/fn_to_numeric_cast.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:27:13 + --> $DIR/fn_to_numeric_cast.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:28:13 + --> $DIR/fn_to_numeric_cast.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast.rs:29:13 + --> $DIR/fn_to_numeric_cast.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast.rs:30:13 + --> $DIR/fn_to_numeric_cast.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `abc` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:43:13 + --> $DIR/fn_to_numeric_cast.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:44:13 + --> $DIR/fn_to_numeric_cast.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:45:13 + --> $DIR/fn_to_numeric_cast.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i64` - --> $DIR/fn_to_numeric_cast.rs:46:13 + --> $DIR/fn_to_numeric_cast.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i128` - --> $DIR/fn_to_numeric_cast.rs:47:13 + --> $DIR/fn_to_numeric_cast.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `isize` - --> $DIR/fn_to_numeric_cast.rs:48:13 + --> $DIR/fn_to_numeric_cast.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:50:13 + --> $DIR/fn_to_numeric_cast.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:51:13 + --> $DIR/fn_to_numeric_cast.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:52:13 + --> $DIR/fn_to_numeric_cast.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u64` - --> $DIR/fn_to_numeric_cast.rs:53:13 + --> $DIR/fn_to_numeric_cast.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u128` - --> $DIR/fn_to_numeric_cast.rs:54:13 + --> $DIR/fn_to_numeric_cast.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `f` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:61:5 + --> $DIR/fn_to_numeric_cast.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` diff --git a/tests/ui/for_kv_map.rs b/tests/ui/for_kv_map.rs index 549187756ab..39a8d960a7e 100644 --- a/tests/ui/for_kv_map.rs +++ b/tests/ui/for_kv_map.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::for_kv_map)] #![allow(clippy::used_underscore_binding)] diff --git a/tests/ui/for_kv_map.stderr b/tests/ui/for_kv_map.stderr index 7b65c58f58d..ebe758526ec 100644 --- a/tests/ui/for_kv_map.stderr +++ b/tests/ui/for_kv_map.stderr @@ -1,5 +1,5 @@ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:18:19 + --> $DIR/for_kv_map.rs:9:19 | LL | for (_, v) in &m { | ^^ @@ -11,7 +11,7 @@ LL | for v in m.values() { | ^ ^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:23:19 + --> $DIR/for_kv_map.rs:14:19 | LL | for (_, v) in &*m { | ^^^ @@ -21,7 +21,7 @@ LL | for v in (*m).values() { | ^ ^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:31:19 + --> $DIR/for_kv_map.rs:22:19 | LL | for (_, v) in &mut m { | ^^^^^^ @@ -31,7 +31,7 @@ LL | for v in m.values_mut() { | ^ ^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:36:19 + --> $DIR/for_kv_map.rs:27:19 | LL | for (_, v) in &mut *m { | ^^^^^^^ @@ -41,7 +41,7 @@ LL | for v in (*m).values_mut() { | ^ ^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's keys - --> $DIR/for_kv_map.rs:42:24 + --> $DIR/for_kv_map.rs:33:24 | LL | for (k, _value) in rm { | ^^ diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index c172b0b3b77..f73bb41a9bb 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::collections::*; use std::rc::Rc; diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 4ded425b321..50f10d6187b 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -1,5 +1,5 @@ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:50:14 + --> $DIR/for_loop.rs:41:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -11,7 +11,7 @@ LL | for in &vec { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:59:14 + --> $DIR/for_loop.rs:50:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | for in &vec { | ^^^^^^ ^^^^ error: the loop variable `j` is only used to index `STATIC`. - --> $DIR/for_loop.rs:64:14 + --> $DIR/for_loop.rs:55:14 | LL | for j in 0..4 { | ^^^^ @@ -31,7 +31,7 @@ LL | for in &STATIC { | ^^^^^^ ^^^^^^^ error: the loop variable `j` is only used to index `CONST`. - --> $DIR/for_loop.rs:68:14 + --> $DIR/for_loop.rs:59:14 | LL | for j in 0..4 { | ^^^^ @@ -41,7 +41,7 @@ LL | for in &CONST { | ^^^^^^ ^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:72:14 + --> $DIR/for_loop.rs:63:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | for (i, ) in vec.iter().enumerate() { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec2`. - --> $DIR/for_loop.rs:80:14 + --> $DIR/for_loop.rs:71:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | for in vec2.iter().take(vec.len()) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:84:14 + --> $DIR/for_loop.rs:75:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | for in vec.iter().skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:88:14 + --> $DIR/for_loop.rs:79:14 | LL | for i in 0..MAX_LEN { | ^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | for in vec.iter().take(MAX_LEN) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:92:14 + --> $DIR/for_loop.rs:83:14 | LL | for i in 0..=MAX_LEN { | ^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | for in vec.iter().take(MAX_LEN + 1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:96:14 + --> $DIR/for_loop.rs:87:14 | LL | for i in 5..10 { | ^^^^^ @@ -101,7 +101,7 @@ LL | for in vec.iter().take(10).skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:100:14 + --> $DIR/for_loop.rs:91:14 | LL | for i in 5..=10 { | ^^^^^^ @@ -111,7 +111,7 @@ LL | for in vec.iter().take(10 + 1).skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:104:14 + --> $DIR/for_loop.rs:95:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | for (i, ) in vec.iter().enumerate().skip(5) { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:108:14 + --> $DIR/for_loop.rs:99:14 | LL | for i in 5..10 { | ^^^^^ @@ -131,7 +131,7 @@ LL | for (i, ) in vec.iter().enumerate().take(10).skip(5) { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:112:14 + --> $DIR/for_loop.rs:103:14 | LL | for i in 10..0 { | ^^^^^ @@ -143,7 +143,7 @@ LL | for i in (0..10).rev() { | ^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:116:14 + --> $DIR/for_loop.rs:107:14 | LL | for i in 10..=0 { | ^^^^^^ @@ -153,7 +153,7 @@ LL | for i in (0...10).rev() { | ^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:120:14 + --> $DIR/for_loop.rs:111:14 | LL | for i in MAX_LEN..0 { | ^^^^^^^^^^ @@ -163,13 +163,13 @@ LL | for i in (0..MAX_LEN).rev() { | ^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:124:14 + --> $DIR/for_loop.rs:115:14 | LL | for i in 5..5 { | ^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:149:14 + --> $DIR/for_loop.rs:140:14 | LL | for i in 10..5 + 4 { | ^^^^^^^^^ @@ -179,7 +179,7 @@ LL | for i in (5 + 4..10).rev() { | ^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:153:14 + --> $DIR/for_loop.rs:144:14 | LL | for i in (5 + 2)..(3 - 1) { | ^^^^^^^^^^^^^^^^ @@ -189,13 +189,13 @@ LL | for i in ((3 - 1)..(5 + 2)).rev() { | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:157:14 + --> $DIR/for_loop.rs:148:14 | LL | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:179:15 + --> $DIR/for_loop.rs:170:15 | LL | for _v in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` @@ -203,13 +203,13 @@ LL | for _v in vec.iter() {} = note: `-D clippy::explicit-iter-loop` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:181:15 + --> $DIR/for_loop.rs:172:15 | LL | for _v in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over containers instead of using explicit iteration methods` - --> $DIR/for_loop.rs:184:15 + --> $DIR/for_loop.rs:175:15 | LL | for _v in out_vec.into_iter() {} | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` @@ -217,67 +217,67 @@ LL | for _v in out_vec.into_iter() {} = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:187:15 + --> $DIR/for_loop.rs:178:15 | LL | for _v in array.into_iter() {} | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:192:15 + --> $DIR/for_loop.rs:183:15 | LL | for _v in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:196:15 + --> $DIR/for_loop.rs:187:15 | LL | for _v in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:201:15 + --> $DIR/for_loop.rs:192:15 | LL | for _v in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:204:15 + --> $DIR/for_loop.rs:195:15 | LL | for _v in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:207:15 + --> $DIR/for_loop.rs:198:15 | LL | for _v in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:210:15 + --> $DIR/for_loop.rs:201:15 | LL | for _v in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:213:15 + --> $DIR/for_loop.rs:204:15 | LL | for _v in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:216:15 + --> $DIR/for_loop.rs:207:15 | LL | for _v in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:219:15 + --> $DIR/for_loop.rs:210:15 | LL | for _v in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want - --> $DIR/for_loop.rs:221:15 + --> $DIR/for_loop.rs:212:15 | LL | for _v in vec.iter().next() {} | ^^^^^^^^^^^^^^^^^ @@ -285,7 +285,7 @@ LL | for _v in vec.iter().next() {} = note: `-D clippy::iter-next-loop` implied by `-D warnings` error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/for_loop.rs:228:5 + --> $DIR/for_loop.rs:219:5 | LL | vec.iter().cloned().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -293,7 +293,7 @@ LL | vec.iter().cloned().map(|x| out.push(x)).collect::>(); = note: `-D clippy::unused-collect` implied by `-D warnings` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:372:14 + --> $DIR/for_loop.rs:363:14 | LL | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` @@ -301,31 +301,31 @@ LL | for i in 0..src.len() { = note: `-D clippy::manual-memcpy` implied by `-D warnings` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:377:14 + --> $DIR/for_loop.rs:368:14 | LL | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[10..(src.len() + 10)].clone_from_slice(&src[..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:382:14 + --> $DIR/for_loop.rs:373:14 | LL | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[10..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:387:14 + --> $DIR/for_loop.rs:378:14 | LL | for i in 11..src.len() { | ^^^^^^^^^^^^^ help: try replacing the loop by: `dst[11..src.len()].clone_from_slice(&src[(11 - 10)..(src.len() - 10)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:392:14 + --> $DIR/for_loop.rs:383:14 | LL | for i in 0..dst.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..dst.len()])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:405:14 + --> $DIR/for_loop.rs:396:14 | LL | for i in 10..256 { | ^^^^^^^ @@ -336,31 +336,31 @@ LL | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) { | error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:417:14 + --> $DIR/for_loop.rs:408:14 | LL | for i in 10..LOOP_OFFSET { | ^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].clone_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:430:14 + --> $DIR/for_loop.rs:421:14 | LL | for i in 0..src_vec.len() { | ^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst_vec[..src_vec.len()].clone_from_slice(&src_vec[..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:459:14 + --> $DIR/for_loop.rs:450:14 | LL | for i in from..from + src.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + src.len()].clone_from_slice(&src[0..(from + src.len() - from)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:463:14 + --> $DIR/for_loop.rs:454:14 | LL | for i in from..from + 3 { | ^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + 3].clone_from_slice(&src[0..(from + 3 - from)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:470:14 + --> $DIR/for_loop.rs:461:14 | LL | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` diff --git a/tests/ui/for_loop_over_option_result.rs b/tests/ui/for_loop_over_option_result.rs index 37fd4e6d038..6b207b26b6b 100644 --- a/tests/ui/for_loop_over_option_result.rs +++ b/tests/ui/for_loop_over_option_result.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::for_loop_over_option, clippy::for_loop_over_result)] /// Tests for_loop_over_result and for_loop_over_option diff --git a/tests/ui/for_loop_over_option_result.stderr b/tests/ui/for_loop_over_option_result.stderr index f8a4212b253..5414bfcf9de 100644 --- a/tests/ui/for_loop_over_option_result.stderr +++ b/tests/ui/for_loop_over_option_result.stderr @@ -1,5 +1,5 @@ error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement. - --> $DIR/for_loop_over_option_result.rs:20:14 + --> $DIR/for_loop_over_option_result.rs:11:14 | LL | for x in option { | ^^^^^^ @@ -8,7 +8,7 @@ LL | for x in option { = help: consider replacing `for x in option` with `if let Some(x) = option` error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement. - --> $DIR/for_loop_over_option_result.rs:25:14 + --> $DIR/for_loop_over_option_result.rs:16:14 | LL | for x in result { | ^^^^^^ @@ -17,7 +17,7 @@ LL | for x in result { = help: consider replacing `for x in result` with `if let Ok(x) = result` error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement. - --> $DIR/for_loop_over_option_result.rs:29:14 + --> $DIR/for_loop_over_option_result.rs:20:14 | LL | for x in option.ok_or("x not found") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | for x in option.ok_or("x not found") { = help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want - --> $DIR/for_loop_over_option_result.rs:35:14 + --> $DIR/for_loop_over_option_result.rs:26:14 | LL | for x in v.iter().next() { | ^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | for x in v.iter().next() { = note: #[deny(clippy::iter_next_loop)] on by default error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement. - --> $DIR/for_loop_over_option_result.rs:40:14 + --> $DIR/for_loop_over_option_result.rs:31:14 | LL | for x in v.iter().next().and(Some(0)) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | for x in v.iter().next().and(Some(0)) { = help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))` error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement. - --> $DIR/for_loop_over_option_result.rs:44:14 + --> $DIR/for_loop_over_option_result.rs:35:14 | LL | for x in v.iter().next().ok_or("x not found") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | for x in v.iter().next().ok_or("x not found") { = help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")` error: this loop never actually loops - --> $DIR/for_loop_over_option_result.rs:56:5 + --> $DIR/for_loop_over_option_result.rs:47:5 | LL | / while let Some(x) = option { LL | | println!("{}", x); @@ -60,7 +60,7 @@ LL | | } = note: #[deny(clippy::never_loop)] on by default error: this loop never actually loops - --> $DIR/for_loop_over_option_result.rs:62:5 + --> $DIR/for_loop_over_option_result.rs:53:5 | LL | / while let Ok(x) = result { LL | | println!("{}", x); diff --git a/tests/ui/format.rs b/tests/ui/format.rs index 6b1577e24ca..f2892c5b84a 100644 --- a/tests/ui/format.rs +++ b/tests/ui/format.rs @@ -1,13 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - #![allow(clippy::print_literal)] #![warn(clippy::useless_format)] diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index 871fc8fba3e..d5f2711bb37 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -1,5 +1,5 @@ error: useless use of `format!` - --> $DIR/format.rs:21:5 + --> $DIR/format.rs:11:5 | LL | format!("foo"); | ^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` @@ -7,7 +7,7 @@ LL | format!("foo"); = note: `-D clippy::useless-format` implied by `-D warnings` error: useless use of `format!` - --> $DIR/format.rs:23:5 + --> $DIR/format.rs:13:5 | LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` @@ -15,7 +15,7 @@ LL | format!("{}", "foo"); = 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: useless use of `format!` - --> $DIR/format.rs:27:5 + --> $DIR/format.rs:17:5 | LL | format!("{:+}", "foo"); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` @@ -23,7 +23,7 @@ LL | format!("{:+}", "foo"); // warn when the format makes no difference = 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: useless use of `format!` - --> $DIR/format.rs:28:5 + --> $DIR/format.rs:18:5 | LL | format!("{:<}", "foo"); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` @@ -31,7 +31,7 @@ LL | format!("{:<}", "foo"); // warn when the format makes no difference = 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: useless use of `format!` - --> $DIR/format.rs:33:5 + --> $DIR/format.rs:23:5 | LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()` @@ -39,7 +39,7 @@ LL | format!("{}", arg); = 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: useless use of `format!` - --> $DIR/format.rs:37:5 + --> $DIR/format.rs:27:5 | LL | format!("{:+}", arg); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()` @@ -47,7 +47,7 @@ LL | format!("{:+}", arg); // warn when the format makes no difference = 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: useless use of `format!` - --> $DIR/format.rs:38:5 + --> $DIR/format.rs:28:5 | LL | format!("{:<}", arg); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()` @@ -55,7 +55,7 @@ LL | format!("{:<}", arg); // warn when the format makes no difference = 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: useless use of `format!` - --> $DIR/format.rs:65:5 + --> $DIR/format.rs:55:5 | LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `42.to_string()` @@ -63,7 +63,7 @@ LL | format!("{}", 42.to_string()); = 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: useless use of `format!` - --> $DIR/format.rs:67:5 + --> $DIR/format.rs:57:5 | LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `x.display().to_string()` diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index b74f778b129..904c05b068c 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(unused_variables)] #![allow(unused_assignments)] diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index 061540b9aa5..3d723ce71b9 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,5 +1,5 @@ error: this looks like an `else {..}` but the `else` is missing - --> $DIR/formatting.rs:21:6 + --> $DIR/formatting.rs:12:6 | LL | } { | ^ @@ -8,7 +8,7 @@ LL | } { = note: to remove this lint, add the missing `else` or add a new line before the next block error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:25:6 + --> $DIR/formatting.rs:16:6 | LL | } if foo() { | ^ @@ -16,7 +16,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:32:10 + --> $DIR/formatting.rs:23:10 | LL | } if foo() { | ^ @@ -24,7 +24,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:40:10 + --> $DIR/formatting.rs:31:10 | LL | } if foo() { | ^ @@ -32,7 +32,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this is an `else {..}` but the formatting might hide it - --> $DIR/formatting.rs:49:6 + --> $DIR/formatting.rs:40:6 | LL | } else | ______^ @@ -42,7 +42,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else {..}` but the formatting might hide it - --> $DIR/formatting.rs:54:6 + --> $DIR/formatting.rs:45:6 | LL | } | ______^ @@ -53,7 +53,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:60:6 + --> $DIR/formatting.rs:51:6 | LL | } else | ______^ @@ -63,7 +63,7 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:65:6 + --> $DIR/formatting.rs:56:6 | LL | } | ______^ @@ -74,7 +74,7 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:106:6 + --> $DIR/formatting.rs:97:6 | LL | a =- 35; | ^^^^ @@ -83,7 +83,7 @@ LL | a =- 35; = note: to remove this lint, use either `-=` or `= -` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:107:6 + --> $DIR/formatting.rs:98:6 | LL | a =* &191; | ^^^^ @@ -91,7 +91,7 @@ LL | a =* &191; = note: to remove this lint, use either `*=` or `= *` error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:110:6 + --> $DIR/formatting.rs:101:6 | LL | b =! false; | ^^^^ @@ -99,7 +99,7 @@ LL | b =! false; = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:119:19 + --> $DIR/formatting.rs:110:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -108,7 +108,7 @@ LL | -1, -2, -3 // <= no comma here = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:123:19 + --> $DIR/formatting.rs:114:19 | LL | -1, -2, -3 // <= no comma here | ^ diff --git a/tests/ui/functions.rs b/tests/ui/functions.rs index 41963294815..500576d1dff 100644 --- a/tests/ui/functions.rs +++ b/tests/ui/functions.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(dead_code)] #![allow(unused_unsafe)] diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index b23d09309bb..150b50d9a7c 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -1,5 +1,5 @@ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:17:1 + --> $DIR/functions.rs:8:1 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,19 +7,19 @@ LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f = note: `-D clippy::too-many-arguments` implied by `-D warnings` error: this function has too many arguments (8/7) - --> $DIR/functions.rs:34:5 + --> $DIR/functions.rs:25:5 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:43:5 + --> $DIR/functions.rs:34:5 | LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:52:34 + --> $DIR/functions.rs:43:34 | LL | println!("{}", unsafe { *p }); | ^ @@ -27,49 +27,49 @@ LL | println!("{}", unsafe { *p }); = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:53:35 + --> $DIR/functions.rs:44:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:54:33 + --> $DIR/functions.rs:45:33 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:65:30 + --> $DIR/functions.rs:56:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:66:31 + --> $DIR/functions.rs:57:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:67:29 + --> $DIR/functions.rs:58:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:76:34 + --> $DIR/functions.rs:67:34 | LL | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:77:35 + --> $DIR/functions.rs:68:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:78:33 + --> $DIR/functions.rs:69:33 | LL | unsafe { std::ptr::read(p) }; | ^ diff --git a/tests/ui/fxhash.rs b/tests/ui/fxhash.rs index 2299714132f..7d6cb4e1179 100644 --- a/tests/ui/fxhash.rs +++ b/tests/ui/fxhash.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::default_hash_types)] #![feature(rustc_private)] diff --git a/tests/ui/fxhash.stderr b/tests/ui/fxhash.stderr index 14fc4a8090b..a2dac670018 100644 --- a/tests/ui/fxhash.stderr +++ b/tests/ui/fxhash.stderr @@ -1,5 +1,5 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:16:24 + --> $DIR/fxhash.rs:7:24 | LL | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashMap` @@ -7,31 +7,31 @@ LL | use std::collections::{HashMap, HashSet}; = note: `-D clippy::default-hash-types` implied by `-D warnings` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:16:33 + --> $DIR/fxhash.rs:7:33 | LL | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:19:15 + --> $DIR/fxhash.rs:10:15 | LL | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:19:41 + --> $DIR/fxhash.rs:10:41 | LL | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:20:15 + --> $DIR/fxhash.rs:11:15 | LL | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:20:33 + --> $DIR/fxhash.rs:11:33 | LL | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` diff --git a/tests/ui/get_unwrap.fixed b/tests/ui/get_unwrap.fixed index 021c0c2ff44..f9d52286355 100644 --- a/tests/ui/get_unwrap.fixed +++ b/tests/ui/get_unwrap.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![allow(unused_mut)] diff --git a/tests/ui/get_unwrap.rs b/tests/ui/get_unwrap.rs index b041ba7b7c7..244a2ef25a1 100644 --- a/tests/ui/get_unwrap.rs +++ b/tests/ui/get_unwrap.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![allow(unused_mut)] diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index d4f699f5a72..dd3a5c68e0a 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -1,5 +1,5 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:42:17 + --> $DIR/get_unwrap.rs:33:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]` @@ -7,73 +7,73 @@ LL | let _ = boxed_slice.get(1).unwrap(); = note: `-D clippy::get-unwrap` implied by `-D warnings` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:43:17 + --> $DIR/get_unwrap.rs:34:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:44:17 + --> $DIR/get_unwrap.rs:35:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]` error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:45:17 + --> $DIR/get_unwrap.rs:36:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]` error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:46:17 + --> $DIR/get_unwrap.rs:37:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]` error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:47:17 + --> $DIR/get_unwrap.rs:38:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:50:21 + --> $DIR/get_unwrap.rs:41:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:55:9 + --> $DIR/get_unwrap.rs:46:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:56:9 + --> $DIR/get_unwrap.rs:47:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:57:9 + --> $DIR/get_unwrap.rs:48:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]` error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:58:9 + --> $DIR/get_unwrap.rs:49:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:67:17 + --> $DIR/get_unwrap.rs:58:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:68:17 + --> $DIR/get_unwrap.rs:59:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` diff --git a/tests/ui/ice-2636.rs b/tests/ui/ice-2636.rs index caf8c89390d..e0b58157590 100644 --- a/tests/ui/ice-2636.rs +++ b/tests/ui/ice-2636.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] enum Foo { diff --git a/tests/ui/ice-2636.stderr b/tests/ui/ice-2636.stderr index a6b150f9b90..aba8be4adcc 100644 --- a/tests/ui/ice-2636.stderr +++ b/tests/ui/ice-2636.stderr @@ -1,5 +1,5 @@ error: you don't need to add `&` to both the expression and the patterns - --> $DIR/ice-2636.rs:21:9 + --> $DIR/ice-2636.rs:12:9 | LL | / match $foo { LL | | $ ( & $t => $ord, diff --git a/tests/ui/identity_conversion.rs b/tests/ui/identity_conversion.rs index 6ba191b0b84..6491518af6c 100644 --- a/tests/ui/identity_conversion.rs +++ b/tests/ui/identity_conversion.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::identity_conversion)] fn test_generic(val: T) -> T { diff --git a/tests/ui/identity_conversion.stderr b/tests/ui/identity_conversion.stderr index 4b0b958e285..73a1996180b 100644 --- a/tests/ui/identity_conversion.stderr +++ b/tests/ui/identity_conversion.stderr @@ -1,65 +1,65 @@ error: identical conversion - --> $DIR/identity_conversion.rs:13:13 + --> $DIR/identity_conversion.rs:4:13 | LL | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: lint level defined here - --> $DIR/identity_conversion.rs:10:9 + --> $DIR/identity_conversion.rs:1:9 | LL | #![deny(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identical conversion - --> $DIR/identity_conversion.rs:14:5 + --> $DIR/identity_conversion.rs:5:5 | LL | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: identical conversion - --> $DIR/identity_conversion.rs:26:22 + --> $DIR/identity_conversion.rs:17:22 | LL | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: identical conversion - --> $DIR/identity_conversion.rs:47:21 + --> $DIR/identity_conversion.rs:38:21 | LL | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:48:21 + --> $DIR/identity_conversion.rs:39:21 | LL | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:49:13 + --> $DIR/identity_conversion.rs:40:13 | LL | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:50:13 + --> $DIR/identity_conversion.rs:41:13 | LL | let _ = String::from(format!("A: {:04}", 123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` error: identical conversion - --> $DIR/identity_conversion.rs:51:13 + --> $DIR/identity_conversion.rs:42:13 | LL | let _ = "".lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` error: identical conversion - --> $DIR/identity_conversion.rs:52:13 + --> $DIR/identity_conversion.rs:43:13 | LL | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` error: identical conversion - --> $DIR/identity_conversion.rs:53:21 + --> $DIR/identity_conversion.rs:44:21 | LL | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index 299cd2a6786..ae2815d345a 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - const ONE: i64 = 1; const NEG_ONE: i64 = -1; const ZERO: i64 = 0; diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 8b42cfbf1ce..4742877706a 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,5 +1,5 @@ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:25:5 + --> $DIR/identity_op.rs:16:5 | LL | x + 0; | ^^^^^ @@ -7,43 +7,43 @@ LL | x + 0; = note: `-D clippy::identity-op` implied by `-D warnings` error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:26:5 + --> $DIR/identity_op.rs:17:5 | LL | x + (1 - 1); | ^^^^^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:28:5 + --> $DIR/identity_op.rs:19:5 | LL | 0 + x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:31:5 + --> $DIR/identity_op.rs:22:5 | LL | x | (0); | ^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:34:5 + --> $DIR/identity_op.rs:25:5 | LL | x * 1; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:35:5 + --> $DIR/identity_op.rs:26:5 | LL | 1 * x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:41:5 + --> $DIR/identity_op.rs:32:5 | LL | -1 & x; | ^^^^^^ error: the operation is ineffective. Consider reducing it to `u` - --> $DIR/identity_op.rs:44:5 + --> $DIR/identity_op.rs:35:5 | LL | u & 255; | ^^^^^^^ diff --git a/tests/ui/if_not_else.rs b/tests/ui/if_not_else.rs index 0179381fdc3..dc3fb1ceac9 100644 --- a/tests/ui/if_not_else.rs +++ b/tests/ui/if_not_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![warn(clippy::if_not_else)] diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index acdf543cc75..3694f5aec53 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,5 +1,5 @@ error: Unnecessary boolean `not` operation - --> $DIR/if_not_else.rs:18:5 + --> $DIR/if_not_else.rs:9:5 | LL | / if !bla() { LL | | println!("Bugs"); @@ -12,7 +12,7 @@ LL | | } = help: remove the `!` and swap the blocks of the if/else error: Unnecessary `!=` operation - --> $DIR/if_not_else.rs:23:5 + --> $DIR/if_not_else.rs:14:5 | LL | / if 4 != 5 { LL | | println!("Bugs"); diff --git a/tests/ui/impl.rs b/tests/ui/impl.rs index 398a8ccce44..1c46e3a5337 100644 --- a/tests/ui/impl.rs +++ b/tests/ui/impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] #![warn(clippy::multiple_inherent_impl)] diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index 8bddd400f70..585d32845d2 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,5 +1,5 @@ error: Multiple implementations of this structure - --> $DIR/impl.rs:19:1 + --> $DIR/impl.rs:10:1 | LL | / impl MyStruct { LL | | fn second() {} @@ -8,7 +8,7 @@ LL | | } | = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` note: First implementation here - --> $DIR/impl.rs:15:1 + --> $DIR/impl.rs:6:1 | LL | / impl MyStruct { LL | | fn first() {} @@ -16,7 +16,7 @@ LL | | } | |_^ error: Multiple implementations of this structure - --> $DIR/impl.rs:33:5 + --> $DIR/impl.rs:24:5 | LL | / impl super::MyStruct { LL | | fn third() {} @@ -24,7 +24,7 @@ LL | | } | |_____^ | note: First implementation here - --> $DIR/impl.rs:15:1 + --> $DIR/impl.rs:6:1 | LL | / impl MyStruct { LL | | fn first() {} diff --git a/tests/ui/implicit_hasher.rs b/tests/ui/implicit_hasher.rs index acd5a52ff38..064760e73f3 100644 --- a/tests/ui/implicit_hasher.rs +++ b/tests/ui/implicit_hasher.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] use std::cmp::Eq; diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index 0c61dbc4c64..68e305f0cb4 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -1,5 +1,5 @@ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:20:35 + --> $DIR/implicit_hasher.rs:11:35 | LL | impl Foo for HashMap { | ^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default: | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:29:36 + --> $DIR/implicit_hasher.rs:20:36 | LL | impl Foo for (HashMap,) { | ^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Defa | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:34:19 + --> $DIR/implicit_hasher.rs:25:19 | LL | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default: | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:51:32 + --> $DIR/implicit_hasher.rs:42:32 | LL | impl Foo for HashSet { | ^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default: | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:56:19 + --> $DIR/implicit_hasher.rs:47:19 | LL | impl Foo for HashSet { | ^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default: | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:73:23 + --> $DIR/implicit_hasher.rs:64:23 | LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | pub fn foo(_map: &mut HashMap, _s | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:73:53 + --> $DIR/implicit_hasher.rs:64:53 | LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | pub fn foo(_map: &mut HashMap, _set: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:77:43 + --> $DIR/implicit_hasher.rs:68:43 | LL | impl Foo for HashMap { | ^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:85:33 + --> $DIR/implicit_hasher.rs:76:33 | LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | pub fn $name(_map: &mut HashMap $DIR/implicit_hasher.rs:85:63 + --> $DIR/implicit_hasher.rs:76:63 | LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^ diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs index 46ead9bf0c5..d1c63ca1697 100644 --- a/tests/ui/implicit_return.rs +++ b/tests/ui/implicit_return.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::implicit_return)] fn test_end_of_fn() -> bool { @@ -35,6 +26,14 @@ fn test_match(x: bool) -> bool { } } +#[allow(clippy::match_bool, clippy::needless_return)] +fn test_match_with_unreachable(x: bool) -> bool { + match x { + true => return false, + false => unreachable!(), + } +} + #[allow(clippy::never_loop)] fn test_loop() -> bool { loop { @@ -62,6 +61,15 @@ fn test_loop_with_nests() -> bool { } } +#[allow(clippy::redundant_pattern_matching)] +fn test_loop_with_if_let() -> bool { + loop { + if let Some(x) = Some(true) { + return x; + } + } +} + fn test_closure() { #[rustfmt::skip] let _ = || { true }; @@ -72,8 +80,10 @@ fn main() { let _ = test_end_of_fn(); let _ = test_if_block(); let _ = test_match(true); + let _ = test_match_with_unreachable(true); let _ = test_loop(); let _ = test_loop_with_block(); let _ = test_loop_with_nests(); + let _ = test_loop_with_if_let(); test_closure(); } diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index 4c62a7d65c6..98b588f1a74 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -1,5 +1,5 @@ error: missing return statement - --> $DIR/implicit_return.rs:17:5 + --> $DIR/implicit_return.rs:8:5 | LL | true | ^^^^ help: add `return` as shown: `return true` @@ -7,55 +7,55 @@ LL | true = note: `-D clippy::implicit-return` implied by `-D warnings` error: missing return statement - --> $DIR/implicit_return.rs:23:9 + --> $DIR/implicit_return.rs:14:9 | LL | true | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:25:9 + --> $DIR/implicit_return.rs:16:9 | LL | false | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:33:17 + --> $DIR/implicit_return.rs:24:17 | LL | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:34:20 + --> $DIR/implicit_return.rs:25:20 | LL | false => { true }, | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:41:9 + --> $DIR/implicit_return.rs:40:9 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:49:13 + --> $DIR/implicit_return.rs:48:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:58:13 + --> $DIR/implicit_return.rs:57:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:67:18 + --> $DIR/implicit_return.rs:75:18 | LL | let _ = || { true }; | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:68:16 + --> $DIR/implicit_return.rs:76:16 | LL | let _ = || true; | ^^^^ help: add `return` as shown: `return true` diff --git a/tests/ui/inconsistent_digit_grouping.fixed b/tests/ui/inconsistent_digit_grouping.fixed new file mode 100644 index 00000000000..f25be70737b --- /dev/null +++ b/tests/ui/inconsistent_digit_grouping.fixed @@ -0,0 +1,15 @@ +// run-rustfix +#[warn(clippy::inconsistent_digit_grouping)] +#[allow(unused_variables, clippy::excessive_precision)] +fn main() { + let good = ( + 123, + 1_234, + 1_2345_6789, + 123_f32, + 1_234.12_f32, + 1_234.123_4_f32, + 1.123_456_7_f32, + ); + let bad = (123_456, 12_345_678, 1_234_567, 1_234.567_8_f32, 1.234_567_8_f32); +} diff --git a/tests/ui/inconsistent_digit_grouping.rs b/tests/ui/inconsistent_digit_grouping.rs index 31e34135bfc..206fac8d3e3 100644 --- a/tests/ui/inconsistent_digit_grouping.rs +++ b/tests/ui/inconsistent_digit_grouping.rs @@ -1,14 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #[warn(clippy::inconsistent_digit_grouping)] -#[allow(unused_variables)] +#[allow(unused_variables, clippy::excessive_precision)] fn main() { let good = ( 123, diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index ba909b94480..9fc1f424dc6 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -1,5 +1,5 @@ error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:22:16 + --> $DIR/inconsistent_digit_grouping.rs:14:16 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` @@ -7,25 +7,25 @@ LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:22:26 + --> $DIR/inconsistent_digit_grouping.rs:14:26 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^ help: consider: `12_345_678` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:22:38 + --> $DIR/inconsistent_digit_grouping.rs:14:38 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `1_234_567` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:22:48 + --> $DIR/inconsistent_digit_grouping.rs:14:48 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:22:64 + --> $DIR/inconsistent_digit_grouping.rs:14:64 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32` diff --git a/tests/ui/indexing_slicing.rs b/tests/ui/indexing_slicing.rs index a9e697e519f..f0bd39c0254 100644 --- a/tests/ui/indexing_slicing.rs +++ b/tests/ui/indexing_slicing.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(plugin)] #![warn(clippy::indexing_slicing)] #![warn(clippy::out_of_bounds_indexing)] diff --git a/tests/ui/indexing_slicing.stderr b/tests/ui/indexing_slicing.stderr index 2e7bff3e0d5..129fec0e97c 100644 --- a/tests/ui/indexing_slicing.stderr +++ b/tests/ui/indexing_slicing.stderr @@ -1,5 +1,5 @@ error: index out of bounds: the len is 4 but the index is 4 - --> $DIR/indexing_slicing.rs:25:5 + --> $DIR/indexing_slicing.rs:16:5 | LL | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ @@ -7,25 +7,25 @@ LL | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on ar = note: #[deny(const_err)] on by default error: index out of bounds: the len is 4 but the index is 8 - --> $DIR/indexing_slicing.rs:26:5 + --> $DIR/indexing_slicing.rs:17:5 | LL | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^^^^^^ error: index out of bounds: the len is 0 but the index is 0 - --> $DIR/indexing_slicing.rs:56:5 + --> $DIR/indexing_slicing.rs:47:5 | LL | empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^^^^^ error: index out of bounds: the len is 4 but the index is 15 - --> $DIR/indexing_slicing.rs:87:5 + --> $DIR/indexing_slicing.rs:78:5 | LL | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:20:5 + --> $DIR/indexing_slicing.rs:11:5 | LL | x[index]; | ^^^^^^^^ @@ -34,7 +34,7 @@ LL | x[index]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:21:6 + --> $DIR/indexing_slicing.rs:12:6 | LL | &x[index..]; | ^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | &x[index..]; = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:22:6 + --> $DIR/indexing_slicing.rs:13:6 | LL | &x[..index]; | ^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | &x[..index]; = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:23:6 + --> $DIR/indexing_slicing.rs:14:6 | LL | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL | &x[index_from..index_to]; = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:24:6 + --> $DIR/indexing_slicing.rs:15:6 | LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from. = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:24:6 + --> $DIR/indexing_slicing.rs:15:6 | LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from. = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:27:11 + --> $DIR/indexing_slicing.rs:18:11 | LL | &x[..=4]; | ^ @@ -82,13 +82,13 @@ LL | &x[..=4]; = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` error: range is out of bounds - --> $DIR/indexing_slicing.rs:28:11 + --> $DIR/indexing_slicing.rs:19:11 | LL | &x[1..5]; | ^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:29:6 + --> $DIR/indexing_slicing.rs:20:6 | LL | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^^^^^^^^^^^^ @@ -96,37 +96,37 @@ LL | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10 = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:29:8 + --> $DIR/indexing_slicing.rs:20:8 | LL | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:30:8 + --> $DIR/indexing_slicing.rs:21:8 | LL | &x[5..]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:31:10 + --> $DIR/indexing_slicing.rs:22:10 | LL | &x[..5]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:32:8 + --> $DIR/indexing_slicing.rs:23:8 | LL | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:33:12 + --> $DIR/indexing_slicing.rs:24:12 | LL | &x[0..=4]; | ^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:34:6 + --> $DIR/indexing_slicing.rs:25:6 | LL | &x[0..][..3]; | ^^^^^^^^^^^ @@ -134,7 +134,7 @@ LL | &x[0..][..3]; = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:35:6 + --> $DIR/indexing_slicing.rs:26:6 | LL | &x[1..][..5]; | ^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | &x[1..][..5]; = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:48:5 + --> $DIR/indexing_slicing.rs:39:5 | LL | y[0]; | ^^^^ @@ -150,7 +150,7 @@ LL | y[0]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:49:6 + --> $DIR/indexing_slicing.rs:40:6 | LL | &y[1..2]; | ^^^^^^^ @@ -158,7 +158,7 @@ LL | &y[1..2]; = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:50:6 + --> $DIR/indexing_slicing.rs:41:6 | LL | &y[0..=4]; | ^^^^^^^^ @@ -166,7 +166,7 @@ LL | &y[0..=4]; = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:51:6 + --> $DIR/indexing_slicing.rs:42:6 | LL | &y[..=4]; | ^^^^^^^ @@ -174,49 +174,49 @@ LL | &y[..=4]; = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:57:12 + --> $DIR/indexing_slicing.rs:48:12 | LL | &empty[1..5]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:58:16 + --> $DIR/indexing_slicing.rs:49:16 | LL | &empty[0..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:59:15 + --> $DIR/indexing_slicing.rs:50:15 | LL | &empty[..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:60:12 + --> $DIR/indexing_slicing.rs:51:12 | LL | &empty[1..]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:61:14 + --> $DIR/indexing_slicing.rs:52:14 | LL | &empty[..4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:62:16 + --> $DIR/indexing_slicing.rs:53:16 | LL | &empty[0..=0]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:63:15 + --> $DIR/indexing_slicing.rs:54:15 | LL | &empty[..=0]; | ^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:71:5 + --> $DIR/indexing_slicing.rs:62:5 | LL | v[0]; | ^^^^ @@ -224,7 +224,7 @@ LL | v[0]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:72:5 + --> $DIR/indexing_slicing.rs:63:5 | LL | v[10]; | ^^^^^ @@ -232,7 +232,7 @@ LL | v[10]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:73:5 + --> $DIR/indexing_slicing.rs:64:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -240,7 +240,7 @@ LL | v[1 << 3]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:74:6 + --> $DIR/indexing_slicing.rs:65:6 | LL | &v[10..100]; | ^^^^^^^^^^ @@ -248,7 +248,7 @@ LL | &v[10..100]; = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:75:6 + --> $DIR/indexing_slicing.rs:66:6 | LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^^^^^^^^^^^^^ @@ -256,13 +256,13 @@ LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [. = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:75:8 + --> $DIR/indexing_slicing.rs:66:8 | LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:76:6 + --> $DIR/indexing_slicing.rs:67:6 | LL | &v[10..]; | ^^^^^^^ @@ -270,7 +270,7 @@ LL | &v[10..]; = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:77:6 + --> $DIR/indexing_slicing.rs:68:6 | LL | &v[..100]; | ^^^^^^^^ @@ -278,7 +278,7 @@ LL | &v[..100]; = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:89:5 + --> $DIR/indexing_slicing.rs:80:5 | LL | v[N]; | ^^^^ @@ -286,7 +286,7 @@ LL | v[N]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:90:5 + --> $DIR/indexing_slicing.rs:81:5 | LL | v[M]; | ^^^^ @@ -294,13 +294,13 @@ LL | v[M]; = help: Consider using `.get(n)` or `.get_mut(n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:94:13 + --> $DIR/indexing_slicing.rs:85:13 | LL | &x[num..10]; // should trigger out of bounds error | ^^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:95:8 + --> $DIR/indexing_slicing.rs:86:8 | LL | &x[10..num]; // should trigger out of bounds error | ^^ diff --git a/tests/ui/infallible_destructuring_match.fixed b/tests/ui/infallible_destructuring_match.fixed new file mode 100644 index 00000000000..f16f0fd0019 --- /dev/null +++ b/tests/ui/infallible_destructuring_match.fixed @@ -0,0 +1,79 @@ +// run-rustfix +#![feature(exhaustive_patterns, never_type)] +#![allow(dead_code, unreachable_code, unused_variables)] +#![allow(clippy::let_and_return)] + +enum SingleVariantEnum { + Variant(i32), +} + +struct TupleStruct(i32); + +enum EmptyEnum {} + +fn infallible_destructuring_match_enum() { + let wrapper = SingleVariantEnum::Variant(0); + + // This should lint! + let SingleVariantEnum::Variant(data) = wrapper; + + // This shouldn't! + let data = match wrapper { + SingleVariantEnum::Variant(_) => -1, + }; + + // Neither should this! + let data = match wrapper { + SingleVariantEnum::Variant(i) => -1, + }; + + let SingleVariantEnum::Variant(data) = wrapper; +} + +fn infallible_destructuring_match_struct() { + let wrapper = TupleStruct(0); + + // This should lint! + let TupleStruct(data) = wrapper; + + // This shouldn't! + let data = match wrapper { + TupleStruct(_) => -1, + }; + + // Neither should this! + let data = match wrapper { + TupleStruct(i) => -1, + }; + + let TupleStruct(data) = wrapper; +} + +fn never_enum() { + let wrapper: Result = Ok(23); + + // This should lint! + let Ok(data) = wrapper; + + // This shouldn't! + let data = match wrapper { + Ok(_) => -1, + }; + + // Neither should this! + let data = match wrapper { + Ok(i) => -1, + }; + + let Ok(data) = wrapper; +} + +impl EmptyEnum { + fn match_on(&self) -> ! { + // The lint shouldn't pick this up, as `let` won't work here! + let data = match *self {}; + data + } +} + +fn main() {} diff --git a/tests/ui/infallible_destructuring_match.rs b/tests/ui/infallible_destructuring_match.rs index 37ae19497d1..a4823ad60ad 100644 --- a/tests/ui/infallible_destructuring_match.rs +++ b/tests/ui/infallible_destructuring_match.rs @@ -1,13 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![feature(exhaustive_patterns, never_type)] +#![allow(dead_code, unreachable_code, unused_variables)] #![allow(clippy::let_and_return)] enum SingleVariantEnum { diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index 976957d35d7..e3693d44e9a 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:25:5 + --> $DIR/infallible_destructuring_match.rs:18:5 | LL | / let data = match wrapper { LL | | SingleVariantEnum::Variant(i) => i, @@ -9,7 +9,7 @@ LL | | }; = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:46:5 + --> $DIR/infallible_destructuring_match.rs:39:5 | LL | / let data = match wrapper { LL | | TupleStruct(i) => i, @@ -17,7 +17,7 @@ LL | | }; | |______^ help: try this: `let TupleStruct(data) = wrapper;` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:67:5 + --> $DIR/infallible_destructuring_match.rs:60:5 | LL | / let data = match wrapper { LL | | Ok(i) => i, diff --git a/tests/ui/infinite_iter.rs b/tests/ui/infinite_iter.rs index bd266368dc4..c324eb95777 100644 --- a/tests/ui/infinite_iter.rs +++ b/tests/ui/infinite_iter.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::iter::repeat; #[allow(clippy::trivially_copy_pass_by_ref)] fn square_is_lower_64(x: &u32) -> bool { diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index 288285d9aae..564c2b43778 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -1,5 +1,5 @@ error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/infinite_iter.rs:19:5 + --> $DIR/infinite_iter.rs:10:5 | LL | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,31 +7,31 @@ LL | repeat(0_u8).collect::>(); // infinite iter = note: `-D clippy::unused-collect` implied by `-D warnings` error: infinite iteration detected - --> $DIR/infinite_iter.rs:19:5 + --> $DIR/infinite_iter.rs:10:5 | LL | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/infinite_iter.rs:17:8 + --> $DIR/infinite_iter.rs:8:8 | LL | #[deny(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:20:5 + --> $DIR/infinite_iter.rs:11:5 | LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:21:5 + --> $DIR/infinite_iter.rs:12:5 | LL | (0..8_u64).chain(0..).max(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:26:5 + --> $DIR/infinite_iter.rs:17:5 | LL | / (0..8_u32) LL | | .rev() @@ -41,37 +41,37 @@ LL | | .for_each(|x| println!("{}", x)); // infinite iter | |________________________________________^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:32:5 + --> $DIR/infinite_iter.rs:23:5 | LL | (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:33:5 + --> $DIR/infinite_iter.rs:24:5 | LL | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:40:5 + --> $DIR/infinite_iter.rs:31:5 | LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/infinite_iter.rs:38:8 + --> $DIR/infinite_iter.rs:29:8 | LL | #[deny(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:41:5 + --> $DIR/infinite_iter.rs:32:5 | LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:42:5 + --> $DIR/infinite_iter.rs:33:5 | LL | / (1..) LL | | .scan(0, |state, x| { @@ -82,31 +82,31 @@ LL | | .min(); // maybe infinite iter | |______________^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:48:5 + --> $DIR/infinite_iter.rs:39:5 | LL | (0..).find(|x| *x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:49:5 + --> $DIR/infinite_iter.rs:40:5 | LL | (0..).position(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:50:5 + --> $DIR/infinite_iter.rs:41:5 | LL | (0..).any(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:51:5 + --> $DIR/infinite_iter.rs:42:5 | LL | (0..).all(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:74:31 + --> $DIR/infinite_iter.rs:65:31 | LL | let _: HashSet = (0..).collect(); // Infinite iter | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs index f9310321593..4df218aa4f3 100644 --- a/tests/ui/infinite_loop.rs +++ b/tests/ui/infinite_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::trivially_copy_pass_by_ref)] fn fn_val(i: i32) -> i32 { diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index 79efb18a83e..a3fc591c1b1 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,5 +1,5 @@ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:32:11 + --> $DIR/infinite_loop.rs:23:11 | LL | while y < 10 { | ^^^^^^ @@ -7,17 +7,29 @@ LL | while y < 10 { = note: #[deny(clippy::while_immutable_condition)] on by default error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:37:11 + --> $DIR/infinite_loop.rs:28:11 | LL | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:44:11 + --> $DIR/infinite_loop.rs:35:11 | LL | while !cond { | ^^^^^ +error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. + --> $DIR/infinite_loop.rs:79:11 + | +LL | while i < 3 { + | ^^^^^ + +error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. + --> $DIR/infinite_loop.rs:84:11 + | +LL | while i < 3 && j > 0 { + | ^^^^^^^^^^^^^^ + error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. --> $DIR/infinite_loop.rs:88:11 | @@ -25,31 +37,19 @@ LL | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:93:11 - | -LL | while i < 3 && j > 0 { - | ^^^^^^^^^^^^^^ - -error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:97:11 + --> $DIR/infinite_loop.rs:103:11 | LL | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:112:11 + --> $DIR/infinite_loop.rs:108:11 | LL | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:117:11 - | -LL | while i < 3 { - | ^^^^^ - -error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:183:15 + --> $DIR/infinite_loop.rs:174:15 | LL | while self.count < n { | ^^^^^^^^^^^^^^ diff --git a/tests/ui/inline_fn_without_body.rs b/tests/ui/inline_fn_without_body.rs index d97e6d69941..af81feaa374 100644 --- a/tests/ui/inline_fn_without_body.rs +++ b/tests/ui/inline_fn_without_body.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::inline_fn_without_body)] #![allow(clippy::inline_always)] diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 3c2b086968e..87d2da71280 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -1,5 +1,5 @@ error: use of `#[inline]` on trait method `default_inline` which has no body - --> $DIR/inline_fn_without_body.rs:14:5 + --> $DIR/inline_fn_without_body.rs:5:5 | LL | #[inline] | _____-^^^^^^^^ @@ -9,7 +9,7 @@ LL | | fn default_inline(); = note: `-D clippy::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:17:5 + --> $DIR/inline_fn_without_body.rs:8:5 | LL | #[inline(always)] | _____-^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | | fn always_inline(); | |____- help: remove error: use of `#[inline]` on trait method `never_inline` which has no body - --> $DIR/inline_fn_without_body.rs:20:5 + --> $DIR/inline_fn_without_body.rs:11:5 | LL | #[inline(never)] | _____-^^^^^^^^^^^^^^^ diff --git a/tests/ui/int_plus_one.rs b/tests/ui/int_plus_one.rs index ce6cd7888ee..42d8045244f 100644 --- a/tests/ui/int_plus_one.rs +++ b/tests/ui/int_plus_one.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(clippy::no_effect, clippy::unnecessary_operation)] #[warn(clippy::int_plus_one)] fn main() { diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 30bc2966619..4a783e50c67 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,5 +1,5 @@ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:16:5 + --> $DIR/int_plus_one.rs:7:5 | LL | x >= y + 1; | ^^^^^^^^^^ @@ -11,7 +11,7 @@ LL | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:17:5 + --> $DIR/int_plus_one.rs:8:5 | LL | y + 1 <= x; | ^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | y < x; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:19:5 + --> $DIR/int_plus_one.rs:10:5 | LL | x - 1 >= y; | ^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:20:5 + --> $DIR/int_plus_one.rs:11:5 | LL | y <= x - 1; | ^^^^^^^^^^ diff --git a/tests/ui/into_iter_on_ref.fixed b/tests/ui/into_iter_on_ref.fixed new file mode 100644 index 00000000000..f5342be631b --- /dev/null +++ b/tests/ui/into_iter_on_ref.fixed @@ -0,0 +1,46 @@ +// run-rustfix +#![allow(clippy::useless_vec)] +#![warn(clippy::into_iter_on_ref)] +#![deny(clippy::into_iter_on_array)] + +struct X; +use std::collections::*; + +fn main() { + for _ in &[1, 2, 3] {} + for _ in vec![X, X] {} + for _ in &vec![X, X] {} + for _ in [1, 2, 3].iter() {} //~ ERROR equivalent to .iter() + + let _ = [1, 2, 3].iter(); //~ ERROR equivalent to .iter() + let _ = vec![1, 2, 3].into_iter(); + let _ = (&vec![1, 2, 3]).iter(); //~ WARN equivalent to .iter() + let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ WARN equivalent to .iter() + let _ = std::rc::Rc::from(&[X][..]).iter(); //~ WARN equivalent to .iter() + let _ = std::sync::Arc::from(&[X][..]).iter(); //~ WARN equivalent to .iter() + + let _ = (&&&&&&&[1, 2, 3]).iter(); //~ ERROR equivalent to .iter() + let _ = (&&&&mut &&&[1, 2, 3]).iter(); //~ ERROR equivalent to .iter() + let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); //~ ERROR equivalent to .iter_mut() + + let _ = (&Some(4)).iter(); //~ WARN equivalent to .iter() + let _ = (&mut Some(5)).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&Ok::<_, i32>(6)).iter(); //~ WARN equivalent to .iter() + let _ = (&mut Err::(7)).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&Vec::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&mut Vec::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&BTreeMap::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&mut BTreeMap::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&VecDeque::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&mut VecDeque::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&LinkedList::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&mut LinkedList::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&HashMap::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&mut HashMap::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() + + let _ = (&BTreeSet::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&BinaryHeap::::new()).iter(); //~ WARN equivalent to .iter() + let _ = (&HashSet::::new()).iter(); //~ WARN equivalent to .iter() + let _ = std::path::Path::new("12/34").iter(); //~ WARN equivalent to .iter() + let _ = std::path::PathBuf::from("12/34").iter(); //~ ERROR equivalent to .iter() +} diff --git a/tests/ui/into_iter_on_ref.rs b/tests/ui/into_iter_on_ref.rs index 212234f0346..5ec64dcf733 100644 --- a/tests/ui/into_iter_on_ref.rs +++ b/tests/ui/into_iter_on_ref.rs @@ -1,3 +1,5 @@ +// run-rustfix +#![allow(clippy::useless_vec)] #![warn(clippy::into_iter_on_ref)] #![deny(clippy::into_iter_on_array)] diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index e7f2a21d7a4..931e4880f93 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,23 +1,23 @@ error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:11:24 + --> $DIR/into_iter_on_ref.rs:13:24 | LL | for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` | note: lint level defined here - --> $DIR/into_iter_on_ref.rs:2:9 + --> $DIR/into_iter_on_ref.rs:4:9 | LL | #![deny(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:13:23 + --> $DIR/into_iter_on_ref.rs:15:23 | LL | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the Vec - --> $DIR/into_iter_on_ref.rs:15:30 + --> $DIR/into_iter_on_ref.rs:17:30 | LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` @@ -25,151 +25,151 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` error: this .into_iter() call is equivalent to .iter() and will not move the slice - --> $DIR/into_iter_on_ref.rs:16:46 + --> $DIR/into_iter_on_ref.rs:18:46 | LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the slice - --> $DIR/into_iter_on_ref.rs:17:41 + --> $DIR/into_iter_on_ref.rs:19:41 | LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the slice - --> $DIR/into_iter_on_ref.rs:18:44 + --> $DIR/into_iter_on_ref.rs:20:44 | LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:20:32 + --> $DIR/into_iter_on_ref.rs:22:32 | LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:21:36 + --> $DIR/into_iter_on_ref.rs:23:36 | LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the array - --> $DIR/into_iter_on_ref.rs:22:40 + --> $DIR/into_iter_on_ref.rs:24:40 | LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Option - --> $DIR/into_iter_on_ref.rs:24:24 + --> $DIR/into_iter_on_ref.rs:26:24 | LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the Option - --> $DIR/into_iter_on_ref.rs:25:28 + --> $DIR/into_iter_on_ref.rs:27:28 | LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Result - --> $DIR/into_iter_on_ref.rs:26:32 + --> $DIR/into_iter_on_ref.rs:28:32 | LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the Result - --> $DIR/into_iter_on_ref.rs:27:37 + --> $DIR/into_iter_on_ref.rs:29:37 | LL | let _ = (&mut Err::(7)).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Vec - --> $DIR/into_iter_on_ref.rs:28:34 + --> $DIR/into_iter_on_ref.rs:30:34 | LL | let _ = (&Vec::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the Vec - --> $DIR/into_iter_on_ref.rs:29:38 + --> $DIR/into_iter_on_ref.rs:31:38 | LL | let _ = (&mut Vec::::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the BTreeMap - --> $DIR/into_iter_on_ref.rs:30:44 + --> $DIR/into_iter_on_ref.rs:32:44 | LL | let _ = (&BTreeMap::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the BTreeMap - --> $DIR/into_iter_on_ref.rs:31:48 + --> $DIR/into_iter_on_ref.rs:33:48 | LL | let _ = (&mut BTreeMap::::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the VecDeque - --> $DIR/into_iter_on_ref.rs:32:39 + --> $DIR/into_iter_on_ref.rs:34:39 | LL | let _ = (&VecDeque::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the VecDeque - --> $DIR/into_iter_on_ref.rs:33:43 + --> $DIR/into_iter_on_ref.rs:35:43 | LL | let _ = (&mut VecDeque::::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the LinkedList - --> $DIR/into_iter_on_ref.rs:34:41 + --> $DIR/into_iter_on_ref.rs:36:41 | LL | let _ = (&LinkedList::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the LinkedList - --> $DIR/into_iter_on_ref.rs:35:45 + --> $DIR/into_iter_on_ref.rs:37:45 | LL | let _ = (&mut LinkedList::::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the HashMap - --> $DIR/into_iter_on_ref.rs:36:43 + --> $DIR/into_iter_on_ref.rs:38:43 | LL | let _ = (&HashMap::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the HashMap - --> $DIR/into_iter_on_ref.rs:37:47 + --> $DIR/into_iter_on_ref.rs:39:47 | LL | let _ = (&mut HashMap::::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the BTreeSet - --> $DIR/into_iter_on_ref.rs:39:39 + --> $DIR/into_iter_on_ref.rs:41:39 | LL | let _ = (&BTreeSet::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the BinaryHeap - --> $DIR/into_iter_on_ref.rs:40:41 + --> $DIR/into_iter_on_ref.rs:42:41 | LL | let _ = (&BinaryHeap::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the HashSet - --> $DIR/into_iter_on_ref.rs:41:38 + --> $DIR/into_iter_on_ref.rs:43:38 | LL | let _ = (&HashSet::::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the Path - --> $DIR/into_iter_on_ref.rs:42:43 + --> $DIR/into_iter_on_ref.rs:44:43 | LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the PathBuf - --> $DIR/into_iter_on_ref.rs:43:47 + --> $DIR/into_iter_on_ref.rs:45:47 | LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` diff --git a/tests/ui/invalid_ref.rs b/tests/ui/invalid_ref.rs index 0ec356280b6..4f04c5467d3 100644 --- a/tests/ui/invalid_ref.rs +++ b/tests/ui/invalid_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] #![feature(core_intrinsics)] diff --git a/tests/ui/invalid_ref.stderr b/tests/ui/invalid_ref.stderr index f4386362099..9966c347f6e 100644 --- a/tests/ui/invalid_ref.stderr +++ b/tests/ui/invalid_ref.stderr @@ -1,5 +1,5 @@ error: reference to zeroed memory - --> $DIR/invalid_ref.rs:33:24 + --> $DIR/invalid_ref.rs:24:24 | LL | let ref_zero: &T = std::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let ref_zero: &T = std::mem::zeroed(); // warning = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory - --> $DIR/invalid_ref.rs:37:24 + --> $DIR/invalid_ref.rs:28:24 | LL | let ref_zero: &T = core::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let ref_zero: &T = core::mem::zeroed(); // warning = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory - --> $DIR/invalid_ref.rs:41:24 + --> $DIR/invalid_ref.rs:32:24 | LL | let ref_zero: &T = std::intrinsics::init(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | let ref_zero: &T = std::intrinsics::init(); // warning = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:45:26 + --> $DIR/invalid_ref.rs:36:26 | LL | let ref_uninit: &T = std::mem::uninitialized(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | let ref_uninit: &T = std::mem::uninitialized(); // warning = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:49:26 + --> $DIR/invalid_ref.rs:40:26 | LL | let ref_uninit: &T = core::mem::uninitialized(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | let ref_uninit: &T = core::mem::uninitialized(); // warning = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:53:26 + --> $DIR/invalid_ref.rs:44:26 | LL | let ref_uninit: &T = std::intrinsics::uninit(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/invalid_upcast_comparisons.rs b/tests/ui/invalid_upcast_comparisons.rs index 60f877b1ebe..697416dcee8 100644 --- a/tests/ui/invalid_upcast_comparisons.rs +++ b/tests/ui/invalid_upcast_comparisons.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::invalid_upcast_comparisons)] #![allow( unused, diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index 4bf92088337..03c3fb80aaa 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,5 +1,5 @@ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:30:5 + --> $DIR/invalid_upcast_comparisons.rs:21:5 | LL | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ @@ -7,157 +7,157 @@ LL | (u8 as u32) > 300; = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:31:5 + --> $DIR/invalid_upcast_comparisons.rs:22:5 | LL | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:32:5 + --> $DIR/invalid_upcast_comparisons.rs:23:5 | LL | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:33:5 + --> $DIR/invalid_upcast_comparisons.rs:24:5 | LL | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:34:5 + --> $DIR/invalid_upcast_comparisons.rs:25:5 | LL | 300 < (u8 as u32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:35:5 + --> $DIR/invalid_upcast_comparisons.rs:26:5 | LL | 300 < (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:36:5 + --> $DIR/invalid_upcast_comparisons.rs:27:5 | LL | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:37:5 + --> $DIR/invalid_upcast_comparisons.rs:28:5 | LL | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:39:5 + --> $DIR/invalid_upcast_comparisons.rs:30:5 | LL | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:40:5 + --> $DIR/invalid_upcast_comparisons.rs:31:5 | LL | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:41:5 + --> $DIR/invalid_upcast_comparisons.rs:32:5 | LL | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:42:5 + --> $DIR/invalid_upcast_comparisons.rs:33:5 | LL | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:43:5 + --> $DIR/invalid_upcast_comparisons.rs:34:5 | LL | 300 >= (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:44:5 + --> $DIR/invalid_upcast_comparisons.rs:35:5 | LL | 300 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:45:5 + --> $DIR/invalid_upcast_comparisons.rs:36:5 | LL | 300 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:46:5 + --> $DIR/invalid_upcast_comparisons.rs:37:5 | LL | 300 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:49:5 + --> $DIR/invalid_upcast_comparisons.rs:40:5 | LL | (u8 as i32) < 0; | ^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:50:5 + --> $DIR/invalid_upcast_comparisons.rs:41:5 | LL | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:52:5 + --> $DIR/invalid_upcast_comparisons.rs:43:5 | LL | (u8 as i32) >= 0; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:53:5 + --> $DIR/invalid_upcast_comparisons.rs:44:5 | LL | -5 == (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:56:5 + --> $DIR/invalid_upcast_comparisons.rs:47:5 | LL | 1337 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:57:5 + --> $DIR/invalid_upcast_comparisons.rs:48:5 | LL | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:59:5 + --> $DIR/invalid_upcast_comparisons.rs:50:5 | LL | 1337 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:60:5 + --> $DIR/invalid_upcast_comparisons.rs:51:5 | LL | 1337 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:74:5 + --> $DIR/invalid_upcast_comparisons.rs:65:5 | LL | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:75:5 + --> $DIR/invalid_upcast_comparisons.rs:66:5 | LL | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:91:5 + --> $DIR/invalid_upcast_comparisons.rs:82:5 | LL | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issue-3145.rs b/tests/ui/issue-3145.rs index 5c6392811b9..f497d5550af 100644 --- a/tests/ui/issue-3145.rs +++ b/tests/ui/issue-3145.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() { println!("{}" a); //~ERROR expected token: `,` } diff --git a/tests/ui/issue-3145.stderr b/tests/ui/issue-3145.stderr index c7a995c61d6..f3984f991a4 100644 --- a/tests/ui/issue-3145.stderr +++ b/tests/ui/issue-3145.stderr @@ -1,5 +1,5 @@ error: expected token: `,` - --> $DIR/issue-3145.rs:11:19 + --> $DIR/issue-3145.rs:2:19 | LL | println!("{}" a); //~ERROR expected token: `,` | ^ diff --git a/tests/ui/issue_2356.rs b/tests/ui/issue_2356.rs index a54da0b6a96..da580a1839a 100644 --- a/tests/ui/issue_2356.rs +++ b/tests/ui/issue_2356.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::while_let_on_iterator)] use std::iter::Iterator; diff --git a/tests/ui/issue_2356.stderr b/tests/ui/issue_2356.stderr index 37599900312..d7125901335 100644 --- a/tests/ui/issue_2356.stderr +++ b/tests/ui/issue_2356.stderr @@ -1,11 +1,11 @@ error: this loop could be written as a `for` loop - --> $DIR/issue_2356.rs:24:29 + --> $DIR/issue_2356.rs:15:29 | LL | while let Some(e) = it.next() { | ^^^^^^^^^ help: try: `for e in it { .. }` | note: lint level defined here - --> $DIR/issue_2356.rs:10:9 + --> $DIR/issue_2356.rs:1:9 | LL | #![deny(clippy::while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/item_after_statement.rs b/tests/ui/item_after_statement.rs index fca19350558..c17a7cbc8d9 100644 --- a/tests/ui/item_after_statement.rs +++ b/tests/ui/item_after_statement.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::items_after_statements)] fn ok() { diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index 3024431244c..f8f010b5e5c 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -1,5 +1,5 @@ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/item_after_statement.rs:21:5 + --> $DIR/item_after_statement.rs:12:5 | LL | / fn foo() { LL | | println!("foo"); @@ -9,7 +9,7 @@ LL | | } = note: `-D clippy::items-after-statements` implied by `-D warnings` error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/item_after_statement.rs:28:5 + --> $DIR/item_after_statement.rs:19:5 | LL | / fn foo() { LL | | println!("foo"); diff --git a/tests/ui/iter_skip_next.rs b/tests/ui/iter_skip_next.rs index 0b9d2c36827..a65ca3bbb13 100644 --- a/tests/ui/iter_skip_next.rs +++ b/tests/ui/iter_skip_next.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // aux-build:option_helpers.rs #![warn(clippy::iter_skip_next)] diff --git a/tests/ui/iter_skip_next.stderr b/tests/ui/iter_skip_next.stderr index 037c33fbc3d..6948bd27679 100644 --- a/tests/ui/iter_skip_next.stderr +++ b/tests/ui/iter_skip_next.stderr @@ -1,5 +1,5 @@ error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/iter_skip_next.rs:22:13 + --> $DIR/iter_skip_next.rs:13:13 | LL | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,19 +7,19 @@ LL | let _ = some_vec.iter().skip(42).next(); = note: `-D clippy::iter-skip-next` implied by `-D warnings` error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/iter_skip_next.rs:23:13 + --> $DIR/iter_skip_next.rs:14:13 | LL | let _ = some_vec.iter().cycle().skip(42).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/iter_skip_next.rs:24:13 + --> $DIR/iter_skip_next.rs:15:13 | LL | let _ = (1..10).skip(10).next(); | ^^^^^^^^^^^^^^^^^^^^^^^ error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/iter_skip_next.rs:25:14 + --> $DIR/iter_skip_next.rs:16:14 | LL | let _ = &some_vec[..].iter().skip(3).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/large_digit_groups.fixed b/tests/ui/large_digit_groups.fixed new file mode 100644 index 00000000000..cf8b36a499b --- /dev/null +++ b/tests/ui/large_digit_groups.fixed @@ -0,0 +1,23 @@ +// run-rustfix +#[warn(clippy::large_digit_groups)] +#[allow(unused_variables)] +fn main() { + let good = ( + 0b1011_i64, + 0o1_234_u32, + 0x1_234_567, + 1_2345_6789, + 1234_f32, + 1_234.12_f32, + 1_234.123_f32, + 1.123_4_f32, + ); + let bad = ( + 0b11_0110_i64, + 0x0123_4567_8901_usize, + 123_456_f32, + 123_456.12_f32, + 123_456.123_45_f64, + 123_456.123_456_f64, + ); +} diff --git a/tests/ui/large_digit_groups.rs b/tests/ui/large_digit_groups.rs index 80153efcb93..5b9aa8c58d8 100644 --- a/tests/ui/large_digit_groups.rs +++ b/tests/ui/large_digit_groups.rs @@ -1,12 +1,4 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #[warn(clippy::large_digit_groups)] #[allow(unused_variables)] fn main() { @@ -25,7 +17,7 @@ fn main() { 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, - 1_23456.12345_f32, - 1_23456.12345_6_f32, + 1_23456.12345_f64, + 1_23456.12345_6_f64, ); } diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index 3f88aefda33..4b5d0bd1a9f 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -1,5 +1,5 @@ error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:24:9 + --> $DIR/large_digit_groups.rs:16:9 | LL | 0b1_10110_i64, | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` @@ -7,34 +7,34 @@ LL | 0b1_10110_i64, = note: `-D clippy::large-digit-groups` implied by `-D warnings` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:25:9 + --> $DIR/large_digit_groups.rs:17:9 | LL | 0x1_23456_78901_usize, | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:26:9 + --> $DIR/large_digit_groups.rs:18:9 | LL | 1_23456_f32, | ^^^^^^^^^^^ help: consider: `123_456_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:27:9 + --> $DIR/large_digit_groups.rs:19:9 | LL | 1_23456.12_f32, | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:28:9 + --> $DIR/large_digit_groups.rs:20:9 | -LL | 1_23456.12345_f32, - | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f32` +LL | 1_23456.12345_f64, + | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f64` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:29:9 + --> $DIR/large_digit_groups.rs:21:9 | -LL | 1_23456.12345_6_f32, - | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f32` +LL | 1_23456.12345_6_f64, + | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f64` error: aborting due to 6 previous errors diff --git a/tests/ui/large_enum_variant.rs b/tests/ui/large_enum_variant.rs index 29a73e68d43..852ef5fec0e 100644 --- a/tests/ui/large_enum_variant.rs +++ b/tests/ui/large_enum_variant.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] #![allow(unused_variables)] #![warn(clippy::large_enum_variant)] diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 839d16bd9a2..b13812612cb 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:16:5 + --> $DIR/large_enum_variant.rs:7:5 | LL | B([i32; 8000]), | ^^^^^^^^^^^^^^ @@ -11,19 +11,19 @@ LL | B(Box<[i32; 8000]>), | ^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:27:5 + --> $DIR/large_enum_variant.rs:18:5 | LL | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:27:5 + --> $DIR/large_enum_variant.rs:18:5 | LL | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:40:5 + --> $DIR/large_enum_variant.rs:31:5 | LL | ContainingLargeEnum(LargeEnum), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,31 +33,31 @@ LL | ContainingLargeEnum(Box), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:43:5 + --> $DIR/large_enum_variant.rs:34:5 | LL | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:43:5 + --> $DIR/large_enum_variant.rs:34:5 | LL | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:50:5 + --> $DIR/large_enum_variant.rs:41:5 | LL | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:50:5 + --> $DIR/large_enum_variant.rs:41:5 | LL | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:55:5 + --> $DIR/large_enum_variant.rs:46:5 | LL | StructLikeLarge2 { x: [i32; 8000] }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index 7f4ba4f1523..05b863f3edc 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::len_without_is_empty, clippy::len_zero)] #![allow(dead_code, unused)] diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index f5f19e128b7..a8b2e2e4097 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,5 +1,5 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:15:1 + --> $DIR/len_zero.rs:6:1 | LL | / impl PubOne { LL | | pub fn len(self: &Self) -> isize { @@ -11,7 +11,7 @@ LL | | } = note: `-D clippy::len-without-is-empty` implied by `-D warnings` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:64:1 + --> $DIR/len_zero.rs:55:1 | LL | / pub trait PubTraitsToo { LL | | fn len(self: &Self) -> isize; @@ -19,7 +19,7 @@ LL | | } | |_^ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method - --> $DIR/len_zero.rs:98:1 + --> $DIR/len_zero.rs:89:1 | LL | / impl HasIsEmpty { LL | | pub fn len(self: &Self) -> isize { @@ -31,7 +31,7 @@ LL | | } | |_^ error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:127:1 + --> $DIR/len_zero.rs:118:1 | LL | / impl HasWrongIsEmpty { LL | | pub fn len(self: &Self) -> isize { @@ -43,7 +43,7 @@ LL | | } | |_^ error: length comparison to zero - --> $DIR/len_zero.rs:148:8 + --> $DIR/len_zero.rs:139:8 | LL | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` @@ -51,85 +51,85 @@ LL | if x.len() == 0 { = note: `-D clippy::len-zero` implied by `-D warnings` error: length comparison to zero - --> $DIR/len_zero.rs:152:8 + --> $DIR/len_zero.rs:143:8 | LL | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:167:8 + --> $DIR/len_zero.rs:158:8 | LL | if has_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:170:8 + --> $DIR/len_zero.rs:161:8 | LL | if has_is_empty.len() != 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:173:8 + --> $DIR/len_zero.rs:164:8 | LL | if has_is_empty.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:176:8 + --> $DIR/len_zero.rs:167:8 | LL | if has_is_empty.len() < 1 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:179:8 + --> $DIR/len_zero.rs:170:8 | LL | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:190:8 + --> $DIR/len_zero.rs:181:8 | LL | if 0 == has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:193:8 + --> $DIR/len_zero.rs:184:8 | LL | if 0 != has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:196:8 + --> $DIR/len_zero.rs:187:8 | LL | if 0 < has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:199:8 + --> $DIR/len_zero.rs:190:8 | LL | if 1 <= has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:202:8 + --> $DIR/len_zero.rs:193:8 | LL | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:216:8 + --> $DIR/len_zero.rs:207:8 | LL | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:229:8 + --> $DIR/len_zero.rs:220:8 | LL | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!b.is_empty()` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:235:1 + --> $DIR/len_zero.rs:226:1 | LL | / pub trait DependsOnFoo: Foo { LL | | fn len(&mut self) -> usize; diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index 26fdc46ac17..5bfa32dd56c 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( unused_variables, unused_assignments, diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 7883a713c05..c53a63a541b 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,5 +1,5 @@ error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:72:5 + --> $DIR/let_if_seq.rs:63:5 | LL | / let mut foo = 0; LL | | if f() { @@ -11,7 +11,7 @@ LL | | } = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:77:5 + --> $DIR/let_if_seq.rs:68:5 | LL | / let mut bar = 0; LL | | if f() { @@ -25,7 +25,7 @@ LL | | } = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:85:5 + --> $DIR/let_if_seq.rs:76:5 | LL | / let quz; LL | | if f() { @@ -36,7 +36,7 @@ LL | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:114:5 + --> $DIR/let_if_seq.rs:105:5 | LL | / let mut baz = 0; LL | | if f() { diff --git a/tests/ui/let_return.rs b/tests/ui/let_return.rs index eb012133376..d2e46621f9f 100644 --- a/tests/ui/let_return.rs +++ b/tests/ui/let_return.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] #![warn(clippy::let_and_return)] diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index c53d5cfb886..69c4720c9b3 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -1,24 +1,24 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/let_return.rs:16:5 + --> $DIR/let_return.rs:7:5 | LL | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned - --> $DIR/let_return.rs:15:13 + --> $DIR/let_return.rs:6:13 | LL | let x = 5; | ^ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/let_return.rs:22:9 + --> $DIR/let_return.rs:13:9 | LL | x | ^ | note: this expression can be directly returned - --> $DIR/let_return.rs:21:17 + --> $DIR/let_return.rs:12:17 | LL | let x = 5; | ^ diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index 89cb190cc96..dc17c98f6a8 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::let_unit_value)] #![allow(unused_variables)] diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index 8929844180a..e1773a40225 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,5 +1,5 @@ error: this let-binding has unit value. Consider omitting `let _x =` - --> $DIR/let_unit.rs:20:5 + --> $DIR/let_unit.rs:11:5 | LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let _x = println!("x"); = note: `-D clippy::let-unit-value` implied by `-D warnings` error: this let-binding has unit value. Consider omitting `let _a =` - --> $DIR/let_unit.rs:24:9 + --> $DIR/let_unit.rs:15:9 | LL | let _a = (); | ^^^^^^^^^^^^ diff --git a/tests/ui/lifetimes.rs b/tests/ui/lifetimes.rs index 110868404bd..46c8e1740a9 100644 --- a/tests/ui/lifetimes.rs +++ b/tests/ui/lifetimes.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::needless_lifetimes, clippy::extra_unused_lifetimes)] #![allow(dead_code, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)] diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index abd11907b6d..18b8440089c 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -1,5 +1,5 @@ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:13:1 + --> $DIR/lifetimes.rs:4:1 | LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} = note: `-D clippy::needless-lifetimes` implied by `-D warnings` error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:15:1 + --> $DIR/lifetimes.rs:6:1 | LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:23:1 + --> $DIR/lifetimes.rs:14:1 | LL | / fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { LL | | x @@ -21,7 +21,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:47:1 + --> $DIR/lifetimes.rs:38:1 | LL | / fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { LL | | Ok(x) @@ -29,7 +29,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:52:1 + --> $DIR/lifetimes.rs:43:1 | LL | / fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> LL | | where @@ -40,13 +40,13 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:63:1 + --> $DIR/lifetimes.rs:54:1 | LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:84:1 + --> $DIR/lifetimes.rs:75:1 | LL | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> LL | | where @@ -57,7 +57,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:117:5 + --> $DIR/lifetimes.rs:108:5 | LL | / fn self_and_out<'s>(&'s self) -> &'s u8 { LL | | &self.x @@ -65,13 +65,13 @@ LL | | } | |_____^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:125:5 + --> $DIR/lifetimes.rs:116:5 | LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:141:1 + --> $DIR/lifetimes.rs:132:1 | LL | / fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { LL | | unimplemented!() @@ -79,7 +79,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:171:1 + --> $DIR/lifetimes.rs:162:1 | LL | / fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { LL | | unimplemented!() @@ -87,7 +87,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:177:1 + --> $DIR/lifetimes.rs:168:1 | LL | / fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { LL | | unimplemented!() @@ -95,7 +95,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:196:1 + --> $DIR/lifetimes.rs:187:1 | LL | / fn named_input_elided_output<'a>(_arg: &'a str) -> &str { LL | | unimplemented!() @@ -103,7 +103,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:204:1 + --> $DIR/lifetimes.rs:195:1 | LL | / fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { LL | | unimplemented!() @@ -111,7 +111,7 @@ LL | | } | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:241:1 + --> $DIR/lifetimes.rs:232:1 | LL | / fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { LL | | unimplemented!() diff --git a/tests/ui/literals.rs b/tests/ui/literals.rs index 90e9a69a994..ef86b5240eb 100644 --- a/tests/ui/literals.rs +++ b/tests/ui/literals.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::large_digit_groups)] #![warn(clippy::mixed_case_hex_literals)] #![warn(clippy::unseparated_literal_suffix)] diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index 6ceb25fd612..2a461dba457 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -1,5 +1,5 @@ error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:22:17 + --> $DIR/literals.rs:13:17 | LL | let fail1 = 0xabCD; | ^^^^^^ @@ -7,19 +7,19 @@ LL | let fail1 = 0xabCD; = note: `-D clippy::mixed-case-hex-literals` implied by `-D warnings` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:23:17 + --> $DIR/literals.rs:14:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:24:17 + --> $DIR/literals.rs:15:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:25:27 + --> $DIR/literals.rs:16:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | let fail_multi_zero = 000_123usize; = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` error: this is a decimal constant - --> $DIR/literals.rs:25:27 + --> $DIR/literals.rs:16:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ @@ -43,37 +43,37 @@ LL | let fail_multi_zero = 0o123usize; | ^^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:30:17 + --> $DIR/literals.rs:21:17 | LL | let fail3 = 1234i32; | ^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:31:17 + --> $DIR/literals.rs:22:17 | LL | let fail4 = 1234u32; | ^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:32:17 + --> $DIR/literals.rs:23:17 | LL | let fail5 = 1234isize; | ^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:33:17 + --> $DIR/literals.rs:24:17 | LL | let fail6 = 1234usize; | ^^^^^^^^^ error: float type suffix should be separated by an underscore - --> $DIR/literals.rs:34:17 + --> $DIR/literals.rs:25:17 | LL | let fail7 = 1.5f32; | ^^^^^^ error: this is a decimal constant - --> $DIR/literals.rs:38:17 + --> $DIR/literals.rs:29:17 | LL | let fail8 = 0123; | ^^^^ @@ -87,7 +87,7 @@ LL | let fail8 = 0o123; | ^^^^^ error: long literal lacking separators - --> $DIR/literals.rs:49:17 + --> $DIR/literals.rs:40:17 | LL | let fail9 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` @@ -95,25 +95,25 @@ LL | let fail9 = 0xabcdef; = note: `-D clippy::unreadable-literal` implied by `-D warnings` error: long literal lacking separators - --> $DIR/literals.rs:50:18 + --> $DIR/literals.rs:41:18 | LL | let fail10 = 0xBAFEBAFE; | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` error: long literal lacking separators - --> $DIR/literals.rs:51:18 + --> $DIR/literals.rs:42:18 | LL | let fail11 = 0xabcdeff; | ^^^^^^^^^ help: consider: `0x0abc_deff` error: long literal lacking separators - --> $DIR/literals.rs:52:18 + --> $DIR/literals.rs:43:18 | LL | let fail12 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` error: digit groups should be smaller - --> $DIR/literals.rs:53:18 + --> $DIR/literals.rs:44:18 | LL | let fail13 = 0x1_23456_78901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` @@ -121,7 +121,7 @@ LL | let fail13 = 0x1_23456_78901_usize; = note: `-D clippy::large-digit-groups` implied by `-D warnings` error: mistyped literal suffix - --> $DIR/literals.rs:55:18 + --> $DIR/literals.rs:46:18 | LL | let fail14 = 2_32; | ^^^^ help: did you mean to write: `2_i32` @@ -129,25 +129,25 @@ LL | let fail14 = 2_32; = note: #[deny(clippy::mistyped_literal_suffixes)] on by default error: mistyped literal suffix - --> $DIR/literals.rs:56:18 + --> $DIR/literals.rs:47:18 | LL | let fail15 = 4_64; | ^^^^ help: did you mean to write: `4_i64` error: mistyped literal suffix - --> $DIR/literals.rs:57:18 + --> $DIR/literals.rs:48:18 | LL | let fail16 = 7_8; | ^^^ help: did you mean to write: `7_i8` error: mistyped literal suffix - --> $DIR/literals.rs:58:18 + --> $DIR/literals.rs:49:18 | LL | let fail17 = 23_16; | ^^^^^ help: did you mean to write: `23_i16` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:60:18 + --> $DIR/literals.rs:51:18 | LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` @@ -155,61 +155,61 @@ LL | let fail19 = 12_3456_21; = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` error: mistyped literal suffix - --> $DIR/literals.rs:61:18 + --> $DIR/literals.rs:52:18 | LL | let fail20 = 2__8; | ^^^^ help: did you mean to write: `2_i8` error: mistyped literal suffix - --> $DIR/literals.rs:62:18 + --> $DIR/literals.rs:53:18 | LL | let fail21 = 4___16; | ^^^^^^ help: did you mean to write: `4_i16` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:63:18 + --> $DIR/literals.rs:54:18 | LL | let fail22 = 3__4___23; | ^^^^^^^^^ help: consider: `3_423` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:64:18 + --> $DIR/literals.rs:55:18 | LL | let fail23 = 3__16___23; | ^^^^^^^^^^ help: consider: `31_623` error: mistyped literal suffix - --> $DIR/literals.rs:66:18 + --> $DIR/literals.rs:57:18 | LL | let fail24 = 12.34_64; | ^^^^^^^^ help: did you mean to write: `12.34_f64` error: mistyped literal suffix - --> $DIR/literals.rs:67:18 + --> $DIR/literals.rs:58:18 | LL | let fail25 = 1E2_32; | ^^^^^^ help: did you mean to write: `1E2_f32` error: mistyped literal suffix - --> $DIR/literals.rs:68:18 + --> $DIR/literals.rs:59:18 | LL | let fail26 = 43E7_64; | ^^^^^^^ help: did you mean to write: `43E7_f64` error: mistyped literal suffix - --> $DIR/literals.rs:69:18 + --> $DIR/literals.rs:60:18 | LL | let fail27 = 243E17_32; | ^^^^^^^^^ help: did you mean to write: `243E17_f32` error: mistyped literal suffix - --> $DIR/literals.rs:70:18 + --> $DIR/literals.rs:61:18 | LL | let fail28 = 241251235E723_64; | ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64` error: mistyped literal suffix - --> $DIR/literals.rs:71:18 + --> $DIR/literals.rs:62:18 | LL | let fail29 = 42279.911_32; | ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32` diff --git a/tests/ui/map_clone.fixed b/tests/ui/map_clone.fixed new file mode 100644 index 00000000000..af417815ed1 --- /dev/null +++ b/tests/ui/map_clone.fixed @@ -0,0 +1,23 @@ +// run-rustfix +#![warn(clippy::all, clippy::pedantic)] +#![allow(clippy::iter_cloned_collect)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::missing_docs_in_private_items)] + +fn main() { + let _: Vec = vec![5_i8; 6].iter().cloned().collect(); + let _: Vec = vec![String::new()].iter().cloned().collect(); + let _: Vec = vec![42, 43].iter().cloned().collect(); + let _: Option = Some(Box::new(16)).map(|b| *b); + + // Don't lint these + let v = vec![5_i8; 6]; + let a = 0; + let b = &a; + let _ = v.iter().map(|_x| *b); + let _ = v.iter().map(|_x| a.clone()); + let _ = v.iter().map(|&_x| a); + + // Issue #498 + let _ = std::env::args(); +} diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index e6fb37f8120..7dd2ce30202 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -1,13 +1,7 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![warn(clippy::all, clippy::pedantic)] +#![allow(clippy::iter_cloned_collect)] +#![allow(clippy::clone_on_copy)] #![allow(clippy::missing_docs_in_private_items)] fn main() { @@ -15,4 +9,15 @@ fn main() { let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); let _: Option = Some(Box::new(16)).map(|b| *b); + + // Don't lint these + let v = vec![5_i8; 6]; + let a = 0; + let b = &a; + let _ = v.iter().map(|_x| *b); + let _ = v.iter().map(|_x| a.clone()); + let _ = v.iter().map(|&_x| a); + + // Issue #498 + let _ = std::env::args().map(|v| v.clone()); } diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 6253ae2150c..504f4a01a4c 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,5 +1,5 @@ error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:14:22 + --> $DIR/map_clone.rs:8:22 | LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![5_i8; 6].iter().cloned()` @@ -7,16 +7,22 @@ LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); = note: `-D clippy::map-clone` implied by `-D warnings` error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:15:26 + --> $DIR/map_clone.rs:9:26 | LL | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()` error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:16:23 + --> $DIR/map_clone.rs:10:23 | LL | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![42, 43].iter().cloned()` -error: aborting due to 3 previous errors +error: You are needlessly cloning iterator elements + --> $DIR/map_clone.rs:22:29 + | +LL | let _ = std::env::args().map(|v| v.clone()); + | ^^^^^^^^^^^^^^^^^^^ help: Remove the map call + +error: aborting due to 4 previous errors diff --git a/tests/ui/map_flatten.rs b/tests/ui/map_flatten.rs index 99b90a0df79..d0720c419c8 100644 --- a/tests/ui/map_flatten.rs +++ b/tests/ui/map_flatten.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::missing_docs_in_private_items)] diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index 931ef9b6248..822d27391f6 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -1,5 +1,5 @@ error: called `map(..).flatten()` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` - --> $DIR/map_flatten.rs:14:21 + --> $DIR/map_flatten.rs:5:21 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using flat_map instead: `vec![5_i8; 6].into_iter().flat_map(|x| 0..x)` diff --git a/tests/ui/map_unit_fn.rs b/tests/ui/map_unit_fn.rs index 1d203a147ba..9a74da4e3b8 100644 --- a/tests/ui/map_unit_fn.rs +++ b/tests/ui/map_unit_fn.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] struct Mappable {} diff --git a/tests/ui/match_bool.rs b/tests/ui/match_bool.rs index fe5e94cf458..a7af8ce0108 100644 --- a/tests/ui/match_bool.rs +++ b/tests/ui/match_bool.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn match_bool() { let test: bool = true; diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index 78711c4ba4b..193e6c17238 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/match_bool.rs:38:11 + --> $DIR/match_bool.rs:29:11 | LL | match test && test { | ^^^^^^^^^^^^ help: try: `test` @@ -7,7 +7,7 @@ LL | match test && test { = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:13:5 + --> $DIR/match_bool.rs:4:5 | LL | / match test { LL | | true => 0, @@ -18,7 +18,7 @@ LL | | }; = note: `-D clippy::match-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:19:5 + --> $DIR/match_bool.rs:10:5 | LL | / match option == 1 { LL | | true => 1, @@ -27,7 +27,7 @@ LL | | }; | |_____^ help: consider using an if/else expression: `if option == 1 { 1 } else { 0 }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:24:5 + --> $DIR/match_bool.rs:15:5 | LL | / match test { LL | | true => (), @@ -44,7 +44,7 @@ LL | }; | error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:31:5 + --> $DIR/match_bool.rs:22:5 | LL | / match test { LL | | false => { @@ -61,7 +61,7 @@ LL | }; | error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:38:5 + --> $DIR/match_bool.rs:29:5 | LL | / match test && test { LL | | false => { @@ -78,7 +78,7 @@ LL | }; | error: equal expressions as operands to `&&` - --> $DIR/match_bool.rs:38:11 + --> $DIR/match_bool.rs:29:11 | LL | match test && test { | ^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | match test && test { = note: #[deny(clippy::eq_op)] on by default error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:45:5 + --> $DIR/match_bool.rs:36:5 | LL | / match test { LL | | false => { diff --git a/tests/ui/match_overlapping_arm.rs b/tests/ui/match_overlapping_arm.rs index 5350f933ae5..978ac5195d3 100644 --- a/tests/ui/match_overlapping_arm.rs +++ b/tests/ui/match_overlapping_arm.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(exclusive_range_pattern)] #![warn(clippy::match_overlapping_arm)] #![allow(clippy::redundant_pattern_matching)] diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index 3e978df842e..14eb378141b 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -1,60 +1,60 @@ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:20:9 + --> $DIR/match_overlapping_arm.rs:11:9 | LL | 0...10 => println!("0 ... 10"), | ^^^^^^ | = note: `-D clippy::match-overlapping-arm` implied by `-D warnings` note: overlaps with this - --> $DIR/match_overlapping_arm.rs:21:9 + --> $DIR/match_overlapping_arm.rs:12:9 | LL | 0...11 => println!("0 ... 11"), | ^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:26:9 + --> $DIR/match_overlapping_arm.rs:17:9 | LL | 0...5 => println!("0 ... 5"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:28:9 + --> $DIR/match_overlapping_arm.rs:19:9 | LL | FOO...11 => println!("0 ... 11"), | ^^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:34:9 + --> $DIR/match_overlapping_arm.rs:25:9 | LL | 0...5 => println!("0 ... 5"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:33:9 + --> $DIR/match_overlapping_arm.rs:24:9 | LL | 2 => println!("2"), | ^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:40:9 + --> $DIR/match_overlapping_arm.rs:31:9 | LL | 0...2 => println!("0 ... 2"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:39:9 + --> $DIR/match_overlapping_arm.rs:30:9 | LL | 2 => println!("2"), | ^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:63:9 + --> $DIR/match_overlapping_arm.rs:54:9 | LL | 0..11 => println!("0 .. 11"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:64:9 + --> $DIR/match_overlapping_arm.rs:55:9 | LL | 0...11 => println!("0 ... 11"), | ^^^^^^ diff --git a/tests/ui/matches.rs b/tests/ui/matches.rs index 8038433c564..013f12a1a0e 100644 --- a/tests/ui/matches.rs +++ b/tests/ui/matches.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(exclusive_range_pattern)] #![warn(clippy::all)] #![allow(unused, clippy::redundant_pattern_matching)] diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 06ba6224855..a3714a69e6e 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -1,5 +1,5 @@ error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:20:9 + --> $DIR/matches.rs:11:9 | LL | / match v { LL | | &Some(v) => println!("{:?}", v), @@ -16,7 +16,7 @@ LL | None => println!("none"), | error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:31:5 + --> $DIR/matches.rs:22:5 | LL | / match tup { LL | | &(v, 1) => println!("{}", v), @@ -30,7 +30,7 @@ LL | (v, 1) => println!("{}", v), | error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:37:5 + --> $DIR/matches.rs:28:5 | LL | / match &w { LL | | &Some(v) => println!("{:?}", v), @@ -45,7 +45,7 @@ LL | None => println!("none"), | error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:48:5 + --> $DIR/matches.rs:39:5 | LL | / if let &None = a { LL | | println!("none"); @@ -57,7 +57,7 @@ LL | if let None = *a { | ^^^^ ^^ error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:53:5 + --> $DIR/matches.rs:44:5 | LL | / if let &None = &b { LL | | println!("none"); @@ -69,7 +69,7 @@ LL | if let None = b { | ^^^^ ^ error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:64:9 + --> $DIR/matches.rs:55:9 | LL | Err(_) => panic!("err"), | ^^^^^^ @@ -78,26 +78,26 @@ LL | Err(_) => panic!("err"), = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies - --> $DIR/matches.rs:63:18 + --> $DIR/matches.rs:54:18 | LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/matches.rs:62:18 + --> $DIR/matches.rs:53:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:62:18 + --> $DIR/matches.rs:53:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = 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: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:70:9 + --> $DIR/matches.rs:61:9 | LL | Err(_) => panic!(), | ^^^^^^ @@ -105,31 +105,49 @@ LL | Err(_) => panic!(), = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies - --> $DIR/matches.rs:69:18 + --> $DIR/matches.rs:60:18 | LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:68:18 + --> $DIR/matches.rs:59:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:68:18 + --> $DIR/matches.rs:59:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = 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: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:76:9 + --> $DIR/matches.rs:67:9 | LL | Err(_) => { | ^^^^^^ | = note: to remove this warning, match each error separately or use unreachable macro +error: this `match` has identical arm bodies + --> $DIR/matches.rs:66:18 + | +LL | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | +note: same as this + --> $DIR/matches.rs:65:18 + | +LL | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ +note: consider refactoring into `Ok(3) | Ok(_)` + --> $DIR/matches.rs:65:18 + | +LL | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ + = 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: this `match` has identical arm bodies --> $DIR/matches.rs:75:18 | @@ -149,115 +167,97 @@ LL | Ok(3) => println!("ok"), = 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: this `match` has identical arm bodies - --> $DIR/matches.rs:84:18 + --> $DIR/matches.rs:82:18 | LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:83:18 + --> $DIR/matches.rs:81:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:83:18 + --> $DIR/matches.rs:81:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = 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: this `match` has identical arm bodies - --> $DIR/matches.rs:91:18 + --> $DIR/matches.rs:88:18 | LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:90:18 + --> $DIR/matches.rs:87:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:90:18 + --> $DIR/matches.rs:87:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = 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: this `match` has identical arm bodies - --> $DIR/matches.rs:97:18 + --> $DIR/matches.rs:94:18 | LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:96:18 + --> $DIR/matches.rs:93:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:96:18 + --> $DIR/matches.rs:93:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = 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: this `match` has identical arm bodies - --> $DIR/matches.rs:103:18 - | -LL | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | -note: same as this - --> $DIR/matches.rs:102:18 - | -LL | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ -note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:102:18 - | -LL | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ - = 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: this `match` has identical arm bodies - --> $DIR/matches.rs:126:29 + --> $DIR/matches.rs:117:29 | LL | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:125:29 + --> $DIR/matches.rs:116:29 | LL | (Ok(x), Some(_)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))` - --> $DIR/matches.rs:125:29 + --> $DIR/matches.rs:116:29 | LL | (Ok(x), Some(_)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ = 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: this `match` has identical arm bodies - --> $DIR/matches.rs:141:18 + --> $DIR/matches.rs:132:18 | LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:140:18 + --> $DIR/matches.rs:131:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:140:18 + --> $DIR/matches.rs:131:18 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = 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: use as_ref() instead - --> $DIR/matches.rs:150:33 + --> $DIR/matches.rs:141:33 | LL | let borrowed: Option<&()> = match owned { | _________________________________^ @@ -269,7 +269,7 @@ LL | | }; = note: `-D clippy::match-as-ref` implied by `-D warnings` error: use as_mut() instead - --> $DIR/matches.rs:156:39 + --> $DIR/matches.rs:147:39 | LL | let borrow_mut: Option<&mut ()> = match mut_owned { | _______________________________________^ diff --git a/tests/ui/mem_discriminant.rs b/tests/ui/mem_discriminant.rs index 9d2d6f9503a..81f1628861e 100644 --- a/tests/ui/mem_discriminant.rs +++ b/tests/ui/mem_discriminant.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::mem_discriminant_non_enum)] use std::mem; diff --git a/tests/ui/mem_discriminant.stderr b/tests/ui/mem_discriminant.stderr index c445b96a90f..295545406ed 100644 --- a/tests/ui/mem_discriminant.stderr +++ b/tests/ui/mem_discriminant.stderr @@ -1,17 +1,17 @@ error: calling `mem::discriminant` on non-enum type `&str` - --> $DIR/mem_discriminant.rs:23:5 + --> $DIR/mem_discriminant.rs:14:5 | LL | mem::discriminant(&"hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/mem_discriminant.rs:10:9 + --> $DIR/mem_discriminant.rs:1:9 | LL | #![deny(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:24:5 + --> $DIR/mem_discriminant.rs:15:5 | LL | mem::discriminant(&&Some(2)); | ^^^^^^^^^^^^^^^^^^---------^ @@ -19,7 +19,7 @@ LL | mem::discriminant(&&Some(2)); | help: try dereferencing: `&Some(2)` error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:25:5 + --> $DIR/mem_discriminant.rs:16:5 | LL | mem::discriminant(&&None::); | ^^^^^^^^^^^^^^^^^^------------^ @@ -27,7 +27,7 @@ LL | mem::discriminant(&&None::); | help: try dereferencing: `&None::` error: calling `mem::discriminant` on non-enum type `&Foo` - --> $DIR/mem_discriminant.rs:26:5 + --> $DIR/mem_discriminant.rs:17:5 | LL | mem::discriminant(&&Foo::One(5)); | ^^^^^^^^^^^^^^^^^^-------------^ @@ -35,7 +35,7 @@ LL | mem::discriminant(&&Foo::One(5)); | help: try dereferencing: `&Foo::One(5)` error: calling `mem::discriminant` on non-enum type `&Foo` - --> $DIR/mem_discriminant.rs:27:5 + --> $DIR/mem_discriminant.rs:18:5 | LL | mem::discriminant(&&Foo::Two(5)); | ^^^^^^^^^^^^^^^^^^-------------^ @@ -43,13 +43,13 @@ LL | mem::discriminant(&&Foo::Two(5)); | help: try dereferencing: `&Foo::Two(5)` error: calling `mem::discriminant` on non-enum type `A` - --> $DIR/mem_discriminant.rs:28:5 + --> $DIR/mem_discriminant.rs:19:5 | LL | mem::discriminant(&A(Foo::One(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:32:5 + --> $DIR/mem_discriminant.rs:23:5 | LL | mem::discriminant(&ro); | ^^^^^^^^^^^^^^^^^^---^ @@ -57,7 +57,7 @@ LL | mem::discriminant(&ro); | help: try dereferencing: `ro` error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:33:5 + --> $DIR/mem_discriminant.rs:24:5 | LL | mem::discriminant(rro); | ^^^^^^^^^^^^^^^^^^---^ @@ -65,7 +65,7 @@ LL | mem::discriminant(rro); | help: try dereferencing: `*rro` error: calling `mem::discriminant` on non-enum type `&&std::option::Option` - --> $DIR/mem_discriminant.rs:34:5 + --> $DIR/mem_discriminant.rs:25:5 | LL | mem::discriminant(&rro); | ^^^^^^^^^^^^^^^^^^----^ @@ -73,7 +73,7 @@ LL | mem::discriminant(&rro); | help: try dereferencing: `*rro` error: calling `mem::discriminant` on non-enum type `&&std::option::Option` - --> $DIR/mem_discriminant.rs:38:13 + --> $DIR/mem_discriminant.rs:29:13 | LL | mem::discriminant($param) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | mem_discriminant_but_in_a_macro!(&rro); | in this macro invocation error: calling `mem::discriminant` on non-enum type `&&&&&std::option::Option` - --> $DIR/mem_discriminant.rs:45:5 + --> $DIR/mem_discriminant.rs:36:5 | LL | mem::discriminant(&rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ @@ -93,7 +93,7 @@ LL | mem::discriminant(&rrrrro); | help: try dereferencing: `****rrrrro` error: calling `mem::discriminant` on non-enum type `&&&std::option::Option` - --> $DIR/mem_discriminant.rs:46:5 + --> $DIR/mem_discriminant.rs:37:5 | LL | mem::discriminant(*rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ diff --git a/tests/ui/mem_forget.rs b/tests/ui/mem_forget.rs index b46f7007cd0..e5b35c098a2 100644 --- a/tests/ui/mem_forget.rs +++ b/tests/ui/mem_forget.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::rc::Rc; use std::sync::Arc; diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 292437d0019..16b95a1038a 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -1,5 +1,5 @@ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:23:5 + --> $DIR/mem_forget.rs:14:5 | LL | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | memstuff::forget(six); = note: `-D clippy::mem-forget` implied by `-D warnings` error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:26:5 + --> $DIR/mem_forget.rs:17:5 | LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:29:5 + --> $DIR/mem_forget.rs:20:5 | LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mem_replace.fixed b/tests/ui/mem_replace.fixed new file mode 100644 index 00000000000..4e47ac95d82 --- /dev/null +++ b/tests/ui/mem_replace.fixed @@ -0,0 +1,21 @@ +// Copyright 2014-2019 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix +#![allow(unused_imports)] +#![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)] + +use std::mem; + +fn main() { + let mut an_option = Some(1); + let _ = an_option.take(); + let an_option = &mut Some(1); + let _ = an_option.take(); +} diff --git a/tests/ui/mem_replace.rs b/tests/ui/mem_replace.rs index edd3c031857..6824ab18e7f 100644 --- a/tests/ui/mem_replace.rs +++ b/tests/ui/mem_replace.rs @@ -1,4 +1,4 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT +// Copyright 2014-2019 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 $DIR/mem_replace.rs:16:13 + --> $DIR/mem_replace.rs:18:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` @@ -7,7 +7,7 @@ LL | let _ = mem::replace(&mut an_option, None); = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:18:13 + --> $DIR/mem_replace.rs:20:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index fa99205d69a..6340d784d74 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // aux-build:option_helpers.rs #![warn(clippy::all, clippy::pedantic, clippy::option_unwrap_used)] diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index ef3a4e2a423..99a0c0d59d1 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -1,5 +1,5 @@ error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name - --> $DIR/methods.rs:44:5 + --> $DIR/methods.rs:35:5 | LL | pub fn add(self, other: T) -> T { self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | pub fn add(self, other: T) -> T { self } = note: `-D clippy::should-implement-trait` implied by `-D warnings` error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/methods.rs:55:17 + --> $DIR/methods.rs:46:17 | LL | fn into_u16(&self) -> u16 { 0 } | ^^^^^ @@ -15,19 +15,19 @@ LL | fn into_u16(&self) -> u16 { 0 } = note: `-D clippy::wrong-self-convention` implied by `-D warnings` error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/methods.rs:57:21 + --> $DIR/methods.rs:48:21 | LL | fn to_something(self) -> u32 { 0 } | ^^^^ error: methods called `new` usually take no self; consider choosing a less ambiguous name - --> $DIR/methods.rs:59:12 + --> $DIR/methods.rs:50:12 | LL | fn new(self) -> Self { unimplemented!(); } | ^^^^ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead - --> $DIR/methods.rs:120:13 + --> $DIR/methods.rs:111:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -39,7 +39,7 @@ LL | | .unwrap_or(0); // should lint even though this call is on = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)` error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead - --> $DIR/methods.rs:124:13 + --> $DIR/methods.rs:115:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -49,7 +49,7 @@ LL | | ).unwrap_or(0); | |____________________________^ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead - --> $DIR/methods.rs:128:13 + --> $DIR/methods.rs:119:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -59,7 +59,7 @@ LL | | }); | |__________________^ error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead - --> $DIR/methods.rs:133:13 + --> $DIR/methods.rs:124:13 | LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))` error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead - --> $DIR/methods.rs:135:13 + --> $DIR/methods.rs:126:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -77,7 +77,7 @@ LL | | ).unwrap_or(None); | |_____________________^ error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead - --> $DIR/methods.rs:139:13 + --> $DIR/methods.rs:130:13 | LL | let _ = opt | _____________^ @@ -88,7 +88,7 @@ LL | | .unwrap_or(None); = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))` error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead - --> $DIR/methods.rs:147:13 + --> $DIR/methods.rs:138:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -100,7 +100,7 @@ LL | | .unwrap_or_else(|| 0); // should lint even though this cal = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead - --> $DIR/methods.rs:151:13 + --> $DIR/methods.rs:142:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -110,7 +110,7 @@ LL | | ).unwrap_or_else(|| 0); | |____________________________________^ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead - --> $DIR/methods.rs:155:13 + --> $DIR/methods.rs:146:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -120,7 +120,7 @@ LL | | ); | |_________________^ error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead - --> $DIR/methods.rs:164:13 + --> $DIR/methods.rs:155:13 | LL | let _ = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))` @@ -128,7 +128,7 @@ LL | let _ = opt.map_or(None, |x| Some(x + 1)); = note: `-D clippy::option-map-or-none` implied by `-D warnings` error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead - --> $DIR/methods.rs:166:13 + --> $DIR/methods.rs:157:13 | LL | let _ = opt.map_or(None, |x| { | _____________^ @@ -144,7 +144,7 @@ LL | }); | error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. - --> $DIR/methods.rs:191:13 + --> $DIR/methods.rs:182:13 | LL | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ LL | let _ = v.iter().filter(|&x| *x < 0).next(); = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)` error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. - --> $DIR/methods.rs:194:13 + --> $DIR/methods.rs:185:13 | LL | let _ = v.iter().filter(|&x| { | _____________^ @@ -163,7 +163,7 @@ LL | | ).next(); | |___________________________^ error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:209:13 + --> $DIR/methods.rs:200:13 | LL | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -172,7 +172,7 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some(); = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)` error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:212:13 + --> $DIR/methods.rs:203:13 | LL | let _ = v.iter().find(|&x| { | _____________^ @@ -182,7 +182,7 @@ LL | | ).is_some(); | |______________________________^ error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:218:13 + --> $DIR/methods.rs:209:13 | LL | let _ = v.iter().position(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +190,7 @@ LL | let _ = v.iter().position(|&x| x < 0).is_some(); = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)` error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:221:13 + --> $DIR/methods.rs:212:13 | LL | let _ = v.iter().position(|&x| { | _____________^ @@ -200,7 +200,7 @@ LL | | ).is_some(); | |______________________________^ error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:227:13 + --> $DIR/methods.rs:218:13 | LL | let _ = v.iter().rposition(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -208,7 +208,7 @@ LL | let _ = v.iter().rposition(|&x| x < 0).is_some(); = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)` error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:230:13 + --> $DIR/methods.rs:221:13 | LL | let _ = v.iter().rposition(|&x| { | _____________^ @@ -218,7 +218,7 @@ LL | | ).is_some(); | |______________________________^ error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:265:22 + --> $DIR/methods.rs:256:22 | LL | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)` @@ -226,73 +226,73 @@ LL | with_constructor.unwrap_or(make()); = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a call to `new` - --> $DIR/methods.rs:268:5 + --> $DIR/methods.rs:259:5 | LL | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:271:21 + --> $DIR/methods.rs:262:21 | LL | with_const_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))` error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:274:14 + --> $DIR/methods.rs:265:14 | LL | with_err.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())` error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:277:19 + --> $DIR/methods.rs:268:19 | LL | with_err_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))` error: use of `unwrap_or` followed by a call to `default` - --> $DIR/methods.rs:280:5 + --> $DIR/methods.rs:271:5 | LL | with_default_trait.unwrap_or(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()` error: use of `unwrap_or` followed by a call to `default` - --> $DIR/methods.rs:283:5 + --> $DIR/methods.rs:274:5 | LL | with_default_type.unwrap_or(u64::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:286:14 + --> $DIR/methods.rs:277:14 | LL | with_vec.unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])` error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:291:21 + --> $DIR/methods.rs:282:21 | LL | without_default.unwrap_or(Foo::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)` error: use of `or_insert` followed by a function call - --> $DIR/methods.rs:294:19 + --> $DIR/methods.rs:285:19 | LL | map.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` error: use of `or_insert` followed by a function call - --> $DIR/methods.rs:297:21 + --> $DIR/methods.rs:288:21 | LL | btree.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:300:21 + --> $DIR/methods.rs:291:21 | LL | let _ = stringy.unwrap_or("".to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())` error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:311:23 + --> $DIR/methods.rs:302:23 | LL | let bad_vec = some_vec.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -300,43 +300,43 @@ LL | let bad_vec = some_vec.iter().nth(3); = note: `-D clippy::iter-nth` implied by `-D warnings` error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:312:26 + --> $DIR/methods.rs:303:26 | LL | let bad_slice = &some_vec[..].iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:313:31 + --> $DIR/methods.rs:304:31 | LL | let bad_boxed_slice = boxed_slice.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:314:29 + --> $DIR/methods.rs:305:29 | LL | let bad_vec_deque = some_vec_deque.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable - --> $DIR/methods.rs:319:23 + --> $DIR/methods.rs:310:23 | LL | let bad_vec = some_vec.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable - --> $DIR/methods.rs:322:26 + --> $DIR/methods.rs:313:26 | LL | let bad_slice = &some_vec[..].iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable - --> $DIR/methods.rs:325:29 + --> $DIR/methods.rs:316:29 | LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message - --> $DIR/methods.rs:337:13 + --> $DIR/methods.rs:328:13 | LL | let _ = opt.unwrap(); | ^^^^^^^^^^^^ diff --git a/tests/ui/min_max.rs b/tests/ui/min_max.rs index cf68bb61100..8307d4b3019 100644 --- a/tests/ui/min_max.rs +++ b/tests/ui/min_max.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] use std::cmp::max as my_max; diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index a6ad34f02b8..6d68d39e8d3 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,5 +1,5 @@ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:21:5 + --> $DIR/min_max.rs:12:5 | LL | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ @@ -7,37 +7,37 @@ LL | min(1, max(3, x)); = note: `-D clippy::min-max` implied by `-D warnings` error: this min/max combination leads to constant result - --> $DIR/min_max.rs:22:5 + --> $DIR/min_max.rs:13:5 | LL | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:23:5 + --> $DIR/min_max.rs:14:5 | LL | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:24:5 + --> $DIR/min_max.rs:15:5 | LL | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:26:5 + --> $DIR/min_max.rs:17:5 | LL | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:38:5 + --> $DIR/min_max.rs:29:5 | LL | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:39:5 + --> $DIR/min_max.rs:30:5 | LL | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing-doc.rs b/tests/ui/missing-doc.rs index 5de2ada5a41..e65bce8e783 100644 --- a/tests/ui/missing-doc.rs +++ b/tests/ui/missing-doc.rs @@ -1,30 +1,8 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* This file incorporates work covered by the following copyright and - * permission notice: - * Copyright 2013 The Rust Project Developers. See the COPYRIGHT - * file at the top-level directory of this distribution and at - * http://rust-lang.org/COPYRIGHT. - * - * Licensed under the Apache License, Version 2.0 or the MIT license - * , at your - * option. This file may not be copied, modified, or distributed - * except according to those terms. - */ - #![warn(clippy::missing_docs_in_private_items)] // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. #![allow(dead_code)] -#![feature(associated_type_defaults)] +#![feature(associated_type_defaults, global_asm)] //! Some garbage docs for the crate here #![doc = "More garbage"] @@ -198,3 +176,6 @@ pub mod public_interface { } fn main() {} + +// Ensure global asm doesn't require documentation. +global_asm! { "" } diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index 35c12786284..a3ae62217a2 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -1,5 +1,5 @@ error: missing documentation for a type alias - --> $DIR/missing-doc.rs:32:1 + --> $DIR/missing-doc.rs:10:1 | LL | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | type Typedef = String; = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` error: missing documentation for a type alias - --> $DIR/missing-doc.rs:33:1 + --> $DIR/missing-doc.rs:11:1 | LL | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:35:1 + --> $DIR/missing-doc.rs:13:1 | LL | / struct Foo { LL | | a: isize, @@ -22,19 +22,19 @@ LL | | } | |_^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:36:5 + --> $DIR/missing-doc.rs:14:5 | LL | a: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:37:5 + --> $DIR/missing-doc.rs:15:5 | LL | b: isize, | ^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:40:1 + --> $DIR/missing-doc.rs:18:1 | LL | / pub struct PubFoo { LL | | pub a: isize, @@ -43,43 +43,43 @@ LL | | } | |_^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:41:5 + --> $DIR/missing-doc.rs:19:5 | LL | pub a: isize, | ^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:42:5 + --> $DIR/missing-doc.rs:20:5 | LL | b: isize, | ^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:51:1 + --> $DIR/missing-doc.rs:29:1 | LL | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:52:1 + --> $DIR/missing-doc.rs:30:1 | LL | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:56:1 + --> $DIR/missing-doc.rs:34:1 | LL | pub fn foo2() {} | ^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:57:1 + --> $DIR/missing-doc.rs:35:1 | LL | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for a trait - --> $DIR/missing-doc.rs:75:1 + --> $DIR/missing-doc.rs:53:1 | LL | / pub trait C { LL | | fn foo(&self); @@ -88,55 +88,55 @@ LL | | } | |_^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:76:5 + --> $DIR/missing-doc.rs:54:5 | LL | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:77:5 + --> $DIR/missing-doc.rs:55:5 | LL | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:87:5 + --> $DIR/missing-doc.rs:65:5 | LL | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:88:5 + --> $DIR/missing-doc.rs:66:5 | LL | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:99:5 + --> $DIR/missing-doc.rs:77:5 | LL | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:100:5 + --> $DIR/missing-doc.rs:78:5 | LL | fn bar() {} | ^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:104:5 + --> $DIR/missing-doc.rs:82:5 | LL | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:107:5 + --> $DIR/missing-doc.rs:85:5 | LL | fn foo2() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:134:1 + --> $DIR/missing-doc.rs:112:1 | LL | / enum Baz { LL | | BazA { a: isize, b: isize }, @@ -145,31 +145,31 @@ LL | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:135:5 + --> $DIR/missing-doc.rs:113:5 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:135:12 + --> $DIR/missing-doc.rs:113:12 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:135:22 + --> $DIR/missing-doc.rs:113:22 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:136:5 + --> $DIR/missing-doc.rs:114:5 | LL | BarB, | ^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:139:1 + --> $DIR/missing-doc.rs:117:1 | LL | / pub enum PubBaz { LL | | PubBazA { a: isize }, @@ -177,43 +177,43 @@ LL | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:140:5 + --> $DIR/missing-doc.rs:118:5 | LL | PubBazA { a: isize }, | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:140:15 + --> $DIR/missing-doc.rs:118:15 | LL | PubBazA { a: isize }, | ^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:160:1 + --> $DIR/missing-doc.rs:138:1 | LL | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:167:1 + --> $DIR/missing-doc.rs:145:1 | LL | pub const FOO4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:169:1 + --> $DIR/missing-doc.rs:147:1 | LL | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:176:1 + --> $DIR/missing-doc.rs:154:1 | LL | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:178:1 + --> $DIR/missing-doc.rs:156:1 | LL | / mod internal_impl { LL | | /// dox @@ -225,31 +225,31 @@ LL | | } | |_^ error: missing documentation for a function - --> $DIR/missing-doc.rs:181:5 + --> $DIR/missing-doc.rs:159:5 | LL | pub fn undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:182:5 + --> $DIR/missing-doc.rs:160:5 | LL | pub fn undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:183:5 + --> $DIR/missing-doc.rs:161:5 | LL | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:188:9 + --> $DIR/missing-doc.rs:166:9 | LL | pub fn also_undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:189:9 + --> $DIR/missing-doc.rs:167:9 | LL | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing_inline.rs b/tests/ui/missing_inline.rs index c9e946e14e6..2b2ea6c94c2 100644 --- a/tests/ui/missing_inline.rs +++ b/tests/ui/missing_inline.rs @@ -1,24 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* This file incorporates work covered by the following copyright and - * permission notice: - * Copyright 2013 The Rust Project Developers. See the COPYRIGHT - * file at the top-level directory of this distribution and at - * http://rust-lang.org/COPYRIGHT. - * - * Licensed under the Apache License, Version 2.0 or the MIT license - * , at your - * option. This file may not be copied, modified, or distributed - * except according to those terms. - */ #![warn(clippy::missing_inline_in_public_items)] #![crate_type = "dylib"] // When denying at the crate level, be sure to not get random warnings from the diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index efe9a3b1399..40b92b7647b 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,5 +1,5 @@ error: missing `#[inline]` for a function - --> $DIR/missing_inline.rs:40:1 + --> $DIR/missing_inline.rs:19:1 | LL | pub fn pub_foo() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^ @@ -7,31 +7,31 @@ LL | pub fn pub_foo() {} // missing #[inline] = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` error: missing `#[inline]` for a default trait method - --> $DIR/missing_inline.rs:56:5 + --> $DIR/missing_inline.rs:35:5 | LL | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:70:5 + --> $DIR/missing_inline.rs:49:5 | LL | fn PubBar_a() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:71:5 + --> $DIR/missing_inline.rs:50:5 | LL | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:72:5 + --> $DIR/missing_inline.rs:51:5 | LL | fn PubBar_c() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:82:5 + --> $DIR/missing_inline.rs:61:5 | LL | pub fn PubFooImpl() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/module_inception.rs b/tests/ui/module_inception.rs index 730055931c4..a23aba9164a 100644 --- a/tests/ui/module_inception.rs +++ b/tests/ui/module_inception.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::module_inception)] mod foo { diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index f4d4692e259..77564dce9eb 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,5 +1,5 @@ error: module has the same name as its containing module - --> $DIR/module_inception.rs:14:9 + --> $DIR/module_inception.rs:5:9 | LL | / mod bar { LL | | mod foo {} @@ -9,7 +9,7 @@ LL | | } = note: `-D clippy::module-inception` implied by `-D warnings` error: module has the same name as its containing module - --> $DIR/module_inception.rs:19:5 + --> $DIR/module_inception.rs:10:5 | LL | / mod foo { LL | | mod bar {} diff --git a/tests/ui/module_name_repetitions.rs b/tests/ui/module_name_repetitions.rs index 4db4f56de46..1719845cb21 100644 --- a/tests/ui/module_name_repetitions.rs +++ b/tests/ui/module_name_repetitions.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::module_name_repetitions)] #![allow(dead_code)] diff --git a/tests/ui/module_name_repetitions.stderr b/tests/ui/module_name_repetitions.stderr index 866156e3b74..5bce2c9ba60 100644 --- a/tests/ui/module_name_repetitions.stderr +++ b/tests/ui/module_name_repetitions.stderr @@ -1,5 +1,5 @@ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:15:5 + --> $DIR/module_name_repetitions.rs:6:5 | LL | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | pub fn foo_bar() {} = note: `-D clippy::module-name-repetitions` implied by `-D warnings` error: item name ends with its containing module's name - --> $DIR/module_name_repetitions.rs:16:5 + --> $DIR/module_name_repetitions.rs:7:5 | LL | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:17:5 + --> $DIR/module_name_repetitions.rs:8:5 | LL | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name - --> $DIR/module_name_repetitions.rs:18:5 + --> $DIR/module_name_repetitions.rs:9:5 | LL | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:19:5 + --> $DIR/module_name_repetitions.rs:10:5 | LL | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/modulo_one.rs b/tests/ui/modulo_one.rs index f7c0c16abad..81603175ab4 100644 --- a/tests/ui/modulo_one.rs +++ b/tests/ui/modulo_one.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::modulo_one)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 36f06c74077..a7feeb56ebc 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -1,5 +1,5 @@ error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:14:5 + --> $DIR/modulo_one.rs:5:5 | LL | 10 % 1; | ^^^^^^ diff --git a/tests/ui/mut_from_ref.rs b/tests/ui/mut_from_ref.rs index 8a9da42083d..8f9ed7ed637 100644 --- a/tests/ui/mut_from_ref.rs +++ b/tests/ui/mut_from_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused, clippy::trivially_copy_pass_by_ref)] #![warn(clippy::mut_from_ref)] diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index 544d1aa5f14..4787999920b 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -1,60 +1,60 @@ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:16:39 + --> $DIR/mut_from_ref.rs:7:39 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^^^^ | = note: `-D clippy::mut-from-ref` implied by `-D warnings` note: immutable borrow here - --> $DIR/mut_from_ref.rs:16:29 + --> $DIR/mut_from_ref.rs:7:29 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:22:25 + --> $DIR/mut_from_ref.rs:13:25 | LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:22:16 + --> $DIR/mut_from_ref.rs:13:16 | LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:31:21 + --> $DIR/mut_from_ref.rs:22:21 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:31:12 + --> $DIR/mut_from_ref.rs:22:12 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:35:50 + --> $DIR/mut_from_ref.rs:26:50 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:35:25 + --> $DIR/mut_from_ref.rs:26:25 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:39:67 + --> $DIR/mut_from_ref.rs:30:67 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:39:27 + --> $DIR/mut_from_ref.rs:30:27 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index e8239007cb3..8965cef66de 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] #![warn(clippy::mut_mut)] diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index ed926637563..6fa5dbfc29f 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,5 +1,5 @@ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:13:11 + --> $DIR/mut_mut.rs:4:11 | LL | fn fun(x: &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | fn fun(x: &mut &mut u32) -> bool { = note: `-D clippy::mut-mut` implied by `-D warnings` error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:29:17 + --> $DIR/mut_mut.rs:20:17 | LL | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:23:9 + --> $DIR/mut_mut.rs:14:9 | LL | &mut $p | ^^^^^^^ @@ -22,37 +22,37 @@ LL | let mut z = mut_ptr!(&mut 3u32); | ------------------- in this macro invocation error: this expression mutably borrows a mutable reference. Consider reborrowing - --> $DIR/mut_mut.rs:31:21 + --> $DIR/mut_mut.rs:22:21 | LL | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:35:32 + --> $DIR/mut_mut.rs:26:32 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:35:16 + --> $DIR/mut_mut.rs:26:16 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:37 + --> $DIR/mut_mut.rs:31:37 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:16 + --> $DIR/mut_mut.rs:31:16 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:21 + --> $DIR/mut_mut.rs:31:21 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ diff --git a/tests/ui/mut_range_bound.rs b/tests/ui/mut_range_bound.rs index 23dddcdd158..1348dd2a3d8 100644 --- a/tests/ui/mut_range_bound.rs +++ b/tests/ui/mut_range_bound.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] fn main() { diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index ce3ae6cb2a5..50e94efde53 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -1,5 +1,5 @@ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:25:9 + --> $DIR/mut_range_bound.rs:16:9 | LL | m = 5; | ^^^^^ @@ -7,25 +7,25 @@ LL | m = 5; = note: `-D clippy::mut-range-bound` implied by `-D warnings` error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:32:9 + --> $DIR/mut_range_bound.rs:23:9 | LL | m *= 2; | ^^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:40:9 + --> $DIR/mut_range_bound.rs:31:9 | LL | m = 5; | ^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:41:9 + --> $DIR/mut_range_bound.rs:32:9 | LL | n = 7; | ^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:55:22 + --> $DIR/mut_range_bound.rs:46:22 | LL | let n = &mut m; // warning | ^ diff --git a/tests/ui/mut_reference.rs b/tests/ui/mut_reference.rs index 882ed7e1dd3..c4379e0ea1c 100644 --- a/tests/ui/mut_reference.rs +++ b/tests/ui/mut_reference.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused_variables, clippy::trivially_copy_pass_by_ref)] fn takes_an_immutable_reference(a: &i32) {} diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 1fe31e26f6e..fa8c82ae0f3 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,5 +1,5 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:26:34 + --> $DIR/mut_reference.rs:17:34 | LL | takes_an_immutable_reference(&mut 42); | ^^^^^^^ @@ -7,13 +7,13 @@ LL | takes_an_immutable_reference(&mut 42); = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` error: The function/method `as_ptr` doesn't need a mutable reference - --> $DIR/mut_reference.rs:28:12 + --> $DIR/mut_reference.rs:19:12 | LL | as_ptr(&mut 42); | ^^^^^^^ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:32:44 + --> $DIR/mut_reference.rs:23:44 | LL | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ diff --git a/tests/ui/mutex_atomic.rs b/tests/ui/mutex_atomic.rs index 5c4e180408c..b9d78b7f479 100644 --- a/tests/ui/mutex_atomic.rs +++ b/tests/ui/mutex_atomic.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![warn(clippy::mutex_integer)] diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 77a05ca13f4..1b0f5c1571b 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,5 +1,5 @@ error: Consider using an AtomicBool instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:15:5 + --> $DIR/mutex_atomic.rs:6:5 | LL | Mutex::new(true); | ^^^^^^^^^^^^^^^^ @@ -7,31 +7,31 @@ LL | Mutex::new(true); = note: `-D clippy::mutex-atomic` implied by `-D warnings` error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:16:5 + --> $DIR/mutex_atomic.rs:7:5 | LL | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:17:5 + --> $DIR/mutex_atomic.rs:8:5 | LL | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:19:5 + --> $DIR/mutex_atomic.rs:10:5 | LL | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:20:5 + --> $DIR/mutex_atomic.rs:11:5 | LL | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:21:5 + --> $DIR/mutex_atomic.rs:12:5 | LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | Mutex::new(0u32); = note: `-D clippy::mutex-integer` implied by `-D warnings` error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:22:5 + --> $DIR/mutex_atomic.rs:13:5 | LL | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/needless_bool.rs b/tests/ui/needless_bool.rs index c82f102c294..75705525790 100644 --- a/tests/ui/needless_bool.rs +++ b/tests/ui/needless_bool.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::needless_bool)] use std::cell::Cell; @@ -150,3 +141,16 @@ fn needless_bool3(x: bool) { if x == true {}; if x == false {}; } + +fn needless_bool_in_the_suggestion_wraps_the_predicate_of_if_else_statement_in_brackets() { + let b = false; + let returns_bool = || false; + + let x = if b { + true + } else if returns_bool() { + false + } else { + true + }; +} diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index a0c4ae9561d..46734ea07a5 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression will always return true - --> $DIR/needless_bool.rs:40:5 + --> $DIR/needless_bool.rs:31:5 | LL | / if x { LL | | true @@ -11,7 +11,7 @@ LL | | }; = note: `-D clippy::needless-bool` implied by `-D warnings` error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:45:5 + --> $DIR/needless_bool.rs:36:5 | LL | / if x { LL | | false @@ -21,7 +21,7 @@ LL | | }; | |_____^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:50:5 + --> $DIR/needless_bool.rs:41:5 | LL | / if x { LL | | true @@ -31,7 +31,7 @@ LL | | }; | |_____^ help: you can reduce it to: `x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:55:5 + --> $DIR/needless_bool.rs:46:5 | LL | / if x { LL | | false @@ -41,7 +41,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:60:5 + --> $DIR/needless_bool.rs:51:5 | LL | / if x && y { LL | | false @@ -51,7 +51,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!(x && y)` error: this if-then-else expression will always return true - --> $DIR/needless_bool.rs:83:5 + --> $DIR/needless_bool.rs:74:5 | LL | / if x { LL | | return true; @@ -61,7 +61,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:92:5 + --> $DIR/needless_bool.rs:83:5 | LL | / if x { LL | | return false; @@ -71,7 +71,7 @@ LL | | }; | |_____^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:101:5 + --> $DIR/needless_bool.rs:92:5 | LL | / if x { LL | | return true; @@ -81,7 +81,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:110:5 + --> $DIR/needless_bool.rs:101:5 | LL | / if x && y { LL | | return true; @@ -91,7 +91,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:119:5 + --> $DIR/needless_bool.rs:110:5 | LL | / if x { LL | | return false; @@ -101,7 +101,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:128:5 + --> $DIR/needless_bool.rs:119:5 | LL | / if x && y { LL | | return false; @@ -111,7 +111,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:136:8 + --> $DIR/needless_bool.rs:127:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -119,22 +119,33 @@ LL | if x == true {}; = note: `-D clippy::bool-comparison` implied by `-D warnings` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool.rs:140:8 + --> $DIR/needless_bool.rs:131:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:150:8 + --> $DIR/needless_bool.rs:141:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool.rs:151:8 + --> $DIR/needless_bool.rs:142:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` -error: aborting due to 15 previous errors +error: this if-then-else expression returns a bool literal + --> $DIR/needless_bool.rs:151:12 + | +LL | } else if returns_bool() { + | ____________^ +LL | | false +LL | | } else { +LL | | true +LL | | }; + | |_____^ help: you can reduce it to: `{ !returns_bool() }` + +error: aborting due to 16 previous errors diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index bfc6e82cb55..a59254625dc 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::borrow::Cow; #[allow(clippy::trivially_copy_pass_by_ref)] diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index ace40665c0c..40744160f65 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,5 +1,5 @@ error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:22:15 + --> $DIR/needless_borrow.rs:13:15 | LL | let c = x(&&a); | ^^^ help: change this to: `&a` @@ -7,19 +7,19 @@ LL | let c = x(&&a); = note: `-D clippy::needless-borrow` implied by `-D warnings` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:29:17 + --> $DIR/needless_borrow.rs:20:17 | LL | if let Some(ref cake) = Some(&5) {} | ^^^^^^^^ help: change this to: `cake` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:36:15 + --> $DIR/needless_borrow.rs:27:15 | LL | 46 => &&a, | ^^^ help: change this to: `&a` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:58:34 + --> $DIR/needless_borrow.rs:49:34 | LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` @@ -27,13 +27,13 @@ LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:59:30 + --> $DIR/needless_borrow.rs:50:30 | LL | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:59:31 + --> $DIR/needless_borrow.rs:50:31 | LL | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ help: change this to: `a` diff --git a/tests/ui/needless_borrowed_ref.rs b/tests/ui/needless_borrowed_ref.rs index 3897c86f53a..968a9f354bc 100644 --- a/tests/ui/needless_borrowed_ref.rs +++ b/tests/ui/needless_borrowed_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::needless_borrowed_reference)] #[allow(unused_variables)] fn main() { diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index b7ea9499f38..1b8067f1d6d 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -1,5 +1,5 @@ error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:14:34 + --> $DIR/needless_borrowed_ref.rs:5:34 | LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` @@ -7,19 +7,19 @@ LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:19:17 + --> $DIR/needless_borrowed_ref.rs:10:17 | LL | if let Some(&ref v) = thingy { | ^^^^^^ help: try removing the `&ref` part and just keep: `v` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:48:27 + --> $DIR/needless_borrowed_ref.rs:39:27 | LL | (&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: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:48:38 + --> $DIR/needless_borrowed_ref.rs:39:38 | LL | (&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` diff --git a/tests/ui/needless_collect.rs b/tests/ui/needless_collect.rs index df449e3184f..d4815f60f51 100644 --- a/tests/ui/needless_collect.rs +++ b/tests/ui/needless_collect.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::collections::{BTreeSet, HashMap, HashSet}; #[warn(clippy::needless_collect)] diff --git a/tests/ui/needless_collect.stderr b/tests/ui/needless_collect.stderr index c4cb187c34e..684c501c5b5 100644 --- a/tests/ui/needless_collect.stderr +++ b/tests/ui/needless_collect.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:16:28 + --> $DIR/needless_collect.rs:7:28 | LL | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` @@ -7,19 +7,19 @@ LL | let len = sample.iter().collect::>().len(); = note: `-D clippy::needless-collect` implied by `-D warnings` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:17:21 + --> $DIR/needless_collect.rs:8:21 | LL | if sample.iter().collect::>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:20:27 + --> $DIR/needless_collect.rs:11:27 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.any(|&x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:21:34 + --> $DIR/needless_collect.rs:12:34 | LL | sample.iter().map(|x| (x, x)).collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` diff --git a/tests/ui/needless_continue.rs b/tests/ui/needless_continue.rs index 6d9b9499dce..8bb1ba6edb5 100644 --- a/tests/ui/needless_continue.rs +++ b/tests/ui/needless_continue.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - macro_rules! zero { ($x:expr) => { $x == 0 diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 60c853c18ad..763eaf3a70e 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -1,6 +1,6 @@ error: This else block is redundant. - --> $DIR/needless_continue.rs:36:16 + --> $DIR/needless_continue.rs:27:16 | LL | } else { | ________________^ @@ -37,7 +37,7 @@ LL | | } error: There is no need for an explicit `else` block for this `if` expression - --> $DIR/needless_continue.rs:51:9 + --> $DIR/needless_continue.rs:42:9 | LL | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { LL | | continue; diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index ec9df9fb3d3..427bce988bd 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::needless_pass_by_value)] #![allow( dead_code, diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index d9ce5909172..31f43bf16ba 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,5 +1,5 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:24:23 + --> $DIR/needless_pass_by_value.rs:15:23 | LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` @@ -7,25 +7,25 @@ LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec $DIR/needless_pass_by_value.rs:38:11 + --> $DIR/needless_pass_by_value.rs:29:11 | LL | 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:38:22 + --> $DIR/needless_pass_by_value.rs:29:22 | LL | 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:44:71 + --> $DIR/needless_pass_by_value.rs:35:71 | LL | 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:56:18 + --> $DIR/needless_pass_by_value.rs:47:18 | LL | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -36,13 +36,13 @@ LL | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:69:24 + --> $DIR/needless_pass_by_value.rs:60:24 | LL | 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:69:36 + --> $DIR/needless_pass_by_value.rs:60:36 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ @@ -55,19 +55,19 @@ LL | 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:85:49 + --> $DIR/needless_pass_by_value.rs:76:49 | LL | 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:87:18 + --> $DIR/needless_pass_by_value.rs:78:18 | LL | 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:87:29 + --> $DIR/needless_pass_by_value.rs:78:29 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ @@ -81,13 +81,13 @@ LL | let _ = t.to_string(); | ^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:87:40 + --> $DIR/needless_pass_by_value.rs:78:40 | LL | 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:87:53 + --> $DIR/needless_pass_by_value.rs:78:53 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ @@ -101,61 +101,61 @@ LL | let _ = v.to_owned(); | ^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:100:12 + --> $DIR/needless_pass_by_value.rs:91:12 | LL | 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:101:12 + --> $DIR/needless_pass_by_value.rs:92:12 | LL | 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:110:23 + --> $DIR/needless_pass_by_value.rs:101:23 | LL | fn baz(&self, _u: U, _s: Self) {} | ^ 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:110:30 + --> $DIR/needless_pass_by_value.rs:101:30 | LL | fn baz(&self, _u: U, _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:132:24 + --> $DIR/needless_pass_by_value.rs:123:24 | LL | 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:130:1 + --> $DIR/needless_pass_by_value.rs:121:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:138:29 + --> $DIR/needless_pass_by_value.rs:129:29 | LL | 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:130:1 + --> $DIR/needless_pass_by_value.rs:121:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:138:45 + --> $DIR/needless_pass_by_value.rs:129:45 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:130:1 + --> $DIR/needless_pass_by_value.rs:121:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -168,13 +168,13 @@ LL | 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:138:61 + --> $DIR/needless_pass_by_value.rs:129:61 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:130:1 + --> $DIR/needless_pass_by_value.rs:121:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -185,13 +185,13 @@ LL | let CopyWrapper(s) = *z; // moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:40 + --> $DIR/needless_pass_by_value.rs:141:40 | LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {} | ^ help: consider taking a reference instead: `&S` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:155:20 + --> $DIR/needless_pass_by_value.rs:146:20 | LL | fn more_fun(_item: impl Club<'static, i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` diff --git a/tests/ui/needless_pass_by_value_proc_macro.rs b/tests/ui/needless_pass_by_value_proc_macro.rs index 28f71d98fe7..3142210f9bf 100644 --- a/tests/ui/needless_pass_by_value_proc_macro.rs +++ b/tests/ui/needless_pass_by_value_proc_macro.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![crate_type = "proc-macro"] #![warn(clippy::needless_pass_by_value)] diff --git a/tests/ui/needless_range_loop.rs b/tests/ui/needless_range_loop.rs index f3d47eede48..a073cc0cfa3 100644 --- a/tests/ui/needless_range_loop.rs +++ b/tests/ui/needless_range_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn calc_idx(i: usize) -> usize { (i + i + 20) % 4 } diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index 73b1d9841eb..7044fc17617 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -1,5 +1,5 @@ error: the loop variable `i` is only used to index `ns`. - --> $DIR/needless_range_loop.rs:17:14 + --> $DIR/needless_range_loop.rs:8:14 | LL | for i in 3..10 { | ^^^^^ @@ -11,7 +11,7 @@ LL | for in ns.iter().take(10).skip(3) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `ms`. - --> $DIR/needless_range_loop.rs:38:14 + --> $DIR/needless_range_loop.rs:29:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | for in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `ms`. - --> $DIR/needless_range_loop.rs:44:14 + --> $DIR/needless_range_loop.rs:35:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | for in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/needless_range_loop.rs:68:14 + --> $DIR/needless_range_loop.rs:59:14 | LL | for i in x..x + 4 { | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | for in vec.iter_mut().skip(x).take(4) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/needless_range_loop.rs:75:14 + --> $DIR/needless_range_loop.rs:66:14 | LL | for i in x..=x + 4 { | ^^^^^^^^^ @@ -51,7 +51,7 @@ LL | for in vec.iter_mut().skip(x).take(4 + 1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:81:14 + --> $DIR/needless_range_loop.rs:72:14 | LL | for i in 0..3 { | ^^^^ @@ -61,7 +61,7 @@ LL | for in &arr { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:85:14 + --> $DIR/needless_range_loop.rs:76:14 | LL | for i in 0..2 { | ^^^^ @@ -71,7 +71,7 @@ LL | for in arr.iter().take(2) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:89:14 + --> $DIR/needless_range_loop.rs:80:14 | LL | for i in 1..3 { | ^^^^ diff --git a/tests/ui/needless_return.rs b/tests/ui/needless_return.rs index 101be5946f4..939233dbecb 100644 --- a/tests/ui/needless_return.rs +++ b/tests/ui/needless_return.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::needless_return)] fn test_end_of_fn() -> bool { diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index bf1083862ed..d7132ce4950 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -1,5 +1,5 @@ error: unneeded return statement - --> $DIR/needless_return.rs:17:5 + --> $DIR/needless_return.rs:8:5 | LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` @@ -7,43 +7,43 @@ LL | return true; = note: `-D clippy::needless-return` implied by `-D warnings` error: unneeded return statement - --> $DIR/needless_return.rs:21:5 + --> $DIR/needless_return.rs:12:5 | LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:26:9 + --> $DIR/needless_return.rs:17:9 | LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:28:9 + --> $DIR/needless_return.rs:19:9 | LL | return false; | ^^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:34:17 + --> $DIR/needless_return.rs:25:17 | LL | true => return false, | ^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:36:13 + --> $DIR/needless_return.rs:27:13 | LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:43:9 + --> $DIR/needless_return.rs:34:9 | LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:45:16 + --> $DIR/needless_return.rs:36:16 | LL | let _ = || return true; | ^^^^^^^^^^^ help: remove `return` as shown: `true` diff --git a/tests/ui/needless_update.rs b/tests/ui/needless_update.rs index 891c446b0ea..bfa005a19f9 100644 --- a/tests/ui/needless_update.rs +++ b/tests/ui/needless_update.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::needless_update)] #![allow(clippy::no_effect)] diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 6c4ea68771b..133c834880d 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,5 +1,5 @@ error: struct update has no effect, all the fields in the struct have already been specified - --> $DIR/needless_update.rs:22:23 + --> $DIR/needless_update.rs:13:23 | LL | S { a: 1, b: 1, ..base }; | ^^^^ diff --git a/tests/ui/neg_cmp_op_on_partial_ord.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index 6c132f85f0a..856a430ba2b 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.rs +++ b/tests/ui/neg_cmp_op_on_partial_ord.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! This test case utilizes `f64` an easy example for `PartialOrd` only types //! but the lint itself actually validates any expression where the left //! operand implements `PartialOrd` but not `Ord`. diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index f1df2b1d98a..d05fd34ce33 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,5 +1,5 @@ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:24:21 + --> $DIR/neg_cmp_op_on_partial_ord.rs:15:21 | LL | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,19 +7,19 @@ LL | let _not_less = !(a_value < another_value); = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:27:30 + --> $DIR/neg_cmp_op_on_partial_ord.rs:18:30 | LL | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:30:24 + --> $DIR/neg_cmp_op_on_partial_ord.rs:21:24 | LL | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:33:33 + --> $DIR/neg_cmp_op_on_partial_ord.rs:24:33 | LL | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs index f5f7525922c..d4a20ce9db1 100644 --- a/tests/ui/neg_multiply.rs +++ b/tests/ui/neg_multiply.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::neg_multiply)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 4c6d8e8d5dd..05554655451 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -1,5 +1,5 @@ error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:36:5 + --> $DIR/neg_multiply.rs:27:5 | LL | x * -1; | ^^^^^^ @@ -7,7 +7,7 @@ LL | x * -1; = note: `-D clippy::neg-multiply` implied by `-D warnings` error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:38:5 + --> $DIR/neg_multiply.rs:29:5 | LL | -1 * x; | ^^^^^^ diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index d5a108b0b27..abcec3e92f6 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( clippy::single_match, unused_assignments, diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 95b1a04e783..416e14d676e 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,5 +1,5 @@ error: this loop never actually loops - --> $DIR/never_loop.rs:19:5 + --> $DIR/never_loop.rs:10:5 | LL | / loop { LL | | // clippy::never_loop @@ -13,7 +13,7 @@ LL | | } = note: #[deny(clippy::never_loop)] on by default error: this loop never actually loops - --> $DIR/never_loop.rs:41:5 + --> $DIR/never_loop.rs:32:5 | LL | / loop { LL | | // never loops @@ -23,7 +23,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:61:5 + --> $DIR/never_loop.rs:52:5 | LL | / loop { LL | | // never loops @@ -35,7 +35,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:63:9 + --> $DIR/never_loop.rs:54:9 | LL | / while i == 0 { LL | | // never loops @@ -44,7 +44,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:75:9 + --> $DIR/never_loop.rs:66:9 | LL | / loop { LL | | // never loops @@ -56,7 +56,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:111:5 + --> $DIR/never_loop.rs:102:5 | LL | / while let Some(y) = x { LL | | // never loops @@ -65,7 +65,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:118:5 + --> $DIR/never_loop.rs:109:5 | LL | / for x in 0..10 { LL | | // never loops @@ -77,7 +77,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:166:5 + --> $DIR/never_loop.rs:157:5 | LL | / 'outer: while a { LL | | // never loops @@ -89,7 +89,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:181:9 + --> $DIR/never_loop.rs:172:9 | LL | / while false { LL | | break 'label; diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index 07d0a6bb05e..82aec070b40 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(const_fn)] #![allow(dead_code)] #![warn(clippy::new_without_default)] diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 9157f60a7e4..cd8e2837f08 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,5 +1,5 @@ error: you should consider deriving a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:17:5 + --> $DIR/new_without_default.rs:8:5 | LL | / pub fn new() -> Foo { LL | | Foo @@ -13,7 +13,7 @@ LL | #[derive(Default)] | error: you should consider deriving a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:25:5 + --> $DIR/new_without_default.rs:16:5 | LL | / pub fn new() -> Self { LL | | Bar @@ -25,7 +25,7 @@ LL | #[derive(Default)] | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:89:5 + --> $DIR/new_without_default.rs:80:5 | LL | / pub fn new() -> LtKo<'c> { LL | | unimplemented!() diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index 6b51c50dcde..8fbfcb79860 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(box_syntax)] #![warn(clippy::no_effect)] #![allow(dead_code)] diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index cc3b069f0b5..834b9056e31 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,5 +1,5 @@ error: statement with no effect - --> $DIR/no_effect.rs:74:5 + --> $DIR/no_effect.rs:65:5 | LL | 0; | ^^ @@ -7,145 +7,145 @@ LL | 0; = note: `-D clippy::no-effect` implied by `-D warnings` error: statement with no effect - --> $DIR/no_effect.rs:75:5 + --> $DIR/no_effect.rs:66:5 | LL | s2; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:76:5 + --> $DIR/no_effect.rs:67:5 | LL | Unit; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:77:5 + --> $DIR/no_effect.rs:68:5 | LL | Tuple(0); | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:78:5 + --> $DIR/no_effect.rs:69:5 | LL | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:79:5 + --> $DIR/no_effect.rs:70:5 | LL | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:80:5 + --> $DIR/no_effect.rs:71:5 | LL | Union { a: 0 }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:81:5 + --> $DIR/no_effect.rs:72:5 | LL | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:82:5 + --> $DIR/no_effect.rs:73:5 | LL | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:83:5 + --> $DIR/no_effect.rs:74:5 | LL | 5 + 6; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:84:5 + --> $DIR/no_effect.rs:75:5 | LL | *&42; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:85:5 + --> $DIR/no_effect.rs:76:5 | LL | &6; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:86:5 + --> $DIR/no_effect.rs:77:5 | LL | (5, 6, 7); | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:87:5 + --> $DIR/no_effect.rs:78:5 | LL | box 42; | ^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:88:5 + --> $DIR/no_effect.rs:79:5 | LL | ..; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:89:5 + --> $DIR/no_effect.rs:80:5 | LL | 5..; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:90:5 + --> $DIR/no_effect.rs:81:5 | LL | ..5; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:91:5 + --> $DIR/no_effect.rs:82:5 | LL | 5..6; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:93:5 + --> $DIR/no_effect.rs:84:5 | LL | [42, 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:94:5 + --> $DIR/no_effect.rs:85:5 | LL | [42, 55][1]; | ^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:95:5 + --> $DIR/no_effect.rs:86:5 | LL | (42, 55).1; | ^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:96:5 + --> $DIR/no_effect.rs:87:5 | LL | [42; 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:97:5 + --> $DIR/no_effect.rs:88:5 | LL | [42; 55][13]; | ^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:99:5 + --> $DIR/no_effect.rs:90:5 | LL | || x += 5; | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:101:5 + --> $DIR/no_effect.rs:92:5 | LL | FooString { s: s }; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/non_copy_const.rs b/tests/ui/non_copy_const.rs index 591e1994ee3..bd8b7521d14 100644 --- a/tests/ui/non_copy_const.rs +++ b/tests/ui/non_copy_const.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(const_string_new, const_vec_new)] #![allow(clippy::ref_in_deref, dead_code)] diff --git a/tests/ui/non_copy_const.stderr b/tests/ui/non_copy_const.stderr index 6b592b681c9..a9584ceb7ec 100644 --- a/tests/ui/non_copy_const.stderr +++ b/tests/ui/non_copy_const.stderr @@ -1,5 +1,5 @@ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:19:1 + --> $DIR/non_copy_const.rs:10:1 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable = note: #[deny(clippy::declare_interior_mutable_const)] on by default error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:20:1 + --> $DIR/non_copy_const.rs:11:1 | LL | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:21:1 + --> $DIR/non_copy_const.rs:12:1 | LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], V | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:26:9 + --> $DIR/non_copy_const.rs:17:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -34,49 +34,49 @@ LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable | ------------------------------------------ in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:50:5 + --> $DIR/non_copy_const.rs:41:5 | LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:54:5 + --> $DIR/non_copy_const.rs:45:5 | LL | const INPUT: T; | ^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:54:18 + --> $DIR/non_copy_const.rs:45:18 | LL | const INPUT: T; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:57:5 + --> $DIR/non_copy_const.rs:48:5 | LL | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:57:18 + --> $DIR/non_copy_const.rs:48:18 | LL | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:61:5 + --> $DIR/non_copy_const.rs:52:5 | LL | const AN_INPUT: T = Self::INPUT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:61:21 + --> $DIR/non_copy_const.rs:52:21 | LL | const AN_INPUT: T = Self::INPUT; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:26:9 + --> $DIR/non_copy_const.rs:17:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,49 +85,49 @@ LL | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior muta | ----------------------------------------------- in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:70:5 + --> $DIR/non_copy_const.rs:61:5 | LL | const SELF_2: Self; | ^^^^^^^^^^^^^^^^^^^ | help: consider requiring `Self` to be `Copy` - --> $DIR/non_copy_const.rs:70:19 + --> $DIR/non_copy_const.rs:61:19 | LL | const SELF_2: Self; | ^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:91:5 + --> $DIR/non_copy_const.rs:82:5 | LL | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:94:5 + --> $DIR/non_copy_const.rs:85:5 | LL | const U_SELF: U = U::SELF_2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `U` to be `Copy` - --> $DIR/non_copy_const.rs:94:19 + --> $DIR/non_copy_const.rs:85:19 | LL | const U_SELF: U = U::SELF_2; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:97:5 + --> $DIR/non_copy_const.rs:88:5 | LL | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:97:20 + --> $DIR/non_copy_const.rs:88:20 | LL | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^ error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:104:5 + --> $DIR/non_copy_const.rs:95:5 | LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^ @@ -136,7 +136,7 @@ LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:105:16 + --> $DIR/non_copy_const.rs:96:16 | LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability | ^^^^^^ @@ -144,7 +144,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutabi = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:107:5 + --> $DIR/non_copy_const.rs:98:5 | LL | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ @@ -152,7 +152,7 @@ LL | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutabi = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:108:16 + --> $DIR/non_copy_const.rs:99:16 | LL | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ @@ -160,7 +160,7 @@ LL | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR inte = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:111:22 + --> $DIR/non_copy_const.rs:102:22 | LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ @@ -168,7 +168,7 @@ LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:112:25 + --> $DIR/non_copy_const.rs:103:25 | LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ @@ -176,7 +176,7 @@ LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:113:27 + --> $DIR/non_copy_const.rs:104:27 | LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ @@ -184,7 +184,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:114:26 + --> $DIR/non_copy_const.rs:105:26 | LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ @@ -192,7 +192,7 @@ LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:125:14 + --> $DIR/non_copy_const.rs:116:14 | LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability | ^^^^^^^^^^^^ @@ -200,7 +200,7 @@ LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:126:14 + --> $DIR/non_copy_const.rs:117:14 | LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability | ^^^^^^^^^^^^ @@ -208,7 +208,7 @@ LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:127:19 + --> $DIR/non_copy_const.rs:118:19 | LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability | ^^^^^^^^^^^^ @@ -216,7 +216,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:128:14 + --> $DIR/non_copy_const.rs:119:14 | LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ @@ -224,7 +224,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:129:13 + --> $DIR/non_copy_const.rs:120:13 | LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^ @@ -232,7 +232,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mu = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:135:13 + --> $DIR/non_copy_const.rs:126:13 | LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ @@ -240,7 +240,7 @@ LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:140:5 + --> $DIR/non_copy_const.rs:131:5 | LL | CELL.set(2); //~ ERROR interior mutability | ^^^^ @@ -248,7 +248,7 @@ LL | CELL.set(2); //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:141:16 + --> $DIR/non_copy_const.rs:132:16 | LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability | ^^^^ @@ -256,7 +256,7 @@ LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:154:5 + --> $DIR/non_copy_const.rs:145:5 | LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^ @@ -264,7 +264,7 @@ LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:155:16 + --> $DIR/non_copy_const.rs:146:16 | LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability | ^^^^^^^^^^^ diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 86c9edc821d..b1d7d8e52a8 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all, clippy::similar_names)] #![allow(unused, clippy::println_empty_string)] diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 8729db18dff..f4274b87cdc 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,110 +1,110 @@ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:24:9 + --> $DIR/non_expressive_names.rs:15:9 | LL | let bpple: i32; | ^^^^^ | = note: `-D clippy::similar-names` implied by `-D warnings` note: existing binding defined here - --> $DIR/non_expressive_names.rs:22:9 + --> $DIR/non_expressive_names.rs:13:9 | LL | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `b_pple` - --> $DIR/non_expressive_names.rs:24:9 + --> $DIR/non_expressive_names.rs:15:9 | LL | let bpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:26:9 + --> $DIR/non_expressive_names.rs:17:9 | LL | let cpple: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:22:9 + --> $DIR/non_expressive_names.rs:13:9 | LL | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `c_pple` - --> $DIR/non_expressive_names.rs:26:9 + --> $DIR/non_expressive_names.rs:17:9 | LL | let cpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:50:9 + --> $DIR/non_expressive_names.rs:41:9 | LL | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:49:9 + --> $DIR/non_expressive_names.rs:40:9 | LL | let blubx: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `blub_y` - --> $DIR/non_expressive_names.rs:50:9 + --> $DIR/non_expressive_names.rs:41:9 | LL | let bluby: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:54:9 + --> $DIR/non_expressive_names.rs:45:9 | LL | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:52:9 + --> $DIR/non_expressive_names.rs:43:9 | LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:72:9 + --> $DIR/non_expressive_names.rs:63:9 | LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:70:9 + --> $DIR/non_expressive_names.rs:61:9 | LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:76:9 + --> $DIR/non_expressive_names.rs:67:9 | LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:74:9 + --> $DIR/non_expressive_names.rs:65:9 | LL | let parser: i32; | ^^^^^^ help: separate the discriminating character by an underscore like: `parse_e` - --> $DIR/non_expressive_names.rs:76:9 + --> $DIR/non_expressive_names.rs:67:9 | LL | let parsee: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:90:16 + --> $DIR/non_expressive_names.rs:81:16 | LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:89:16 + --> $DIR/non_expressive_names.rs:80:16 | LL | apple: spring, | ^^^^^^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:125:17 + --> $DIR/non_expressive_names.rs:116:17 | LL | let e: i32; | ^ @@ -112,25 +112,25 @@ LL | let e: i32; = note: `-D clippy::many-single-char-names` implied by `-D warnings` error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:128:17 + --> $DIR/non_expressive_names.rs:119:17 | LL | let e: i32; | ^ error: 6th binding whose name is just one char - --> $DIR/non_expressive_names.rs:129:17 + --> $DIR/non_expressive_names.rs:120:17 | LL | let f: i32; | ^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:133:13 + --> $DIR/non_expressive_names.rs:124:13 | LL | e => panic!(), | ^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:143:9 + --> $DIR/non_expressive_names.rs:134:9 | LL | let _1 = 1; //~ERROR Consider a more descriptive name | ^^ @@ -138,31 +138,31 @@ LL | let _1 = 1; //~ERROR Consider a more descriptive name = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:144:9 + --> $DIR/non_expressive_names.rs:135:9 | LL | let ____1 = 1; //~ERROR Consider a more descriptive name | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:145:9 + --> $DIR/non_expressive_names.rs:136:9 | LL | let __1___2 = 12; //~ERROR Consider a more descriptive name | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:165:13 + --> $DIR/non_expressive_names.rs:156:13 | LL | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:166:13 + --> $DIR/non_expressive_names.rs:157:13 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:167:13 + --> $DIR/non_expressive_names.rs:158:13 | LL | let __1___2 = 12; | ^^^^^^^ diff --git a/tests/ui/ok_expect.rs b/tests/ui/ok_expect.rs index b121aae788c..ff68d38c73b 100644 --- a/tests/ui/ok_expect.rs +++ b/tests/ui/ok_expect.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::io; struct MyError(()); // doesn't implement Debug diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index 4ccca10a463..99e62313183 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -1,5 +1,5 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:23:5 + --> $DIR/ok_expect.rs:14:5 | LL | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | res.ok().expect("disaster!"); = note: `-D clippy::ok-expect` implied by `-D warnings` error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:29:5 + --> $DIR/ok_expect.rs:20:5 | LL | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:31:5 + --> $DIR/ok_expect.rs:22:5 | LL | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:33:5 + --> $DIR/ok_expect.rs:24:5 | LL | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:35:5 + --> $DIR/ok_expect.rs:26:5 | LL | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/ok_if_let.rs b/tests/ui/ok_if_let.rs index 3ede64ce3aa..61db3113052 100644 --- a/tests/ui/ok_if_let.rs +++ b/tests/ui/ok_if_let.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::if_let_some_result)] fn str_to_int(x: &str) -> i32 { diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index 4567493a7c2..e3e6c5c4634 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -1,5 +1,5 @@ error: Matching on `Some` with `ok()` is redundant - --> $DIR/ok_if_let.rs:13:5 + --> $DIR/ok_if_let.rs:4:5 | LL | / if let Some(y) = x.parse().ok() { LL | | y diff --git a/tests/ui/op_ref.rs b/tests/ui/op_ref.rs index 1112b6794cf..bf43deca12c 100644 --- a/tests/ui/op_ref.rs +++ b/tests/ui/op_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused_variables, clippy::blacklisted_name)] use std::collections::HashSet; diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index 956e2ee754c..f5c5b970261 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -1,5 +1,5 @@ error: needlessly taken reference of both operands - --> $DIR/op_ref.rs:19:15 + --> $DIR/op_ref.rs:10:15 | LL | let foo = &5 - &6; | ^^^^^^^ @@ -11,7 +11,7 @@ LL | let foo = 5 - 6; | ^ ^ error: taken reference of right operand - --> $DIR/op_ref.rs:27:8 + --> $DIR/op_ref.rs:18:8 | LL | if b < &a { | ^^^^-- diff --git a/tests/ui/open_options.rs b/tests/ui/open_options.rs index f4d0af94b3f..9063fafbcd0 100644 --- a/tests/ui/open_options.rs +++ b/tests/ui/open_options.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::fs::OpenOptions; #[allow(unused_must_use)] diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 55c0429800b..addb0c4e1a5 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,5 +1,5 @@ error: file opened with "truncate" and "read" - --> $DIR/open_options.rs:15:5 + --> $DIR/open_options.rs:6:5 | LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,37 +7,37 @@ LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` error: file opened with "append" and "truncate" - --> $DIR/open_options.rs:16:5 + --> $DIR/open_options.rs:7:5 | LL | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "read" is called more than once - --> $DIR/open_options.rs:18:5 + --> $DIR/open_options.rs:9:5 | LL | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "create" is called more than once - --> $DIR/open_options.rs:19:5 + --> $DIR/open_options.rs:10:5 | LL | OpenOptions::new().create(true).create(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "write" is called more than once - --> $DIR/open_options.rs:20:5 + --> $DIR/open_options.rs:11:5 | LL | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "append" is called more than once - --> $DIR/open_options.rs:21:5 + --> $DIR/open_options.rs:12:5 | LL | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "truncate" is called more than once - --> $DIR/open_options.rs:22:5 + --> $DIR/open_options.rs:13:5 | LL | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/option_map_unit_fn.rs b/tests/ui/option_map_unit_fn.rs index db473f9b41e..1d2a3a17ee0 100644 --- a/tests/ui/option_map_unit_fn.rs +++ b/tests/ui/option_map_unit_fn.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::option_map_unit_fn)] #![allow(unused)] diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 18ddcec5edd..16e355ad0b2 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -1,5 +1,5 @@ error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:41:5 + --> $DIR/option_map_unit_fn.rs:32:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -9,7 +9,7 @@ LL | x.field.map(do_nothing); = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:43:5 + --> $DIR/option_map_unit_fn.rs:34:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | x.field.map(do_nothing); | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:45:5 + --> $DIR/option_map_unit_fn.rs:36:5 | LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- @@ -25,7 +25,7 @@ LL | x.field.map(diverge); | help: try this: `if let Some(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:51:5 + --> $DIR/option_map_unit_fn.rs:42:5 | LL | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -33,7 +33,7 @@ LL | x.field.map(|value| x.do_option_nothing(value + captured)); | help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:53:5 + --> $DIR/option_map_unit_fn.rs:44:5 | LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -41,7 +41,7 @@ LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:56:5 + --> $DIR/option_map_unit_fn.rs:47:5 | LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -49,7 +49,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:58:5 + --> $DIR/option_map_unit_fn.rs:49:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -57,7 +57,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:60:5 + --> $DIR/option_map_unit_fn.rs:51:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -65,7 +65,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:62:5 + --> $DIR/option_map_unit_fn.rs:53:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -73,7 +73,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:65:5 + --> $DIR/option_map_unit_fn.rs:56:5 | LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -81,7 +81,7 @@ LL | x.field.map(|value| diverge(value + captured)); | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:67:5 + --> $DIR/option_map_unit_fn.rs:58:5 | LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -89,7 +89,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:69:5 + --> $DIR/option_map_unit_fn.rs:60:5 | LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -97,7 +97,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:71:5 + --> $DIR/option_map_unit_fn.rs:62:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -105,7 +105,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:76:5 + --> $DIR/option_map_unit_fn.rs:67:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -113,7 +113,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:78:5 + --> $DIR/option_map_unit_fn.rs:69:5 | LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -121,7 +121,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:80:5 + --> $DIR/option_map_unit_fn.rs:71:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -129,7 +129,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:83:5 + --> $DIR/option_map_unit_fn.rs:74:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -137,7 +137,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:86:5 + --> $DIR/option_map_unit_fn.rs:77:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -145,7 +145,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:88:5 + --> $DIR/option_map_unit_fn.rs:79:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -153,7 +153,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:92:5 + --> $DIR/option_map_unit_fn.rs:83:5 | LL | x.field.map(|value| { | _____^ @@ -167,7 +167,7 @@ LL | || }); | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:96:5 + --> $DIR/option_map_unit_fn.rs:87:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -175,7 +175,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:99:5 + --> $DIR/option_map_unit_fn.rs:90:5 | LL | Some(42).map(diverge); | ^^^^^^^^^^^^^^^^^^^^^- @@ -183,7 +183,7 @@ LL | Some(42).map(diverge); | help: try this: `if let Some(_) = Some(42) { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:100:5 + --> $DIR/option_map_unit_fn.rs:91:5 | LL | "12".parse::().ok().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -191,7 +191,7 @@ LL | "12".parse::().ok().map(diverge); | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:101:5 + --> $DIR/option_map_unit_fn.rs:92:5 | LL | Some(plus_one(1)).map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -199,7 +199,7 @@ LL | Some(plus_one(1)).map(do_nothing); | help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:105:5 + --> $DIR/option_map_unit_fn.rs:96:5 | LL | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- diff --git a/tests/ui/option_option.rs b/tests/ui/option_option.rs index fcfd4e6ea56..e2e649a8108 100644 --- a/tests/ui/option_option.rs +++ b/tests/ui/option_option.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn input(_: Option>) {} fn output() -> Option> { diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 992f14c825f..9e9425cf954 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,5 +1,5 @@ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:10:13 + --> $DIR/option_option.rs:1:13 | LL | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ @@ -7,49 +7,49 @@ LL | fn input(_: Option>) {} = note: `-D clippy::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:12:16 + --> $DIR/option_option.rs:3:16 | LL | 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:16:27 + --> $DIR/option_option.rs:7:27 | LL | 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:21:30 + --> $DIR/option_option.rs:12:30 | LL | 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:26:8 + --> $DIR/option_option.rs:17:8 | LL | 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:30:23 + --> $DIR/option_option.rs:21:23 | LL | 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:36:22 + --> $DIR/option_option.rs:27:22 | LL | 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:40:11 + --> $DIR/option_option.rs:31:11 | LL | 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:41:17 + --> $DIR/option_option.rs:32:17 | LL | Struct { x: Option> }, | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/overflow_check_conditional.rs b/tests/ui/overflow_check_conditional.rs index a5cff3df9d7..84332040dba 100644 --- a/tests/ui/overflow_check_conditional.rs +++ b/tests/ui/overflow_check_conditional.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::many_single_char_names)] #![warn(clippy::overflow_check_conditional)] diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index 078a1a5941c..ad66135d326 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,5 +1,5 @@ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:17:8 + --> $DIR/overflow_check_conditional.rs:8:8 | LL | if a + b < a {} | ^^^^^^^^^ @@ -7,43 +7,43 @@ LL | if a + b < a {} = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:18:8 + --> $DIR/overflow_check_conditional.rs:9:8 | LL | if a > a + b {} | ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:19:8 + --> $DIR/overflow_check_conditional.rs:10:8 | LL | if a + b < b {} | ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:20:8 + --> $DIR/overflow_check_conditional.rs:11:8 | LL | if b > a + b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:21:8 + --> $DIR/overflow_check_conditional.rs:12:8 | LL | if a - b > b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:22:8 + --> $DIR/overflow_check_conditional.rs:13:8 | LL | if b < a - b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:23:8 + --> $DIR/overflow_check_conditional.rs:14:8 | LL | if a - b > a {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:24:8 + --> $DIR/overflow_check_conditional.rs:15:8 | LL | if a < a - b {} | ^^^^^^^^^ diff --git a/tests/ui/panic_unimplemented.rs b/tests/ui/panic_unimplemented.rs index 309a22dc215..a7c5b91fdb5 100644 --- a/tests/ui/panic_unimplemented.rs +++ b/tests/ui/panic_unimplemented.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::panic_params, clippy::unimplemented)] #![allow(clippy::assertions_on_constants::assertions_on_constants)] fn missing() { diff --git a/tests/ui/panic_unimplemented.stderr b/tests/ui/panic_unimplemented.stderr index 7bc83a287c1..588fa187b4a 100644 --- a/tests/ui/panic_unimplemented.stderr +++ b/tests/ui/panic_unimplemented.stderr @@ -1,5 +1,5 @@ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:14:16 + --> $DIR/panic_unimplemented.rs:5:16 | LL | panic!("{}"); | ^^^^ @@ -7,25 +7,25 @@ LL | panic!("{}"); = note: `-D clippy::panic-params` implied by `-D warnings` error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:16:16 + --> $DIR/panic_unimplemented.rs:7:16 | LL | panic!("{:?}"); | ^^^^^^ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:18:23 + --> $DIR/panic_unimplemented.rs:9:23 | LL | assert!(true, "here be missing values: {}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:21:12 + --> $DIR/panic_unimplemented.rs:12:12 | LL | panic!("{{{this}}}"); | ^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panic_unimplemented.rs:64:5 + --> $DIR/panic_unimplemented.rs:55:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/partialeq_ne_impl.rs b/tests/ui/partialeq_ne_impl.rs index e1e0413fcea..1338d3c74d5 100644 --- a/tests/ui/partialeq_ne_impl.rs +++ b/tests/ui/partialeq_ne_impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] struct Foo; diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index ac040acc306..b92da4511b4 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -1,5 +1,5 @@ error: re-implementing `PartialEq::ne` is unnecessary - --> $DIR/partialeq_ne_impl.rs:18:5 + --> $DIR/partialeq_ne_impl.rs:9:5 | LL | / fn ne(&self, _: &Foo) -> bool { LL | | false diff --git a/tests/ui/patterns.rs b/tests/ui/patterns.rs index e10afdb86b8..576e6c9ab92 100644 --- a/tests/ui/patterns.rs +++ b/tests/ui/patterns.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] #![warn(clippy::all)] diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index 74e8b9ae776..39dc034a014 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -1,5 +1,5 @@ error: the `y @ _` pattern can be written as just `y` - --> $DIR/patterns.rs:17:9 + --> $DIR/patterns.rs:8:9 | LL | y @ _ => (), | ^^^^^ diff --git a/tests/ui/precedence.fixed b/tests/ui/precedence.fixed new file mode 100644 index 00000000000..0ec85bc47e7 --- /dev/null +++ b/tests/ui/precedence.fixed @@ -0,0 +1,37 @@ +// run-rustfix +#![warn(clippy::precedence)] +#![allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)] +#![allow(clippy::identity_op)] +#![allow(clippy::eq_op)] + +macro_rules! trip { + ($a:expr) => { + match $a & 0b1111_1111u8 { + 0 => println!("a is zero ({})", $a), + _ => println!("a is {}", $a), + } + }; +} + +fn main() { + 1 << (2 + 3); + (1 + 2) << 3; + 4 >> (1 + 1); + (1 + 3) >> 2; + 1 ^ (1 - 1); + 3 | (2 - 1); + 3 & (5 - 2); + -(1i32.abs()); + -(1f32.abs()); + + // These should not trigger an error + let _ = (-1i32).abs(); + let _ = (-1f32).abs(); + let _ = -(1i32).abs(); + let _ = -(1f32).abs(); + let _ = -(1i32.abs()); + let _ = -(1f32.abs()); + + let b = 3; + trip!(b * 8); +} diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index 82009cd3873..4ef771c314f 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -1,19 +1,12 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[warn(clippy::precedence)] -#[allow(clippy::identity_op)] -#[allow(clippy::eq_op)] +// run-rustfix +#![warn(clippy::precedence)] +#![allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)] +#![allow(clippy::identity_op)] +#![allow(clippy::eq_op)] macro_rules! trip { ($a:expr) => { - match $a & 0b1111_1111i8 { + match $a & 0b1111_1111u8 { 0 => println!("a is zero ({})", $a), _ => println!("a is {}", $a), } diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 2d917b3cbdb..a2ed5392bfc 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,5 +1,5 @@ error: operator precedence can trip the unwary - --> $DIR/precedence.rs:24:5 + --> $DIR/precedence.rs:17:5 | LL | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` @@ -7,49 +7,49 @@ LL | 1 << 2 + 3; = note: `-D clippy::precedence` implied by `-D warnings` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:25:5 + --> $DIR/precedence.rs:18:5 | LL | 1 + 2 << 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:26:5 + --> $DIR/precedence.rs:19:5 | LL | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:27:5 + --> $DIR/precedence.rs:20:5 | LL | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:28:5 + --> $DIR/precedence.rs:21:5 | LL | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:29:5 + --> $DIR/precedence.rs:22:5 | LL | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:30:5 + --> $DIR/precedence.rs:23:5 | LL | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:31:5 + --> $DIR/precedence.rs:24:5 | LL | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:32:5 + --> $DIR/precedence.rs:25:5 | LL | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` diff --git a/tests/ui/print.rs b/tests/ui/print.rs index a43482cba62..366ccc2b3bd 100644 --- a/tests/ui/print.rs +++ b/tests/ui/print.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::print_literal, clippy::write_literal)] #![warn(clippy::print_stdout, clippy::use_debug)] diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 9635011b906..12c5a0bdaa0 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -1,5 +1,5 @@ error: use of `Debug`-based formatting - --> $DIR/print.rs:20:19 + --> $DIR/print.rs:11:19 | LL | write!(f, "{:?}", 43.1415) | ^^^^^^ @@ -7,13 +7,13 @@ LL | write!(f, "{:?}", 43.1415) = note: `-D clippy::use-debug` implied by `-D warnings` error: use of `Debug`-based formatting - --> $DIR/print.rs:27:19 + --> $DIR/print.rs:18:19 | LL | write!(f, "{:?}", 42.718) | ^^^^^^ error: use of `println!` - --> $DIR/print.rs:32:5 + --> $DIR/print.rs:23:5 | LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ @@ -21,37 +21,37 @@ LL | println!("Hello"); = note: `-D clippy::print-stdout` implied by `-D warnings` error: use of `print!` - --> $DIR/print.rs:33:5 + --> $DIR/print.rs:24:5 | LL | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:35:5 + --> $DIR/print.rs:26:5 | LL | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:37:5 + --> $DIR/print.rs:28:5 | LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:37:12 + --> $DIR/print.rs:28:12 | LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:39:5 + --> $DIR/print.rs:30:5 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:39:12 + --> $DIR/print.rs:30:12 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^ diff --git a/tests/ui/print_literal.rs b/tests/ui/print_literal.rs index 74756384067..40ed18e9302 100644 --- a/tests/ui/print_literal.rs +++ b/tests/ui/print_literal.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::print_literal)] fn main() { diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index be55795d1ac..fc502e9f71d 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:31:71 + --> $DIR/print_literal.rs:22:71 | LL | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ @@ -7,79 +7,79 @@ LL | println!("{} of {:b} people know binary, the other half doesn't", 1, 2) = note: `-D clippy::print-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/print_literal.rs:32:24 + --> $DIR/print_literal.rs:23:24 | LL | print!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:33:36 + --> $DIR/print_literal.rs:24:36 | LL | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:34:26 + --> $DIR/print_literal.rs:25:26 | LL | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:35:30 + --> $DIR/print_literal.rs:26:30 | LL | println!("10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:36:28 + --> $DIR/print_literal.rs:27:28 | LL | println!("2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/print_literal.rs:41:25 + --> $DIR/print_literal.rs:32:25 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:41:34 + --> $DIR/print_literal.rs:32:34 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:42:25 + --> $DIR/print_literal.rs:33:25 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:42:34 + --> $DIR/print_literal.rs:33:34 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:45:35 + --> $DIR/print_literal.rs:36:35 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:45:50 + --> $DIR/print_literal.rs:36:50 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:46:35 + --> $DIR/print_literal.rs:37:35 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:46:50 + --> $DIR/print_literal.rs:37:50 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs index 351fd60bc36..991cd7311e5 100644 --- a/tests/ui/print_with_newline.rs +++ b/tests/ui/print_with_newline.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::print_literal)] #![warn(clippy::print_with_newline)] diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 2d76e447145..a731212be87 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,5 +1,5 @@ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:14:5 + --> $DIR/print_with_newline.rs:5:5 | LL | print!("Hello/n"); | ^^^^^^^^^^^^^^^^^ @@ -7,19 +7,19 @@ LL | print!("Hello/n"); = note: `-D clippy::print-with-newline` implied by `-D warnings` error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:15:5 + --> $DIR/print_with_newline.rs:6:5 | LL | print!("Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:16:5 + --> $DIR/print_with_newline.rs:7:5 | LL | print!("Hello {} {}/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:17:5 + --> $DIR/print_with_newline.rs:8:5 | LL | print!("{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/println_empty_string.fixed b/tests/ui/println_empty_string.fixed index 4ca151453fe..4e84511d7b0 100644 --- a/tests/ui/println_empty_string.fixed +++ b/tests/ui/println_empty_string.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix fn main() { diff --git a/tests/ui/println_empty_string.rs b/tests/ui/println_empty_string.rs index 21f944916db..9fdfb03a366 100644 --- a/tests/ui/println_empty_string.rs +++ b/tests/ui/println_empty_string.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix fn main() { diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index 2370a3f1e28..689624a0fa0 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -1,5 +1,5 @@ error: using `println!("")` - --> $DIR/println_empty_string.rs:14:5 + --> $DIR/println_empty_string.rs:5:5 | LL | println!(""); | ^^^^^^^^^^^^ help: replace it with: `println!()` @@ -7,7 +7,7 @@ LL | println!(""); = note: `-D clippy::println-empty-string` implied by `-D warnings` error: using `println!("")` - --> $DIR/println_empty_string.rs:17:14 + --> $DIR/println_empty_string.rs:8:14 | LL | _ => println!(""), | ^^^^^^^^^^^^ help: replace it with: `println!()` diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index 0d7a829888e..1ce6081bf94 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused, clippy::many_single_char_names)] #![warn(clippy::ptr_arg)] diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index af5003c9b95..34516368e5e 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,5 +1,5 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:15:14 + --> $DIR/ptr_arg.rs:6:14 | LL | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` @@ -7,19 +7,19 @@ LL | fn do_vec(x: &Vec) { = note: `-D clippy::ptr-arg` implied by `-D warnings` error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:24:14 + --> $DIR/ptr_arg.rs:15:14 | LL | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:37:18 + --> $DIR/ptr_arg.rs:28:18 | LL | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:50:14 + --> $DIR/ptr_arg.rs:41:14 | LL | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ @@ -37,7 +37,7 @@ LL | x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:59:18 + --> $DIR/ptr_arg.rs:50:18 | LL | fn str_cloned(x: &String) -> String { | ^^^^^^^ @@ -59,7 +59,7 @@ LL | x.to_string() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:67:44 + --> $DIR/ptr_arg.rs:58:44 | LL | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ @@ -77,7 +77,7 @@ LL | let c = y; | ^ error: using a reference to `Cow` is not recommended. - --> $DIR/ptr_arg.rs:81:25 + --> $DIR/ptr_arg.rs:72:25 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` diff --git a/tests/ui/ptr_offset_with_cast.fixed b/tests/ui/ptr_offset_with_cast.fixed index c9f58896ae1..ebdd6c4003d 100644 --- a/tests/ui/ptr_offset_with_cast.fixed +++ b/tests/ui/ptr_offset_with_cast.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix fn main() { diff --git a/tests/ui/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs index 23eb4c6ce8a..3416c4b727a 100644 --- a/tests/ui/ptr_offset_with_cast.rs +++ b/tests/ui/ptr_offset_with_cast.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix fn main() { diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index 98e3ff92a6e..b5c7a03e277 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -1,5 +1,5 @@ error: use of `offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:21:9 + --> $DIR/ptr_offset_with_cast.rs:12:9 | LL | ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` @@ -7,7 +7,7 @@ LL | ptr.offset(offset_usize as isize); = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` error: use of `wrapping_offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:25:9 + --> $DIR/ptr_offset_with_cast.rs:16:9 | LL | ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs index 7e749d164ca..56ccf1d432f 100644 --- a/tests/ui/question_mark.rs +++ b/tests/ui/question_mark.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn some_func(a: Option) -> Option { if a.is_none() { return None; diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index a0b87813770..522501d58c6 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -1,5 +1,5 @@ error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:11:5 + --> $DIR/question_mark.rs:2:5 | LL | / if a.is_none() { LL | | return None; @@ -9,7 +9,7 @@ LL | | } = note: `-D clippy::question-mark` implied by `-D warnings` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:56:9 + --> $DIR/question_mark.rs:47:9 | LL | / if (self.opt).is_none() { LL | | return None; @@ -17,7 +17,7 @@ LL | | } | |_________^ help: replace_it_with: `(self.opt)?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:60:9 + --> $DIR/question_mark.rs:51:9 | LL | / if self.opt.is_none() { LL | | return None @@ -25,7 +25,7 @@ LL | | } | |_________^ help: replace_it_with: `self.opt?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:64:17 + --> $DIR/question_mark.rs:55:17 | LL | let _ = if self.opt.is_none() { | _________________^ @@ -36,7 +36,7 @@ LL | | }; | |_________^ help: replace_it_with: `Some(self.opt?)` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:81:9 + --> $DIR/question_mark.rs:72:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -44,7 +44,7 @@ LL | | } | |_________^ help: replace_it_with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:89:9 + --> $DIR/question_mark.rs:80:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -52,7 +52,7 @@ LL | | } | |_________^ help: replace_it_with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:97:9 + --> $DIR/question_mark.rs:88:9 | LL | / if self.opt.is_none() { LL | | return None; diff --git a/tests/ui/range.rs b/tests/ui/range.rs index 1eab67e20d0..d0c5cc93bd9 100644 --- a/tests/ui/range.rs +++ b/tests/ui/range.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - struct NotARange; impl NotARange { fn step_by(&self, _: u32) {} diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index b9a0a10c207..387d1f674cb 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,5 +1,5 @@ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:17:13 + --> $DIR/range.rs:8:13 | LL | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | let _ = (0..1).step_by(0); = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:21:13 + --> $DIR/range.rs:12:13 | LL | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:22:13 + --> $DIR/range.rs:13:13 | LL | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:25:13 + --> $DIR/range.rs:16:13 | LL | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: It is more idiomatic to use v1.iter().enumerate() - --> $DIR/range.rs:33:14 + --> $DIR/range.rs:24:14 | LL | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _x = v1.iter().zip(0..v1.len()); = note: `-D clippy::range-zip-with-len` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:37:13 + --> $DIR/range.rs:28:13 | LL | let _ = v1.iter().step_by(2 / 3); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/range_plus_minus_one.rs b/tests/ui/range_plus_minus_one.rs index d8c955ba73f..54aec853d3b 100644 --- a/tests/ui/range_plus_minus_one.rs +++ b/tests/ui/range_plus_minus_one.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn f() -> usize { 42 } diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index b1c93933ccc..9ebc22e1625 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,5 +1,5 @@ error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:19:14 + --> $DIR/range_plus_minus_one.rs:10:14 | LL | for _ in 0..3 + 1 {} | ^^^^^^^^ help: use: `0..=3` @@ -7,25 +7,25 @@ LL | for _ in 0..3 + 1 {} = note: `-D clippy::range-plus-one` implied by `-D warnings` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:22:14 + --> $DIR/range_plus_minus_one.rs:13:14 | LL | for _ in 0..1 + 5 {} | ^^^^^^^^ help: use: `0..=5` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:25:14 + --> $DIR/range_plus_minus_one.rs:16:14 | LL | for _ in 1..1 + 1 {} | ^^^^^^^^ help: use: `1..=1` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:31:14 + --> $DIR/range_plus_minus_one.rs:22:14 | LL | for _ in 0..(1 + f()) {} | ^^^^^^^^^^^^ help: use: `0..=f()` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:35:13 + --> $DIR/range_plus_minus_one.rs:26:13 | LL | let _ = ..=11 - 1; | ^^^^^^^^^ help: use: `..11` @@ -33,19 +33,19 @@ LL | let _ = ..=11 - 1; = note: `-D clippy::range-minus-one` implied by `-D warnings` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:36:13 + --> $DIR/range_plus_minus_one.rs:27:13 | LL | let _ = ..=(11 - 1); | ^^^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:37:13 + --> $DIR/range_plus_minus_one.rs:28:13 | LL | let _ = (1..11 + 1); | ^^^^^^^^^^^ help: use: `(1..=11)` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:38:13 + --> $DIR/range_plus_minus_one.rs:29:13 | LL | let _ = (f() + 1)..(f() + 1); | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs index 09d4d392725..6e9ad71e55b 100644 --- a/tests/ui/redundant_clone.rs +++ b/tests/ui/redundant_clone.rs @@ -1,12 +1,3 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::redundant_clone)] use std::ffi::OsString; diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index aef6b9b3d2f..c8f6cacab2b 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -1,120 +1,120 @@ error: redundant clone - --> $DIR/redundant_clone.rs:16:41 + --> $DIR/redundant_clone.rs:7:41 | LL | let _ = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^ help: remove this | = note: `-D clippy::redundant-clone` implied by `-D warnings` note: this value is dropped without further use - --> $DIR/redundant_clone.rs:16:13 + --> $DIR/redundant_clone.rs:7:13 | LL | let _ = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:19:14 + --> $DIR/redundant_clone.rs:10:14 | LL | let _ = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:19:13 + --> $DIR/redundant_clone.rs:10:13 | LL | let _ = s.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:22:14 + --> $DIR/redundant_clone.rs:13:14 | LL | let _ = s.to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:22:13 + --> $DIR/redundant_clone.rs:13:13 | LL | let _ = s.to_string(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:25:14 + --> $DIR/redundant_clone.rs:16:14 | LL | let _ = s.to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:25:13 + --> $DIR/redundant_clone.rs:16:13 | LL | let _ = s.to_owned(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:27:41 + --> $DIR/redundant_clone.rs:18:41 | LL | let _ = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:27:13 + --> $DIR/redundant_clone.rs:18:13 | LL | let _ = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:29:41 + --> $DIR/redundant_clone.rs:20:41 | LL | let _ = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:29:13 + --> $DIR/redundant_clone.rs:20:13 | LL | let _ = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:31:28 + --> $DIR/redundant_clone.rs:22:28 | LL | let _ = OsString::new().to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:31:13 + --> $DIR/redundant_clone.rs:22:13 | LL | let _ = OsString::new().to_owned(); | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:33:28 + --> $DIR/redundant_clone.rs:24:28 | LL | let _ = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:33:13 + --> $DIR/redundant_clone.rs:24:13 | LL | let _ = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:40:18 + --> $DIR/redundant_clone.rs:31:18 | LL | let _ = tup.0.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:40:13 + --> $DIR/redundant_clone.rs:31:13 | LL | let _ = tup.0.clone(); | ^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:50:22 + --> $DIR/redundant_clone.rs:41:22 | LL | (a.clone(), a.clone()) | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:50:21 + --> $DIR/redundant_clone.rs:41:21 | LL | (a.clone(), a.clone()) | ^ diff --git a/tests/ui/redundant_closure_call.rs b/tests/ui/redundant_closure_call.rs index 46c56922974..2304871f213 100644 --- a/tests/ui/redundant_closure_call.rs +++ b/tests/ui/redundant_closure_call.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::redundant_closure_call)] fn main() { diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 6a41a07bd95..9c827fd8f17 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -1,5 +1,5 @@ error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:21:5 + --> $DIR/redundant_closure_call.rs:12:5 | LL | i = closure(); | ^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | i = closure(); = note: `-D clippy::redundant-closure-call` implied by `-D warnings` error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:24:5 + --> $DIR/redundant_closure_call.rs:15:5 | LL | i = closure(3); | ^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:13:13 + --> $DIR/redundant_closure_call.rs:4:13 | LL | let a = (|| 42)(); | ^^^^^^^^^ help: Try doing something like: : `42` error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:16:17 + --> $DIR/redundant_closure_call.rs:7:17 | LL | let mut k = (|m| m + 1)(i); | ^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:18:9 + --> $DIR/redundant_closure_call.rs:9:9 | LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_field_names.fixed b/tests/ui/redundant_field_names.fixed new file mode 100644 index 00000000000..5b4b8eeedd4 --- /dev/null +++ b/tests/ui/redundant_field_names.fixed @@ -0,0 +1,71 @@ +// run-rustfix +#![warn(clippy::redundant_field_names)] +#![allow(clippy::no_effect, dead_code, unused_variables)] + +#[macro_use] +extern crate derive_new; + +use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive}; + +mod foo { + pub const BAR: u8 = 0; +} + +struct Person { + gender: u8, + age: u8, + name: u8, + buzz: u64, + foo: u8, +} + +#[derive(new)] +pub struct S { + v: String, +} + +fn main() { + let gender: u8 = 42; + let age = 0; + let fizz: u64 = 0; + let name: u8 = 0; + + let me = Person { + gender, + age, + + name, //should be ok + buzz: fizz, //should be ok + foo: foo::BAR, //should be ok + }; + + // Range expressions + let (start, end) = (0, 0); + + let _ = start..; + let _ = ..end; + let _ = start..end; + + let _ = ..=end; + let _ = start..=end; + + // Issue #2799 + let _: Vec<_> = (start..end).collect(); + + // hand-written Range family structs are linted + let _ = RangeFrom { start }; + let _ = RangeTo { end }; + let _ = Range { start, end }; + let _ = RangeInclusive::new(start, end); + let _ = RangeToInclusive { end }; +} + +fn issue_3476() { + fn foo() {} + + struct S { + foo: fn(), + } + + S { foo: foo:: }; +} diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index 60569372e5d..3f97b80c568 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -1,15 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![warn(clippy::redundant_field_names)] -#![allow(unused_variables)] -#![feature(inclusive_range, inclusive_range_fields, inclusive_range_methods)] +#![allow(clippy::no_effect, dead_code, unused_variables)] #[macro_use] extern crate derive_new; diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 5675f8beb7a..7976292df22 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,5 +1,5 @@ error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:43:9 + --> $DIR/redundant_field_names.rs:34:9 | LL | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` @@ -7,37 +7,37 @@ LL | gender: gender, = note: `-D clippy::redundant-field-names` implied by `-D warnings` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:44:9 + --> $DIR/redundant_field_names.rs:35:9 | LL | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:65:25 + --> $DIR/redundant_field_names.rs:56:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:66:23 + --> $DIR/redundant_field_names.rs:57:23 | LL | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:67:21 + --> $DIR/redundant_field_names.rs:58:21 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:67:35 + --> $DIR/redundant_field_names.rs:58:35 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:69:32 + --> $DIR/redundant_field_names.rs:60:32 | LL | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` diff --git a/tests/ui/redundant_pattern_matching.rs b/tests/ui/redundant_pattern_matching.rs index 3744695a535..8e8d4b59ba4 100644 --- a/tests/ui/redundant_pattern_matching.rs +++ b/tests/ui/redundant_pattern_matching.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] diff --git a/tests/ui/redundant_pattern_matching.stderr b/tests/ui/redundant_pattern_matching.stderr index 0511fbc7e09..baed95d6f2e 100644 --- a/tests/ui/redundant_pattern_matching.stderr +++ b/tests/ui/redundant_pattern_matching.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:14:12 + --> $DIR/redundant_pattern_matching.rs:5:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^------------------------ help: try this: `if Ok::(42).is_ok()` @@ -7,25 +7,25 @@ LL | if let Ok(_) = Ok::(42) {} = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:16:12 + --> $DIR/redundant_pattern_matching.rs:7:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^------------------------- help: try this: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching.rs:18:12 + --> $DIR/redundant_pattern_matching.rs:9:12 | LL | if let None = None::<()> {} | -------^^^^---------------- help: try this: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching.rs:20:12 + --> $DIR/redundant_pattern_matching.rs:11:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^-------------- help: try this: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:34:5 + --> $DIR/redundant_pattern_matching.rs:25:5 | LL | / match Ok::(42) { LL | | Ok(_) => true, @@ -34,7 +34,7 @@ LL | | }; | |_____^ help: try this: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:39:5 + --> $DIR/redundant_pattern_matching.rs:30:5 | LL | / match Ok::(42) { LL | | Ok(_) => false, @@ -43,7 +43,7 @@ LL | | }; | |_____^ help: try this: `Ok::(42).is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:44:5 + --> $DIR/redundant_pattern_matching.rs:35:5 | LL | / match Err::(42) { LL | | Ok(_) => false, @@ -52,7 +52,7 @@ LL | | }; | |_____^ help: try this: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:49:5 + --> $DIR/redundant_pattern_matching.rs:40:5 | LL | / match Err::(42) { LL | | Ok(_) => true, @@ -61,7 +61,7 @@ LL | | }; | |_____^ help: try this: `Err::(42).is_ok()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching.rs:54:5 + --> $DIR/redundant_pattern_matching.rs:45:5 | LL | / match Some(42) { LL | | Some(_) => true, @@ -70,7 +70,7 @@ LL | | }; | |_____^ help: try this: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching.rs:59:5 + --> $DIR/redundant_pattern_matching.rs:50:5 | LL | / match None::<()> { LL | | Some(_) => false, diff --git a/tests/ui/reference.rs b/tests/ui/reference.rs index bab0c21ffd9..c63997fa858 100644 --- a/tests/ui/reference.rs +++ b/tests/ui/reference.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn get_number() -> usize { 10 } diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index eaaacc7bcbe..aea95a7fa9f 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -1,5 +1,5 @@ error: immediately dereferencing a reference - --> $DIR/reference.rs:25:13 + --> $DIR/reference.rs:16:13 | LL | let b = *&a; | ^^^ help: try this: `a` @@ -7,61 +7,61 @@ LL | let b = *&a; = note: `-D clippy::deref-addrof` implied by `-D warnings` error: immediately dereferencing a reference - --> $DIR/reference.rs:27:13 + --> $DIR/reference.rs:18:13 | LL | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try this: `get_number()` error: immediately dereferencing a reference - --> $DIR/reference.rs:32:13 + --> $DIR/reference.rs:23:13 | LL | let b = *&bytes[1..2][0]; | ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]` error: immediately dereferencing a reference - --> $DIR/reference.rs:36:13 + --> $DIR/reference.rs:27:13 | LL | let b = *&(a); | ^^^^^ help: try this: `(a)` error: immediately dereferencing a reference - --> $DIR/reference.rs:38:13 + --> $DIR/reference.rs:29:13 | LL | let b = *(&a); | ^^^^^ help: try this: `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:41:13 + --> $DIR/reference.rs:32:13 | LL | let b = *((&a)); | ^^^^^^^ help: try this: `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:43:13 + --> $DIR/reference.rs:34:13 | LL | let b = *&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:45:14 + --> $DIR/reference.rs:36:14 | LL | let b = **&aref; | ^^^^^^ help: try this: `aref` error: immediately dereferencing a reference - --> $DIR/reference.rs:49:14 + --> $DIR/reference.rs:40:14 | LL | let b = **&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:53:17 + --> $DIR/reference.rs:44:17 | LL | let y = *&mut x; | ^^^^^^^ help: try this: `x` error: immediately dereferencing a reference - --> $DIR/reference.rs:60:18 + --> $DIR/reference.rs:51:18 | LL | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index 2d9c3482850..b523fa5b711 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused)] #![warn(clippy::invalid_regex, clippy::trivial_regex, clippy::regex_macro)] diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index b6a4f6eb2af..1394a9b63bc 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -1,5 +1,5 @@ error: trivial regex - --> $DIR/regex.rs:22:45 + --> $DIR/regex.rs:13:45 | LL | let pipe_in_wrong_position = Regex::new("|"); | ^^^ @@ -8,7 +8,7 @@ LL | let pipe_in_wrong_position = Regex::new("|"); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:23:60 + --> $DIR/regex.rs:14:60 | LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ @@ -16,7 +16,7 @@ LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); = help: the regex is unlikely to be useful as it is error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:24:42 + --> $DIR/regex.rs:15:42 | LL | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ @@ -24,19 +24,19 @@ LL | let wrong_char_ranice = Regex::new("[z-a]"); = note: `-D clippy::invalid-regex` implied by `-D warnings` error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:25:37 + --> $DIR/regex.rs:16:37 | LL | let some_unicode = Regex::new("[é-è]"); | ^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:27:33 + --> $DIR/regex.rs:18:33 | LL | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: trivial regex - --> $DIR/regex.rs:29:53 + --> $DIR/regex.rs:20:53 | LL | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ @@ -44,43 +44,43 @@ LL | let binary_pipe_in_wrong_position = BRegex::new("|"); = help: the regex is unlikely to be useful as it is error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:30:41 + --> $DIR/regex.rs:21:41 | LL | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:31:56 + --> $DIR/regex.rs:22:56 | LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:43:37 + --> $DIR/regex.rs:34:37 | LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:44:39 + --> $DIR/regex.rs:35:39 | LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); | ^^^^^^^^^^^^^ error: regex syntax error: unrecognized escape sequence - --> $DIR/regex.rs:46:45 + --> $DIR/regex.rs:37:45 | LL | let raw_string_error = Regex::new(r"[...//...]"); | ^^ error: regex syntax error: unrecognized escape sequence - --> $DIR/regex.rs:47:46 + --> $DIR/regex.rs:38:46 | LL | let raw_string_error = Regex::new(r#"[...//...]"#); | ^^ error: trivial regex - --> $DIR/regex.rs:51:33 + --> $DIR/regex.rs:42:33 | LL | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | let trivial_eq = Regex::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:53:48 + --> $DIR/regex.rs:44:48 | LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ @@ -96,7 +96,7 @@ LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:55:42 + --> $DIR/regex.rs:46:42 | LL | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ @@ -104,7 +104,7 @@ LL | let trivial_starts_with = Regex::new("^foobar"); = help: consider using `str::starts_with` error: trivial regex - --> $DIR/regex.rs:57:40 + --> $DIR/regex.rs:48:40 | LL | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ @@ -112,7 +112,7 @@ LL | let trivial_ends_with = Regex::new("foobar$"); = help: consider using `str::ends_with` error: trivial regex - --> $DIR/regex.rs:59:39 + --> $DIR/regex.rs:50:39 | LL | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ @@ -120,7 +120,7 @@ LL | let trivial_contains = Regex::new("foobar"); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:61:39 + --> $DIR/regex.rs:52:39 | LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ @@ -128,7 +128,7 @@ LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:63:40 + --> $DIR/regex.rs:54:40 | LL | let trivial_backslash = Regex::new("a/.b"); | ^^^^^^^ @@ -136,7 +136,7 @@ LL | let trivial_backslash = Regex::new("a/.b"); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:66:36 + --> $DIR/regex.rs:57:36 | LL | let trivial_empty = Regex::new(""); | ^^ @@ -144,7 +144,7 @@ LL | let trivial_empty = Regex::new(""); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:68:36 + --> $DIR/regex.rs:59:36 | LL | let trivial_empty = Regex::new("^"); | ^^^ @@ -152,7 +152,7 @@ LL | let trivial_empty = Regex::new("^"); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:70:36 + --> $DIR/regex.rs:61:36 | LL | let trivial_empty = Regex::new("^$"); | ^^^^ @@ -160,7 +160,7 @@ LL | let trivial_empty = Regex::new("^$"); = help: consider using `str::is_empty` error: trivial regex - --> $DIR/regex.rs:72:44 + --> $DIR/regex.rs:63:44 | LL | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs index eb08f1de63d..bd916fa7196 100644 --- a/tests/ui/rename.rs +++ b/tests/ui/rename.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(stutter)] #[warn(clippy::stutter)] diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index 074e3527e8a..58d2c98f890 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -1,5 +1,5 @@ error: unknown lint: `stutter` - --> $DIR/rename.rs:10:10 + --> $DIR/rename.rs:1:10 | LL | #![allow(stutter)] | ^^^^^^^ @@ -7,7 +7,7 @@ LL | #![allow(stutter)] = note: `-D unknown-lints` implied by `-D warnings` error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` - --> $DIR/rename.rs:12:8 + --> $DIR/rename.rs:3:8 | LL | #[warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` @@ -15,7 +15,7 @@ LL | #[warn(clippy::stutter)] = note: `-D renamed-and-removed-lints` implied by `-D warnings` error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` - --> $DIR/rename.rs:15:8 + --> $DIR/rename.rs:6:8 | LL | #[warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` diff --git a/tests/ui/replace_consts.fixed b/tests/ui/replace_consts.fixed new file mode 100644 index 00000000000..96a1281e478 --- /dev/null +++ b/tests/ui/replace_consts.fixed @@ -0,0 +1,100 @@ +// run-rustfix +#![feature(integer_atomics)] +#![allow(unused_variables, clippy::blacklisted_name)] +#![deny(clippy::replace_consts)] + +use std::sync::atomic::*; +use std::sync::{Once, ONCE_INIT}; + +#[rustfmt::skip] +fn bad() { + // Once + { let foo = ONCE_INIT; }; + // Atomic + { let foo = AtomicBool::new(false); }; + { let foo = AtomicIsize::new(0); }; + { let foo = AtomicI8::new(0); }; + { let foo = AtomicI16::new(0); }; + { let foo = AtomicI32::new(0); }; + { let foo = AtomicI64::new(0); }; + { let foo = AtomicUsize::new(0); }; + { let foo = AtomicU8::new(0); }; + { let foo = AtomicU16::new(0); }; + { let foo = AtomicU32::new(0); }; + { let foo = AtomicU64::new(0); }; + // Min + { let foo = isize::min_value(); }; + { let foo = i8::min_value(); }; + { let foo = i16::min_value(); }; + { let foo = i32::min_value(); }; + { let foo = i64::min_value(); }; + { let foo = i128::min_value(); }; + { let foo = usize::min_value(); }; + { let foo = u8::min_value(); }; + { let foo = u16::min_value(); }; + { let foo = u32::min_value(); }; + { let foo = u64::min_value(); }; + { let foo = u128::min_value(); }; + // Max + { let foo = isize::max_value(); }; + { let foo = i8::max_value(); }; + { let foo = i16::max_value(); }; + { let foo = i32::max_value(); }; + { let foo = i64::max_value(); }; + { let foo = i128::max_value(); }; + { let foo = usize::max_value(); }; + { let foo = u8::max_value(); }; + { let foo = u16::max_value(); }; + { let foo = u32::max_value(); }; + { let foo = u64::max_value(); }; + { let foo = u128::max_value(); }; +} + +#[rustfmt::skip] +fn good() { + // Once + { let foo = Once::new(); }; + // Atomic + { let foo = AtomicBool::new(false); }; + { let foo = AtomicIsize::new(0); }; + { let foo = AtomicI8::new(0); }; + { let foo = AtomicI16::new(0); }; + { let foo = AtomicI32::new(0); }; + { let foo = AtomicI64::new(0); }; + { let foo = AtomicUsize::new(0); }; + { let foo = AtomicU8::new(0); }; + { let foo = AtomicU16::new(0); }; + { let foo = AtomicU32::new(0); }; + { let foo = AtomicU64::new(0); }; + // Min + { let foo = isize::min_value(); }; + { let foo = i8::min_value(); }; + { let foo = i16::min_value(); }; + { let foo = i32::min_value(); }; + { let foo = i64::min_value(); }; + { let foo = i128::min_value(); }; + { let foo = usize::min_value(); }; + { let foo = u8::min_value(); }; + { let foo = u16::min_value(); }; + { let foo = u32::min_value(); }; + { let foo = u64::min_value(); }; + { let foo = u128::min_value(); }; + // Max + { let foo = isize::max_value(); }; + { let foo = i8::max_value(); }; + { let foo = i16::max_value(); }; + { let foo = i32::max_value(); }; + { let foo = i64::max_value(); }; + { let foo = i128::max_value(); }; + { let foo = usize::max_value(); }; + { let foo = u8::max_value(); }; + { let foo = u16::max_value(); }; + { let foo = u32::max_value(); }; + { let foo = u64::max_value(); }; + { let foo = u128::max_value(); }; +} + +fn main() { + bad(); + good(); +} diff --git a/tests/ui/replace_consts.rs b/tests/ui/replace_consts.rs index ca3d3b13edc..b61293cc6e9 100644 --- a/tests/ui/replace_consts.rs +++ b/tests/ui/replace_consts.rs @@ -1,14 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![feature(integer_atomics)] -#![allow(clippy::blacklisted_name)] +#![allow(unused_variables, clippy::blacklisted_name)] #![deny(clippy::replace_consts)] use std::sync::atomic::*; diff --git a/tests/ui/replace_consts.stderr b/tests/ui/replace_consts.stderr index e45f490463c..6f2155406cd 100644 --- a/tests/ui/replace_consts.stderr +++ b/tests/ui/replace_consts.stderr @@ -1,215 +1,215 @@ error: using `ATOMIC_BOOL_INIT` - --> $DIR/replace_consts.rs:22:17 + --> $DIR/replace_consts.rs:14:17 | LL | { let foo = ATOMIC_BOOL_INIT; }; | ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)` | note: lint level defined here - --> $DIR/replace_consts.rs:12:9 + --> $DIR/replace_consts.rs:4:9 | LL | #![deny(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ error: using `ATOMIC_ISIZE_INIT` - --> $DIR/replace_consts.rs:23:17 + --> $DIR/replace_consts.rs:15:17 | LL | { let foo = ATOMIC_ISIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)` error: using `ATOMIC_I8_INIT` - --> $DIR/replace_consts.rs:24:17 + --> $DIR/replace_consts.rs:16:17 | LL | { let foo = ATOMIC_I8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)` error: using `ATOMIC_I16_INIT` - --> $DIR/replace_consts.rs:25:17 + --> $DIR/replace_consts.rs:17:17 | LL | { let foo = ATOMIC_I16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)` error: using `ATOMIC_I32_INIT` - --> $DIR/replace_consts.rs:26:17 + --> $DIR/replace_consts.rs:18:17 | LL | { let foo = ATOMIC_I32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)` error: using `ATOMIC_I64_INIT` - --> $DIR/replace_consts.rs:27:17 + --> $DIR/replace_consts.rs:19:17 | LL | { let foo = ATOMIC_I64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)` error: using `ATOMIC_USIZE_INIT` - --> $DIR/replace_consts.rs:28:17 + --> $DIR/replace_consts.rs:20:17 | LL | { let foo = ATOMIC_USIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)` error: using `ATOMIC_U8_INIT` - --> $DIR/replace_consts.rs:29:17 + --> $DIR/replace_consts.rs:21:17 | LL | { let foo = ATOMIC_U8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)` error: using `ATOMIC_U16_INIT` - --> $DIR/replace_consts.rs:30:17 + --> $DIR/replace_consts.rs:22:17 | LL | { let foo = ATOMIC_U16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)` error: using `ATOMIC_U32_INIT` - --> $DIR/replace_consts.rs:31:17 + --> $DIR/replace_consts.rs:23:17 | LL | { let foo = ATOMIC_U32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)` error: using `ATOMIC_U64_INIT` - --> $DIR/replace_consts.rs:32:17 + --> $DIR/replace_consts.rs:24:17 | LL | { let foo = ATOMIC_U64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` error: using `MIN` - --> $DIR/replace_consts.rs:34:17 + --> $DIR/replace_consts.rs:26:17 | LL | { let foo = std::isize::MIN; }; | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:35:17 + --> $DIR/replace_consts.rs:27:17 | LL | { let foo = std::i8::MIN; }; | ^^^^^^^^^^^^ help: try this: `i8::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:36:17 + --> $DIR/replace_consts.rs:28:17 | LL | { let foo = std::i16::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:37:17 + --> $DIR/replace_consts.rs:29:17 | LL | { let foo = std::i32::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:38:17 + --> $DIR/replace_consts.rs:30:17 | LL | { let foo = std::i64::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:39:17 + --> $DIR/replace_consts.rs:31:17 | LL | { let foo = std::i128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:40:17 + --> $DIR/replace_consts.rs:32:17 | LL | { let foo = std::usize::MIN; }; | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:41:17 + --> $DIR/replace_consts.rs:33:17 | LL | { let foo = std::u8::MIN; }; | ^^^^^^^^^^^^ help: try this: `u8::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:42:17 + --> $DIR/replace_consts.rs:34:17 | LL | { let foo = std::u16::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:43:17 + --> $DIR/replace_consts.rs:35:17 | LL | { let foo = std::u32::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:44:17 + --> $DIR/replace_consts.rs:36:17 | LL | { let foo = std::u64::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:45:17 + --> $DIR/replace_consts.rs:37:17 | LL | { let foo = std::u128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` error: using `MAX` - --> $DIR/replace_consts.rs:47:17 + --> $DIR/replace_consts.rs:39:17 | LL | { let foo = std::isize::MAX; }; | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:48:17 + --> $DIR/replace_consts.rs:40:17 | LL | { let foo = std::i8::MAX; }; | ^^^^^^^^^^^^ help: try this: `i8::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:49:17 + --> $DIR/replace_consts.rs:41:17 | LL | { let foo = std::i16::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:50:17 + --> $DIR/replace_consts.rs:42:17 | LL | { let foo = std::i32::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:51:17 + --> $DIR/replace_consts.rs:43:17 | LL | { let foo = std::i64::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:52:17 + --> $DIR/replace_consts.rs:44:17 | LL | { let foo = std::i128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:53:17 + --> $DIR/replace_consts.rs:45:17 | LL | { let foo = std::usize::MAX; }; | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:54:17 + --> $DIR/replace_consts.rs:46:17 | LL | { let foo = std::u8::MAX; }; | ^^^^^^^^^^^^ help: try this: `u8::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:55:17 + --> $DIR/replace_consts.rs:47:17 | LL | { let foo = std::u16::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:56:17 + --> $DIR/replace_consts.rs:48:17 | LL | { let foo = std::u32::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:57:17 + --> $DIR/replace_consts.rs:49:17 | LL | { let foo = std::u64::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:58:17 + --> $DIR/replace_consts.rs:50:17 | LL | { let foo = std::u128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` diff --git a/tests/ui/result_map_unit_fn.rs b/tests/ui/result_map_unit_fn.rs index 3d731c9b350..a8e891d8db0 100644 --- a/tests/ui/result_map_unit_fn.rs +++ b/tests/ui/result_map_unit_fn.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(never_type)] #![warn(clippy::result_map_unit_fn)] #![allow(unused)] diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index e462a07ad51..9f9025152e2 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,5 +1,5 @@ error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:43:5 + --> $DIR/result_map_unit_fn.rs:34:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -9,7 +9,7 @@ LL | x.field.map(do_nothing); = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:45:5 + --> $DIR/result_map_unit_fn.rs:36:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | x.field.map(do_nothing); | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:47:5 + --> $DIR/result_map_unit_fn.rs:38:5 | LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- @@ -25,7 +25,7 @@ LL | x.field.map(diverge); | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:53:5 + --> $DIR/result_map_unit_fn.rs:44:5 | LL | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -33,7 +33,7 @@ LL | x.field.map(|value| x.do_result_nothing(value + captured)); | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:55:5 + --> $DIR/result_map_unit_fn.rs:46:5 | LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -41,7 +41,7 @@ LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:58:5 + --> $DIR/result_map_unit_fn.rs:49:5 | LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -49,7 +49,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:60:5 + --> $DIR/result_map_unit_fn.rs:51:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -57,7 +57,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:62:5 + --> $DIR/result_map_unit_fn.rs:53:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -65,7 +65,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:64:5 + --> $DIR/result_map_unit_fn.rs:55:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -73,7 +73,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:67:5 + --> $DIR/result_map_unit_fn.rs:58:5 | LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -81,7 +81,7 @@ LL | x.field.map(|value| diverge(value + captured)); | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:69:5 + --> $DIR/result_map_unit_fn.rs:60:5 | LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -89,7 +89,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:71:5 + --> $DIR/result_map_unit_fn.rs:62:5 | LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -97,7 +97,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:73:5 + --> $DIR/result_map_unit_fn.rs:64:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -105,7 +105,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:78:5 + --> $DIR/result_map_unit_fn.rs:69:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -113,7 +113,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:80:5 + --> $DIR/result_map_unit_fn.rs:71:5 | LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -121,7 +121,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:82:5 + --> $DIR/result_map_unit_fn.rs:73:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -129,7 +129,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:85:5 + --> $DIR/result_map_unit_fn.rs:76:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -137,7 +137,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:88:5 + --> $DIR/result_map_unit_fn.rs:79:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -145,7 +145,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:90:5 + --> $DIR/result_map_unit_fn.rs:81:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -153,7 +153,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:94:5 + --> $DIR/result_map_unit_fn.rs:85:5 | LL | x.field.map(|value| { | _____^ @@ -167,7 +167,7 @@ LL | || }); | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:98:5 + --> $DIR/result_map_unit_fn.rs:89:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -175,7 +175,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:102:5 + --> $DIR/result_map_unit_fn.rs:93:5 | LL | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -183,7 +183,7 @@ LL | "12".parse::().map(diverge); | help: try this: `if let Ok(_) = "12".parse::() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:108:5 + --> $DIR/result_map_unit_fn.rs:99:5 | LL | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- diff --git a/tests/ui/result_map_unwrap_or_else.rs b/tests/ui/result_map_unwrap_or_else.rs index 0481e4ec1b0..40751bfebe6 100644 --- a/tests/ui/result_map_unwrap_or_else.rs +++ b/tests/ui/result_map_unwrap_or_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2019 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // aux-build:option_helpers.rs //! Checks implementation of `RESULT_MAP_UNWRAP_OR_ELSE` diff --git a/tests/ui/result_map_unwrap_or_else.stderr b/tests/ui/result_map_unwrap_or_else.stderr index 9f03de669e4..7674b91c128 100644 --- a/tests/ui/result_map_unwrap_or_else.stderr +++ b/tests/ui/result_map_unwrap_or_else.stderr @@ -1,5 +1,5 @@ error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead - --> $DIR/result_map_unwrap_or_else.rs:24:13 + --> $DIR/result_map_unwrap_or_else.rs:15:13 | LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even t = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead - --> $DIR/result_map_unwrap_or_else.rs:26:13 + --> $DIR/result_map_unwrap_or_else.rs:17:13 | LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead - --> $DIR/result_map_unwrap_or_else.rs:27:13 + --> $DIR/result_map_unwrap_or_else.rs:18:13 | LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/serde.rs b/tests/ui/serde.rs index c52fd065dbe..5843344eba8 100644 --- a/tests/ui/serde.rs +++ b/tests/ui/serde.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::serde_api_misuse)] #![allow(dead_code)] diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index 61e54d53468..760c9c9908a 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -1,5 +1,5 @@ error: you should not implement `visit_string` without also implementing `visit_str` - --> $DIR/serde.rs:48:5 + --> $DIR/serde.rs:39:5 | LL | / fn visit_string(self, _v: String) -> Result LL | | where diff --git a/tests/ui/shadow.rs b/tests/ui/shadow.rs index e960a6252be..a9c77aca66f 100644 --- a/tests/ui/shadow.rs +++ b/tests/ui/shadow.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn( clippy::all, clippy::pedantic, diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index 158933e9672..ada8b07d69b 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,135 +1,135 @@ error: `x` is shadowed by itself in `&mut x` - --> $DIR/shadow.rs:29:5 + --> $DIR/shadow.rs:20:5 | LL | let x = &mut x; | ^^^^^^^^^^^^^^^ | = note: `-D clippy::shadow-same` implied by `-D warnings` note: previous binding is here - --> $DIR/shadow.rs:28:13 + --> $DIR/shadow.rs:19:13 | LL | let mut x = 1; | ^ error: `x` is shadowed by itself in `{ x }` - --> $DIR/shadow.rs:30:5 + --> $DIR/shadow.rs:21:5 | LL | let x = { x }; | ^^^^^^^^^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:29:9 + --> $DIR/shadow.rs:20:9 | LL | let x = &mut x; | ^ error: `x` is shadowed by itself in `(&*x)` - --> $DIR/shadow.rs:31:5 + --> $DIR/shadow.rs:22:5 | LL | let x = (&*x); | ^^^^^^^^^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:30:9 + --> $DIR/shadow.rs:21:9 | LL | let x = { x }; | ^ error: `x` is shadowed by `{ *x + 1 }` which reuses the original value - --> $DIR/shadow.rs:32:9 + --> $DIR/shadow.rs:23:9 | LL | let x = { *x + 1 }; | ^ | = note: `-D clippy::shadow-reuse` implied by `-D warnings` note: initialization happens here - --> $DIR/shadow.rs:32:13 + --> $DIR/shadow.rs:23:13 | LL | let x = { *x + 1 }; | ^^^^^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:31:9 + --> $DIR/shadow.rs:22:9 | LL | let x = (&*x); | ^ error: `x` is shadowed by `id(x)` which reuses the original value - --> $DIR/shadow.rs:33:9 + --> $DIR/shadow.rs:24:9 | LL | let x = id(x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:33:13 + --> $DIR/shadow.rs:24:13 | LL | let x = id(x); | ^^^^^ note: previous binding is here - --> $DIR/shadow.rs:32:9 + --> $DIR/shadow.rs:23:9 | LL | let x = { *x + 1 }; | ^ error: `x` is shadowed by `(1, x)` which reuses the original value - --> $DIR/shadow.rs:34:9 + --> $DIR/shadow.rs:25:9 | LL | let x = (1, x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:34:13 + --> $DIR/shadow.rs:25:13 | LL | let x = (1, x); | ^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:33:9 + --> $DIR/shadow.rs:24:9 | LL | let x = id(x); | ^ error: `x` is shadowed by `first(x)` which reuses the original value - --> $DIR/shadow.rs:35:9 + --> $DIR/shadow.rs:26:9 | LL | let x = first(x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:35:13 + --> $DIR/shadow.rs:26:13 | LL | let x = first(x); | ^^^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:34:9 + --> $DIR/shadow.rs:25:9 | LL | let x = (1, x); | ^ error: `x` is shadowed by `y` - --> $DIR/shadow.rs:37:9 + --> $DIR/shadow.rs:28:9 | LL | let x = y; | ^ | = note: `-D clippy::shadow-unrelated` implied by `-D warnings` note: initialization happens here - --> $DIR/shadow.rs:37:13 + --> $DIR/shadow.rs:28:13 | LL | let x = y; | ^ note: previous binding is here - --> $DIR/shadow.rs:35:9 + --> $DIR/shadow.rs:26:9 | LL | let x = first(x); | ^ error: `x` shadows a previous declaration - --> $DIR/shadow.rs:39:5 + --> $DIR/shadow.rs:30:5 | LL | let x; | ^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:37:9 + --> $DIR/shadow.rs:28:9 | LL | let x = y; | ^ diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index efe9920dd88..84e736fe080 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::short_circuit_statement)] fn main() { diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 4141a003fc4..a526766f698 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -1,5 +1,5 @@ error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:13:5 + --> $DIR/short_circuit_statement.rs:4:5 | LL | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` @@ -7,13 +7,13 @@ LL | f() && g(); = note: `-D clippy::short-circuit-statement` implied by `-D warnings` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:14:5 + --> $DIR/short_circuit_statement.rs:5:5 | LL | f() || g(); | ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:15:5 + --> $DIR/short_circuit_statement.rs:6:5 | LL | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if !(1 == 2) { g(); }` diff --git a/tests/ui/single_char_pattern.fixed b/tests/ui/single_char_pattern.fixed index c3c399f0ce3..220b855ead5 100644 --- a/tests/ui/single_char_pattern.fixed +++ b/tests/ui/single_char_pattern.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix use std::collections::HashSet; diff --git a/tests/ui/single_char_pattern.rs b/tests/ui/single_char_pattern.rs index cf2fe66236a..9650eb2af32 100644 --- a/tests/ui/single_char_pattern.rs +++ b/tests/ui/single_char_pattern.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix use std::collections::HashSet; diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index 7bc92a96536..82ef00bfee8 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,5 +1,5 @@ error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:16:13 + --> $DIR/single_char_pattern.rs:7:13 | LL | x.split("x"); | ^^^ help: try using a char instead: `'x'` @@ -7,115 +7,115 @@ LL | x.split("x"); = note: `-D clippy::single-char-pattern` implied by `-D warnings` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:33:16 + --> $DIR/single_char_pattern.rs:24:16 | LL | x.contains("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:34:19 + --> $DIR/single_char_pattern.rs:25:19 | LL | x.starts_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:35:17 + --> $DIR/single_char_pattern.rs:26:17 | LL | x.ends_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:36:12 + --> $DIR/single_char_pattern.rs:27:12 | LL | x.find("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:37:13 + --> $DIR/single_char_pattern.rs:28:13 | LL | x.rfind("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:38:14 + --> $DIR/single_char_pattern.rs:29:14 | LL | x.rsplit("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:39:24 + --> $DIR/single_char_pattern.rs:30:24 | LL | x.split_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:40:25 + --> $DIR/single_char_pattern.rs:31:25 | LL | x.rsplit_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:41:17 + --> $DIR/single_char_pattern.rs:32:17 | LL | x.splitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:42:18 + --> $DIR/single_char_pattern.rs:33:18 | LL | x.rsplitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:43:15 + --> $DIR/single_char_pattern.rs:34:15 | LL | x.matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:44:16 + --> $DIR/single_char_pattern.rs:35:16 | LL | x.rmatches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:45:21 + --> $DIR/single_char_pattern.rs:36:21 | LL | x.match_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:46:22 + --> $DIR/single_char_pattern.rs:37:22 | LL | x.rmatch_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:47:26 + --> $DIR/single_char_pattern.rs:38:26 | LL | x.trim_start_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:48:24 + --> $DIR/single_char_pattern.rs:39:24 | LL | x.trim_end_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:50:13 + --> $DIR/single_char_pattern.rs:41:13 | LL | x.split("/n"); | ^^^^ help: try using a char instead: `'/n'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:55:31 + --> $DIR/single_char_pattern.rs:46:31 | LL | x.replace(";", ",").split(","); // issue #2978 | ^^^ help: try using a char instead: `','` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:56:19 + --> $DIR/single_char_pattern.rs:47:19 | LL | x.starts_with("/x03"); // issue #2996 | ^^^^^^ help: try using a char instead: `'/x03'` diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs index 5a1bde3de32..99e88019cb8 100644 --- a/tests/ui/single_match.rs +++ b/tests/ui/single_match.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::single_match)] fn dummy() {} diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index 41776030800..445f702d0ce 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:17:5 + --> $DIR/single_match.rs:8:5 | LL | / match x { LL | | Some(y) => { @@ -18,7 +18,7 @@ LL | }; | error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:25:5 + --> $DIR/single_match.rs:16:5 | LL | / match x { LL | | // Note the missing block braces. @@ -30,7 +30,7 @@ LL | | } | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y) }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:34:5 + --> $DIR/single_match.rs:25:5 | LL | / match z { LL | | (2...3, 7...9) => dummy(), @@ -39,7 +39,7 @@ LL | | }; | |_____^ help: try this: `if let (2...3, 7...9) = z { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:63:5 + --> $DIR/single_match.rs:54:5 | LL | / match x { LL | | Some(y) => dummy(), @@ -48,7 +48,7 @@ LL | | }; | |_____^ help: try this: `if let Some(y) = x { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:68:5 + --> $DIR/single_match.rs:59:5 | LL | / match y { LL | | Ok(y) => dummy(), @@ -57,7 +57,7 @@ LL | | }; | |_____^ help: try this: `if let Ok(y) = y { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:75:5 + --> $DIR/single_match.rs:66:5 | LL | / match c { LL | | Cow::Borrowed(..) => dummy(), diff --git a/tests/ui/single_match_else.rs b/tests/ui/single_match_else.rs index 18c26f7fc26..37a99de8832 100644 --- a/tests/ui/single_match_else.rs +++ b/tests/ui/single_match_else.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::single_match_else)] enum ExprNode { diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index ff780ad9667..3f29f5aaf6a 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:21:5 + --> $DIR/single_match_else.rs:12:5 | LL | / match ExprNode::Butterflies { LL | | ExprNode::ExprAddrOf => Some(&NODE), diff --git a/tests/ui/slow_vector_initialization.rs b/tests/ui/slow_vector_initialization.rs index cf11384467c..c5ae3ff769b 100644 --- a/tests/ui/slow_vector_initialization.rs +++ b/tests/ui/slow_vector_initialization.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::iter::repeat; fn main() { diff --git a/tests/ui/slow_vector_initialization.stderr b/tests/ui/slow_vector_initialization.stderr index 319234386ac..5d2788ec260 100644 --- a/tests/ui/slow_vector_initialization.stderr +++ b/tests/ui/slow_vector_initialization.stderr @@ -1,5 +1,5 @@ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:22:5 + --> $DIR/slow_vector_initialization.rs:13:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replace allocation with: `vec![0; len]` @@ -9,7 +9,7 @@ LL | vec1.extend(repeat(0).take(len)); = note: `-D clippy::slow-vector-initialization` implied by `-D warnings` error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:26:5 + --> $DIR/slow_vector_initialization.rs:17:5 | LL | let mut vec2 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replace allocation with: `vec![0; len - 10]` @@ -17,7 +17,7 @@ LL | vec2.extend(repeat(0).take(len - 10)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:40:5 + --> $DIR/slow_vector_initialization.rs:31:5 | LL | let mut resized_vec = Vec::with_capacity(30); | ---------------------- help: consider replace allocation with: `vec![0; 30]` @@ -25,7 +25,7 @@ LL | resized_vec.resize(30, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:43:5 + --> $DIR/slow_vector_initialization.rs:34:5 | LL | let mut extend_vec = Vec::with_capacity(30); | ---------------------- help: consider replace allocation with: `vec![0; 30]` @@ -33,7 +33,7 @@ LL | extend_vec.extend(repeat(0).take(30)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:50:5 + --> $DIR/slow_vector_initialization.rs:41:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replace allocation with: `vec![0; len]` @@ -41,7 +41,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:58:5 + --> $DIR/slow_vector_initialization.rs:49:5 | LL | let mut vec3 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replace allocation with: `vec![0; len - 10]` @@ -49,7 +49,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:62:5 + --> $DIR/slow_vector_initialization.rs:53:5 | LL | vec1 = Vec::with_capacity(10); | ---------------------- help: consider replace allocation with: `vec![0; 10]` diff --git a/tests/ui/starts_ends_with.fixed b/tests/ui/starts_ends_with.fixed new file mode 100644 index 00000000000..7dfcf9c91e4 --- /dev/null +++ b/tests/ui/starts_ends_with.fixed @@ -0,0 +1,46 @@ +// run-rustfix +#![allow(dead_code, unused_must_use)] + +fn main() {} + +#[allow(clippy::unnecessary_operation)] +fn starts_with() { + "".starts_with(' '); + !"".starts_with(' '); +} + +fn chars_cmp_with_unwrap() { + let s = String::from("foo"); + if s.starts_with('f') { + // s.starts_with('f') + // Nothing here + } + if s.ends_with('o') { + // s.ends_with('o') + // Nothing here + } + if s.ends_with('o') { + // s.ends_with('o') + // Nothing here + } + if !s.starts_with('f') { + // !s.starts_with('f') + // Nothing here + } + if !s.ends_with('o') { + // !s.ends_with('o') + // Nothing here + } + if !s.ends_with('o') { + // !s.ends_with('o') + // Nothing here + } +} + +#[allow(clippy::unnecessary_operation)] +fn ends_with() { + "".ends_with(' '); + !"".ends_with(' '); + "".ends_with(' '); + !"".ends_with(' '); +} diff --git a/tests/ui/starts_ends_with.rs b/tests/ui/starts_ends_with.rs index 529c2487f54..e48a4246354 100644 --- a/tests/ui/starts_ends_with.rs +++ b/tests/ui/starts_ends_with.rs @@ -1,13 +1,5 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] +// run-rustfix +#![allow(dead_code, unused_must_use)] fn main() {} diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index ed1ccad9814..7c726d0e010 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,5 +1,5 @@ error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:16:5 + --> $DIR/starts_ends_with.rs:8:5 | LL | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` @@ -7,19 +7,19 @@ LL | "".chars().next() == Some(' '); = note: `-D clippy::chars-next-cmp` implied by `-D warnings` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:17:5 + --> $DIR/starts_ends_with.rs:9:5 | LL | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:22:8 + --> $DIR/starts_ends_with.rs:14:8 | LL | if s.chars().next().unwrap() == 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:26:8 + --> $DIR/starts_ends_with.rs:18:8 | LL | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` @@ -27,49 +27,49 @@ LL | if s.chars().next_back().unwrap() == 'o' { = note: `-D clippy::chars-last-cmp` implied by `-D warnings` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:30:8 + --> $DIR/starts_ends_with.rs:22:8 | LL | if s.chars().last().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:34:8 + --> $DIR/starts_ends_with.rs:26:8 | LL | if s.chars().next().unwrap() != 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:38:8 + --> $DIR/starts_ends_with.rs:30:8 | LL | if s.chars().next_back().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:42:8 + --> $DIR/starts_ends_with.rs:34:8 | LL | if s.chars().last().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:50:5 + --> $DIR/starts_ends_with.rs:42:5 | LL | "".chars().last() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:51:5 + --> $DIR/starts_ends_with.rs:43:5 | LL | Some(' ') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:52:5 + --> $DIR/starts_ends_with.rs:44:5 | LL | "".chars().next_back() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:53:5 + --> $DIR/starts_ends_with.rs:45:5 | LL | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` diff --git a/tests/ui/string_extend.fixed b/tests/ui/string_extend.fixed index 7463baff2af..1883a9f8325 100644 --- a/tests/ui/string_extend.fixed +++ b/tests/ui/string_extend.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[derive(Copy, Clone)] diff --git a/tests/ui/string_extend.rs b/tests/ui/string_extend.rs index 3a2ad2695de..07d0baa1be6 100644 --- a/tests/ui/string_extend.rs +++ b/tests/ui/string_extend.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[derive(Copy, Clone)] diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index 5638dd87ed1..6af8c9e1662 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -1,5 +1,5 @@ error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:27:5 + --> $DIR/string_extend.rs:18:5 | LL | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)` @@ -7,13 +7,13 @@ LL | s.extend(abc.chars()); = note: `-D clippy::string-extend-chars` implied by `-D warnings` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:30:5 + --> $DIR/string_extend.rs:21:5 | LL | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str("abc")` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:33:5 + --> $DIR/string_extend.rs:24:5 | LL | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)` diff --git a/tests/ui/strings.rs b/tests/ui/strings.rs index e15e80c1928..f0808eca829 100644 --- a/tests/ui/strings.rs +++ b/tests/ui/strings.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::string_add)] #[allow(clippy::string_add_assign)] fn add_only() { diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index a8c80939b55..e2e997f58e6 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -1,5 +1,5 @@ error: manual implementation of an assign operation - --> $DIR/strings.rs:17:9 + --> $DIR/strings.rs:8:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` @@ -7,7 +7,7 @@ LL | x = x + "."; = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:17:13 + --> $DIR/strings.rs:8:13 | LL | x = x + "."; | ^^^^^^^ @@ -15,13 +15,13 @@ LL | x = x + "."; = note: `-D clippy::string-add` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:21:13 + --> $DIR/strings.rs:12:13 | LL | let z = y + "..."; | ^^^^^^^^^ error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:31:9 + --> $DIR/strings.rs:22:9 | LL | x = x + "."; | ^^^^^^^^^^^ @@ -29,31 +29,31 @@ LL | x = x + "."; = note: `-D clippy::string-add-assign` implied by `-D warnings` error: manual implementation of an assign operation - --> $DIR/strings.rs:31:9 + --> $DIR/strings.rs:22:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:45:9 + --> $DIR/strings.rs:36:9 | LL | x = x + "."; | ^^^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/strings.rs:45:9 + --> $DIR/strings.rs:36:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:49:13 + --> $DIR/strings.rs:40:13 | LL | let z = y + "..."; | ^^^^^^^^^ error: calling `as_bytes()` on a string literal - --> $DIR/strings.rs:57:14 + --> $DIR/strings.rs:48:14 | LL | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` @@ -61,13 +61,13 @@ LL | let bs = "hello there".as_bytes(); = note: `-D clippy::string-lit-as-bytes` implied by `-D warnings` error: calling `as_bytes()` on a string literal - --> $DIR/strings.rs:59:14 + --> $DIR/strings.rs:50:14 | LL | let bs = r###"raw string with three ### in it and some " ""###.as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `br###"raw string with three ### in it and some " ""###` error: calling `as_bytes()` on `include_str!(..)` - --> $DIR/strings.rs:66:22 + --> $DIR/strings.rs:57:22 | LL | let includestr = include_str!("entry.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("entry.rs")` diff --git a/tests/ui/suspicious_arithmetic_impl.rs b/tests/ui/suspicious_arithmetic_impl.rs index ed845b7647a..6ee924d3b2e 100644 --- a/tests/ui/suspicious_arithmetic_impl.rs +++ b/tests/ui/suspicious_arithmetic_impl.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::suspicious_arithmetic_impl)] use std::ops::{Add, AddAssign, Div, Mul, Sub}; diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 71cb08c77d7..f818f7b3d95 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,5 +1,5 @@ error: Suspicious use of binary operator in `Add` impl - --> $DIR/suspicious_arithmetic_impl.rs:20:20 + --> $DIR/suspicious_arithmetic_impl.rs:11:20 | LL | Foo(self.0 - other.0) | ^ @@ -7,7 +7,7 @@ LL | Foo(self.0 - other.0) = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` error: Suspicious use of binary operator in `AddAssign` impl - --> $DIR/suspicious_arithmetic_impl.rs:26:23 + --> $DIR/suspicious_arithmetic_impl.rs:17:23 | LL | *self = *self - other; | ^ diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index 20fa9c87574..77cfc16ff6e 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(clippy::blacklisted_name, unused_assignments)] diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 25afaccd754..5d818cf2056 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:17:5 + --> $DIR/swap.rs:8:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -9,7 +9,7 @@ LL | | foo[1] = temp; = note: `-D clippy::manual-swap` implied by `-D warnings` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:26:5 + --> $DIR/swap.rs:17:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -17,7 +17,7 @@ LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:35:5 + --> $DIR/swap.rs:26:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -25,7 +25,7 @@ LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:54:7 + --> $DIR/swap.rs:45:7 | LL | ; let t = a; | _______^ @@ -36,7 +36,7 @@ LL | | b = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:63:7 + --> $DIR/swap.rs:54:7 | LL | ; let t = c.0; | _______^ @@ -47,7 +47,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:51:5 + --> $DIR/swap.rs:42:5 | LL | / a = b; LL | | b = a; @@ -57,7 +57,7 @@ LL | | b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:60:5 + --> $DIR/swap.rs:51:5 | LL | / c.0 = a; LL | | a = c.0; diff --git a/tests/ui/temporary_assignment.rs b/tests/ui/temporary_assignment.rs index 5581f5be766..c6c315d5fab 100644 --- a/tests/ui/temporary_assignment.rs +++ b/tests/ui/temporary_assignment.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::temporary_assignment)] use std::ops::{Deref, DerefMut}; diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 13ece2858b9..4efe2d4bb67 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -1,5 +1,5 @@ error: assignment to temporary - --> $DIR/temporary_assignment.rs:56:5 + --> $DIR/temporary_assignment.rs:47:5 | LL | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | Struct { field: 0 }.field = 1; = note: `-D clippy::temporary-assignment` implied by `-D warnings` error: assignment to temporary - --> $DIR/temporary_assignment.rs:57:5 + --> $DIR/temporary_assignment.rs:48:5 | LL | / MultiStruct { LL | | structure: Struct { field: 0 }, @@ -17,37 +17,37 @@ LL | | .field = 1; | |______________^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:62:5 + --> $DIR/temporary_assignment.rs:53:5 | LL | ArrayStruct { array: [0] }.array[0] = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:63:5 + --> $DIR/temporary_assignment.rs:54:5 | LL | (0, 0).0 = 1; | ^^^^^^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:65:5 + --> $DIR/temporary_assignment.rs:56:5 | LL | A.0 = 2; | ^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:66:5 + --> $DIR/temporary_assignment.rs:57:5 | LL | B.field = 2; | ^^^^^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:67:5 + --> $DIR/temporary_assignment.rs:58:5 | LL | C.structure.field = 2; | ^^^^^^^^^^^^^^^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:68:5 + --> $DIR/temporary_assignment.rs:59:5 | LL | D.array[0] = 2; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/toplevel_ref_arg.rs b/tests/ui/toplevel_ref_arg.rs index b051746bbd4..711fb4f8aed 100644 --- a/tests/ui/toplevel_ref_arg.rs +++ b/tests/ui/toplevel_ref_arg.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(unused)] diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 7b7a46d9f8e..00a753c6ac2 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,5 +1,5 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead. - --> $DIR/toplevel_ref_arg.rs:13:15 + --> $DIR/toplevel_ref_arg.rs:4:15 | LL | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ @@ -7,25 +7,25 @@ LL | fn the_answer(ref mut x: u8) { = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:24:9 + --> $DIR/toplevel_ref_arg.rs:15:9 | LL | let ref x = 1; | ----^^^^^----- help: try: `let x = &1;` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:26:9 + --> $DIR/toplevel_ref_arg.rs:17:9 | LL | let ref y: (&_, u8) = (&1, 2); | ----^^^^^--------------------- help: try: `let y: &(&_, u8) = &(&1, 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:28:9 + --> $DIR/toplevel_ref_arg.rs:19:9 | LL | let ref z = 1 + 2; | ----^^^^^--------- help: try: `let z = &(1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:30:9 + --> $DIR/toplevel_ref_arg.rs:21:9 | LL | let ref mut z = 1 + 2; | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` diff --git a/tests/ui/trailing_zeros.rs b/tests/ui/trailing_zeros.rs index 9afb3399c59..4ee5ecffb87 100644 --- a/tests/ui/trailing_zeros.rs +++ b/tests/ui/trailing_zeros.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(stmt_expr_attributes)] #![allow(unused_parens)] diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 1675eb44efd..61289b24471 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,5 +1,5 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:16:5 + --> $DIR/trailing_zeros.rs:7:5 | LL | (x & 0b1111 == 0); // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` @@ -7,7 +7,7 @@ LL | (x & 0b1111 == 0); // suggest trailing_zeros = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:17:13 + --> $DIR/trailing_zeros.rs:8:13 | LL | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs index b27014201cd..86964f8480a 100644 --- a/tests/ui/transmute.rs +++ b/tests/ui/transmute.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] extern crate core; diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index a6e87a72104..ceee86d224d 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,5 +1,5 @@ error: transmute from a type (`&'a T`) to itself - --> $DIR/transmute.rs:28:20 + --> $DIR/transmute.rs:19:20 | LL | let _: &'a T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | let _: &'a T = core::intrinsics::transmute(t); = note: `-D clippy::useless-transmute` implied by `-D warnings` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:32:23 + --> $DIR/transmute.rs:23:23 | LL | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:34:21 + --> $DIR/transmute.rs:25:21 | LL | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:36:23 + --> $DIR/transmute.rs:27:23 | LL | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` error: transmute from a pointer type (`*const T`) to a reference type (`&T`) - --> $DIR/transmute.rs:41:17 + --> $DIR/transmute.rs:32:17 | LL | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` @@ -33,103 +33,103 @@ LL | let _: &T = std::mem::transmute(p); = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:44:21 + --> $DIR/transmute.rs:35:21 | LL | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) - --> $DIR/transmute.rs:47:17 + --> $DIR/transmute.rs:38:17 | LL | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:50:21 + --> $DIR/transmute.rs:41:21 | LL | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) - --> $DIR/transmute.rs:53:17 + --> $DIR/transmute.rs:44:17 | LL | let _: &T = std::mem::transmute(o); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:56:21 + --> $DIR/transmute.rs:47:21 | LL | let _: &mut T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) - --> $DIR/transmute.rs:59:17 + --> $DIR/transmute.rs:50:17 | LL | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) - --> $DIR/transmute.rs:70:32 + --> $DIR/transmute.rs:61:32 | LL | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) - --> $DIR/transmute.rs:72:33 + --> $DIR/transmute.rs:63:33 | LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<&_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) - --> $DIR/transmute.rs:76:14 + --> $DIR/transmute.rs:67:14 | LL | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:82:27 + --> $DIR/transmute.rs:73:27 | LL | let _: Vec = core::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:84:27 + --> $DIR/transmute.rs:75:27 | LL | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:86:27 + --> $DIR/transmute.rs:77:27 | LL | let _: Vec = std::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:88:27 + --> $DIR/transmute.rs:79:27 | LL | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:90:27 + --> $DIR/transmute.rs:81:27 | LL | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer - --> $DIR/transmute.rs:98:31 + --> $DIR/transmute.rs:89:31 | LL | let _: *const usize = std::mem::transmute(5_isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` error: transmute from an integer to a pointer - --> $DIR/transmute.rs:102:31 + --> $DIR/transmute.rs:93:31 | LL | let _: *const usize = std::mem::transmute(1 + 1usize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:117:24 + --> $DIR/transmute.rs:108:24 | LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,25 +137,25 @@ LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:119:24 + --> $DIR/transmute.rs:110:24 | LL | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> $DIR/transmute.rs:121:31 + --> $DIR/transmute.rs:112:31 | LL | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> $DIR/transmute.rs:123:29 + --> $DIR/transmute.rs:114:29 | LL | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u32` to a `char` - --> $DIR/transmute.rs:129:28 + --> $DIR/transmute.rs:120:28 | LL | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` @@ -163,13 +163,13 @@ LL | let _: char = unsafe { std::mem::transmute(0_u32) }; = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` error: transmute from a `i32` to a `char` - --> $DIR/transmute.rs:130:28 + --> $DIR/transmute.rs:121:28 | LL | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` error: transmute from a `u8` to a `bool` - --> $DIR/transmute.rs:135:28 + --> $DIR/transmute.rs:126:28 | LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` @@ -177,7 +177,7 @@ LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` error: transmute from a `u32` to a `f32` - --> $DIR/transmute.rs:140:27 + --> $DIR/transmute.rs:131:27 | LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` @@ -185,13 +185,13 @@ LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; = note: `-D clippy::transmute-int-to-float` implied by `-D warnings` error: transmute from a `i32` to a `f32` - --> $DIR/transmute.rs:141:27 + --> $DIR/transmute.rs:132:27 | LL | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:145:28 + --> $DIR/transmute.rs:136:28 | LL | let _: &str = unsafe { std::mem::transmute(b) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()` @@ -199,13 +199,13 @@ LL | let _: &str = unsafe { std::mem::transmute(b) }; = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings` error: transmute from a `&mut [u8]` to a `&mut str` - --> $DIR/transmute.rs:146:32 + --> $DIR/transmute.rs:137:32 | LL | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:178:29 + --> $DIR/transmute.rs:169:29 | LL | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` @@ -213,31 +213,31 @@ LL | let _: *const f32 = std::mem::transmute(ptr); = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:179:27 + --> $DIR/transmute.rs:170:27 | LL | let _: *mut f32 = std::mem::transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` error: transmute from a reference to a reference - --> $DIR/transmute.rs:181:23 + --> $DIR/transmute.rs:172:23 | LL | let _: &f32 = std::mem::transmute(&1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:182:23 + --> $DIR/transmute.rs:173:23 | LL | let _: &f64 = std::mem::transmute(&1f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:185:27 + --> $DIR/transmute.rs:176:27 | LL | let _: &mut f32 = std::mem::transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:186:37 + --> $DIR/transmute.rs:177:37 | LL | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` diff --git a/tests/ui/transmute_32bit.rs b/tests/ui/transmute_32bit.rs index dd96e2dabe1..1b50133d391 100644 --- a/tests/ui/transmute_32bit.rs +++ b/tests/ui/transmute_32bit.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //ignore-x86_64 #[warn(wrong_transmute)] diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index fbc298e3a06..aee5152d647 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //ignore-x86 //no-ignore-x86_64 diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index bbca3bc0b36..457050ec504 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,5 +1,5 @@ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:16:31 + --> $DIR/transmute_64bit.rs:7:31 | LL | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let _: *const usize = std::mem::transmute(6.0f64); = note: `-D clippy::wrong-transmute` implied by `-D warnings` error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:18:29 + --> $DIR/transmute_64bit.rs:9:29 | LL | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/trivially_copy_pass_by_ref.rs b/tests/ui/trivially_copy_pass_by_ref.rs index 94e0113e56c..c12d9856501 100644 --- a/tests/ui/trivially_copy_pass_by_ref.rs +++ b/tests/ui/trivially_copy_pass_by_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( clippy::many_single_char_names, clippy::blacklisted_name, diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 6f2967bc392..754069b421c 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,5 +1,5 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:56:11 + --> $DIR/trivially_copy_pass_by_ref.rs:47:11 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` @@ -7,85 +7,85 @@ LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:56:20 + --> $DIR/trivially_copy_pass_by_ref.rs:47:20 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:56:29 + --> $DIR/trivially_copy_pass_by_ref.rs:47:29 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:63:12 + --> $DIR/trivially_copy_pass_by_ref.rs:54:12 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:63:22 + --> $DIR/trivially_copy_pass_by_ref.rs:54:22 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:63:31 + --> $DIR/trivially_copy_pass_by_ref.rs:54:31 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:63:40 + --> $DIR/trivially_copy_pass_by_ref.rs:54:40 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:65:16 + --> $DIR/trivially_copy_pass_by_ref.rs:56:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:65:25 + --> $DIR/trivially_copy_pass_by_ref.rs:56:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:65:34 + --> $DIR/trivially_copy_pass_by_ref.rs:56:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:77:16 + --> $DIR/trivially_copy_pass_by_ref.rs:68:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:77:25 + --> $DIR/trivially_copy_pass_by_ref.rs:68:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:77:34 + --> $DIR/trivially_copy_pass_by_ref.rs:68:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:81:34 + --> $DIR/trivially_copy_pass_by_ref.rs:72:34 | LL | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:85:37 + --> $DIR/trivially_copy_pass_by_ref.rs:76:37 | LL | fn trait_method2(&self, _color: &Color); | ^^^^^^ help: consider passing by value instead: `Color` diff --git a/tests/ui/ty_fn_sig.rs b/tests/ui/ty_fn_sig.rs index 17027306367..9e2753dcb18 100644 --- a/tests/ui/ty_fn_sig.rs +++ b/tests/ui/ty_fn_sig.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // Regression test pub fn retry(f: F) { diff --git a/tests/ui/types.fixed b/tests/ui/types.fixed new file mode 100644 index 00000000000..a71a9ec8124 --- /dev/null +++ b/tests/ui/types.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(dead_code, unused_variables)] + +// should not warn on lossy casting in constant types +// because not supported yet +const C: i32 = 42; +const C_I64: i64 = C as i64; + +fn main() { + // should suggest i64::from(c) + let c: i32 = 42; + let c_i64: i64 = i64::from(c); +} diff --git a/tests/ui/types.rs b/tests/ui/types.rs index f0ede2fd48c..6f48080cedd 100644 --- a/tests/ui/types.rs +++ b/tests/ui/types.rs @@ -1,11 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// run-rustfix + +#![allow(dead_code, unused_variables)] // should not warn on lossy casting in constant types // because not supported yet diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index 76dc07aef31..f85e27a24ec 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,5 +1,5 @@ error: casting i32 to i64 may become silently lossy if types change - --> $DIR/types.rs:18:22 + --> $DIR/types.rs:13:22 | LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` diff --git a/tests/ui/unicode.rs b/tests/ui/unicode.rs index 0e1200db227..deec885b85d 100644 --- a/tests/ui/unicode.rs +++ b/tests/ui/unicode.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[warn(clippy::zero_width_space)] fn zero() { print!("Here >​< is a ZWS, and ​another"); diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 9b78271e1fa..c60dcdaec1d 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -1,5 +1,5 @@ error: zero-width space detected - --> $DIR/unicode.rs:12:12 + --> $DIR/unicode.rs:3:12 | LL | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | print!("Here >​< is a ZWS, and ​another"); ""Here >/u{200B}< is a ZWS, and /u{200B}another"" error: non-nfc unicode sequence detected - --> $DIR/unicode.rs:18:12 + --> $DIR/unicode.rs:9:12 | LL | print!("̀àh?"); | ^^^^^ @@ -19,7 +19,7 @@ LL | print!("̀àh?"); ""̀àh?"" error: literal non-ASCII character detected - --> $DIR/unicode.rs:24:12 + --> $DIR/unicode.rs:15:12 | LL | print!("Üben!"); | ^^^^^^^ diff --git a/tests/ui/unit_arg.fixed b/tests/ui/unit_arg.fixed new file mode 100644 index 00000000000..d8f3e854ca9 --- /dev/null +++ b/tests/ui/unit_arg.fixed @@ -0,0 +1,53 @@ +// run-rustfix +#![warn(clippy::unit_arg)] +#![allow(clippy::no_effect, unused_must_use)] + +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(()); + foo(()); + foo(()); + foo3((), 2, 2); + let b = Bar; + b.bar(()); +} + +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.rs b/tests/ui/unit_arg.rs index 571882ced0f..1403870eacf 100644 --- a/tests/ui/unit_arg.rs +++ b/tests/ui/unit_arg.rs @@ -1,14 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - +// run-rustfix #![warn(clippy::unit_arg)] -#![allow(clippy::no_effect)] +#![allow(clippy::no_effect, unused_must_use)] use std::fmt::Debug; diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index 013016574ff..862534b18ec 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,5 +1,5 @@ error: passing a unit value to a function - --> $DIR/unit_arg.rs:32:9 + --> $DIR/unit_arg.rs:24:9 | LL | foo({}); | ^^ @@ -11,7 +11,7 @@ LL | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:33:9 + --> $DIR/unit_arg.rs:25:9 | LL | foo({ | _________^ @@ -24,7 +24,7 @@ LL | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:36:9 + --> $DIR/unit_arg.rs:28:9 | LL | foo(foo(1)); | ^^^^^^ @@ -34,7 +34,7 @@ LL | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:37:9 + --> $DIR/unit_arg.rs:29:9 | LL | foo({ | _________^ @@ -48,7 +48,7 @@ LL | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:41:10 + --> $DIR/unit_arg.rs:33:10 | LL | foo3({}, 2, 2); | ^^ @@ -58,7 +58,7 @@ LL | foo3((), 2, 2); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:43:11 + --> $DIR/unit_arg.rs:35:11 | LL | b.bar({ | ___________^ diff --git a/tests/ui/unit_cmp.rs b/tests/ui/unit_cmp.rs index 0bc87f43c15..48c22f7f875 100644 --- a/tests/ui/unit_cmp.rs +++ b/tests/ui/unit_cmp.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::unit_cmp)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 481891b99b0..56293403043 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,5 +1,5 @@ error: ==-comparison of unit values detected. This will always be true - --> $DIR/unit_cmp.rs:21:8 + --> $DIR/unit_cmp.rs:12:8 | LL | if { | ________^ @@ -12,7 +12,7 @@ LL | | } {} = note: `-D clippy::unit-cmp` implied by `-D warnings` error: >-comparison of unit values detected. This will always be false - --> $DIR/unit_cmp.rs:27:8 + --> $DIR/unit_cmp.rs:18:8 | LL | if { | ________^ diff --git a/tests/ui/unknown_clippy_lints.rs b/tests/ui/unknown_clippy_lints.rs index e583614a93c..0a93c814d96 100644 --- a/tests/ui/unknown_clippy_lints.rs +++ b/tests/ui/unknown_clippy_lints.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::All)] #![warn(clippy::pedantic)] diff --git a/tests/ui/unknown_clippy_lints.stderr b/tests/ui/unknown_clippy_lints.stderr index f83a51728e7..3c86432a972 100644 --- a/tests/ui/unknown_clippy_lints.stderr +++ b/tests/ui/unknown_clippy_lints.stderr @@ -1,5 +1,5 @@ error: unknown clippy lint: clippy::if_not_els - --> $DIR/unknown_clippy_lints.rs:13:8 + --> $DIR/unknown_clippy_lints.rs:4:8 | LL | #[warn(clippy::if_not_els)] | ^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[warn(clippy::if_not_els)] = note: `-D clippy::unknown-clippy-lints` implied by `-D warnings` error: unknown clippy lint: clippy::All - --> $DIR/unknown_clippy_lints.rs:10:10 + --> $DIR/unknown_clippy_lints.rs:1:10 | LL | #![allow(clippy::All)] | ^^^^^^^^^^^ help: lowercase the lint name: `all` diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index 40c4b4961e9..fee6b30a97b 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::clone_on_ref_ptr)] #![allow(unused)] diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 604902e5d6d..5cd9b2d337f 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,5 +1,5 @@ error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:26:5 + --> $DIR/unnecessary_clone.rs:17:5 | LL | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` @@ -7,19 +7,19 @@ LL | 42.clone(); = note: `-D clippy::clone-on-copy` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:30:5 + --> $DIR/unnecessary_clone.rs:21:5 | LL | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:33:5 + --> $DIR/unnecessary_clone.rs:24:5 | LL | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:43:5 + --> $DIR/unnecessary_clone.rs:34:5 | LL | rc.clone(); | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` @@ -27,43 +27,43 @@ LL | rc.clone(); = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:46:5 + --> $DIR/unnecessary_clone.rs:37:5 | LL | arc.clone(); | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:49:5 + --> $DIR/unnecessary_clone.rs:40:5 | LL | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:52:5 + --> $DIR/unnecessary_clone.rs:43:5 | LL | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:56:29 + --> $DIR/unnecessary_clone.rs:47:29 | LL | let _: Arc = x.clone(); | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:60:5 + --> $DIR/unnecessary_clone.rs:51:5 | LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:62:5 + --> $DIR/unnecessary_clone.rs:53:5 | LL | 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:68:22 + --> $DIR/unnecessary_clone.rs:59:22 | LL | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ @@ -79,7 +79,7 @@ LL | 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:75:26 + --> $DIR/unnecessary_clone.rs:66:26 | LL | let v2: Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL | let v2: Vec = v.iter().cloned().collect(); = note: `-D clippy::iter-cloned-collect` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:111:20 + --> $DIR/unnecessary_clone.rs:102:20 | LL | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` diff --git a/tests/ui/unnecessary_filter_map.rs b/tests/ui/unnecessary_filter_map.rs index a0c183a58cc..af858e4abcf 100644 --- a/tests/ui/unnecessary_filter_map.rs +++ b/tests/ui/unnecessary_filter_map.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - fn main() { let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); let _ = (0..4).filter_map(|x| { diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 09f8973708f..041829c3c78 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -1,5 +1,5 @@ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:11:13 + --> $DIR/unnecessary_filter_map.rs:2:13 | LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings` error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:12:13 + --> $DIR/unnecessary_filter_map.rs:3:13 | LL | let _ = (0..4).filter_map(|x| { | _____________^ @@ -19,7 +19,7 @@ LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:18:13 + --> $DIR/unnecessary_filter_map.rs:9:13 | LL | let _ = (0..4).filter_map(|x| match x { | _____________^ @@ -29,7 +29,7 @@ LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.map` - --> $DIR/unnecessary_filter_map.rs:23:13 + --> $DIR/unnecessary_filter_map.rs:14:13 | LL | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_fold.fixed b/tests/ui/unnecessary_fold.fixed new file mode 100644 index 00000000000..5f12d72a76a --- /dev/null +++ b/tests/ui/unnecessary_fold.fixed @@ -0,0 +1,44 @@ +// run-rustfix + +#![allow(dead_code)] + +/// Calls which should trigger the `UNNECESSARY_FOLD` lint +fn unnecessary_fold() { + // Can be replaced by .any + let _ = (0..3).any(|x| x > 2); + // Can be replaced by .all + let _ = (0..3).all(|x| x > 2); + // Can be replaced by .sum + let _: i32 = (0..3).sum(); + // Can be replaced by .product + let _: i32 = (0..3).product(); +} + +/// Should trigger the `UNNECESSARY_FOLD` lint, with an error span including exactly `.fold(...)` +fn unnecessary_fold_span_for_multi_element_chain() { + let _: bool = (0..3).map(|x| 2 * x).any(|x| x > 2); +} + +/// Calls which should not trigger the `UNNECESSARY_FOLD` lint +fn unnecessary_fold_should_ignore() { + let _ = (0..3).fold(true, |acc, x| acc || x > 2); + let _ = (0..3).fold(false, |acc, x| acc && x > 2); + let _ = (0..3).fold(1, |acc, x| acc + x); + let _ = (0..3).fold(0, |acc, x| acc * x); + let _ = (0..3).fold(0, |acc, x| 1 + acc + x); + + // We only match against an accumulator on the left + // hand side. We could lint for .sum and .product when + // it's on the right, but don't for now (and this wouldn't + // be valid if we extended the lint to cover arbitrary numeric + // types). + let _ = (0..3).fold(false, |acc, x| x > 2 || acc); + let _ = (0..3).fold(true, |acc, x| x > 2 && acc); + let _ = (0..3).fold(0, |acc, x| x + acc); + let _ = (0..3).fold(1, |acc, x| x * acc); + + let _ = [(0..2), (0..3)].iter().fold(0, |a, b| a + b.len()); + let _ = [(0..2), (0..3)].iter().fold(1, |a, b| a * b.len()); +} + +fn main() {} diff --git a/tests/ui/unnecessary_fold.rs b/tests/ui/unnecessary_fold.rs index 4b4a6ee044c..ae667d1ac06 100644 --- a/tests/ui/unnecessary_fold.rs +++ b/tests/ui/unnecessary_fold.rs @@ -1,11 +1,6 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// run-rustfix + +#![allow(dead_code)] /// Calls which should trigger the `UNNECESSARY_FOLD` lint fn unnecessary_fold() { @@ -14,14 +9,14 @@ fn unnecessary_fold() { // Can be replaced by .all let _ = (0..3).fold(true, |acc, x| acc && x > 2); // Can be replaced by .sum - let _ = (0..3).fold(0, |acc, x| acc + x); + let _: i32 = (0..3).fold(0, |acc, x| acc + x); // Can be replaced by .product - let _ = (0..3).fold(1, |acc, x| acc * x); + let _: i32 = (0..3).fold(1, |acc, x| acc * x); } /// Should trigger the `UNNECESSARY_FOLD` lint, with an error span including exactly `.fold(...)` fn unnecessary_fold_span_for_multi_element_chain() { - let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); + let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); } /// Calls which should not trigger the `UNNECESSARY_FOLD` lint diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index 2c2349bd3bc..f9911d4a3dc 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,5 +1,5 @@ error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:13:19 + --> $DIR/unnecessary_fold.rs:8:19 | LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` @@ -7,28 +7,28 @@ LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); = note: `-D clippy::unnecessary-fold` implied by `-D warnings` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:15:19 + --> $DIR/unnecessary_fold.rs:10:19 | LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:17:19 + --> $DIR/unnecessary_fold.rs:12:24 | -LL | let _ = (0..3).fold(0, |acc, x| acc + x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.sum()` +LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:19:19 + --> $DIR/unnecessary_fold.rs:14:24 | -LL | let _ = (0..3).fold(1, |acc, x| acc * x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.product()` +LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:24:34 + --> $DIR/unnecessary_fold.rs:19:40 | -LL | let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` +LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` error: aborting due to 5 previous errors diff --git a/tests/ui/unnecessary_operation.rs b/tests/ui/unnecessary_operation.rs index 34e1112f006..3c6796fea7b 100644 --- a/tests/ui/unnecessary_operation.rs +++ b/tests/ui/unnecessary_operation.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![feature(box_syntax)] #![allow(clippy::deref_addrof)] #![warn(clippy::unnecessary_operation)] diff --git a/tests/ui/unnecessary_operation.stderr b/tests/ui/unnecessary_operation.stderr index e46002dd97b..826bf6e2c28 100644 --- a/tests/ui/unnecessary_operation.stderr +++ b/tests/ui/unnecessary_operation.stderr @@ -1,5 +1,5 @@ error: statement can be reduced - --> $DIR/unnecessary_operation.rs:54:5 + --> $DIR/unnecessary_operation.rs:45:5 | LL | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` @@ -7,109 +7,109 @@ LL | Tuple(get_number()); = note: `-D clippy::unnecessary-operation` implied by `-D warnings` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:55:5 + --> $DIR/unnecessary_operation.rs:46:5 | LL | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:56:5 + --> $DIR/unnecessary_operation.rs:47:5 | LL | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:57:5 + --> $DIR/unnecessary_operation.rs:48:5 | LL | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:58:5 + --> $DIR/unnecessary_operation.rs:49:5 | LL | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:59:5 + --> $DIR/unnecessary_operation.rs:50:5 | LL | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:60:5 + --> $DIR/unnecessary_operation.rs:51:5 | LL | *&get_number(); | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:61:5 + --> $DIR/unnecessary_operation.rs:52:5 | LL | &get_number(); | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:62:5 + --> $DIR/unnecessary_operation.rs:53:5 | LL | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:63:5 + --> $DIR/unnecessary_operation.rs:54:5 | LL | box get_number(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:64:5 + --> $DIR/unnecessary_operation.rs:55:5 | LL | get_number()..; | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:65:5 + --> $DIR/unnecessary_operation.rs:56:5 | LL | ..get_number(); | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:66:5 + --> $DIR/unnecessary_operation.rs:57:5 | LL | 5..get_number(); | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:67:5 + --> $DIR/unnecessary_operation.rs:58:5 | LL | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:68:5 + --> $DIR/unnecessary_operation.rs:59:5 | LL | [42, 55][get_number() as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_number() as usize;` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:69:5 + --> $DIR/unnecessary_operation.rs:60:5 | LL | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:70:5 + --> $DIR/unnecessary_operation.rs:61:5 | LL | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:71:5 + --> $DIR/unnecessary_operation.rs:62:5 | LL | [42; 55][get_number() as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_number() as usize;` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:72:5 + --> $DIR/unnecessary_operation.rs:63:5 | LL | / { LL | | get_number() @@ -117,7 +117,7 @@ LL | | }; | |______^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:75:5 + --> $DIR/unnecessary_operation.rs:66:5 | LL | / FooString { LL | | s: String::from("blah"), diff --git a/tests/ui/unnecessary_ref.fixed b/tests/ui/unnecessary_ref.fixed index 3617641a116..f7b94118d4e 100644 --- a/tests/ui/unnecessary_ref.fixed +++ b/tests/ui/unnecessary_ref.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![feature(stmt_expr_attributes)] diff --git a/tests/ui/unnecessary_ref.rs b/tests/ui/unnecessary_ref.rs index 48101c87a54..4e585b9b96b 100644 --- a/tests/ui/unnecessary_ref.rs +++ b/tests/ui/unnecessary_ref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![feature(stmt_expr_attributes)] diff --git a/tests/ui/unnecessary_ref.stderr b/tests/ui/unnecessary_ref.stderr index 863a6389e7f..89adca3b1ad 100644 --- a/tests/ui/unnecessary_ref.stderr +++ b/tests/ui/unnecessary_ref.stderr @@ -1,11 +1,11 @@ error: Creating a reference that is immediately dereferenced. - --> $DIR/unnecessary_ref.rs:22:17 + --> $DIR/unnecessary_ref.rs:13:17 | LL | let inner = (&outer).inner; | ^^^^^^^^ help: try this: `outer` | note: lint level defined here - --> $DIR/unnecessary_ref.rs:19:8 + --> $DIR/unnecessary_ref.rs:10:8 | LL | #[deny(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unneeded_field_pattern.rs b/tests/ui/unneeded_field_pattern.rs index 14676c1e76f..fa639aa70d6 100644 --- a/tests/ui/unneeded_field_pattern.rs +++ b/tests/ui/unneeded_field_pattern.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::unneeded_field_pattern)] #[allow(dead_code, unused)] diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 23e35923f83..e7b92ce1e19 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,5 +1,5 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead - --> $DIR/unneeded_field_pattern.rs:23:15 + --> $DIR/unneeded_field_pattern.rs:14:15 | LL | Foo { a: _, b: 0, .. } => {}, | ^^^^ @@ -8,7 +8,7 @@ LL | Foo { a: _, b: 0, .. } => {}, = help: Try with `Foo { b: 0, .. }` error: All the struct fields are matched to a wildcard pattern, consider using `..`. - --> $DIR/unneeded_field_pattern.rs:25:9 + --> $DIR/unneeded_field_pattern.rs:16:9 | LL | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unreadable_literal.fixed b/tests/ui/unreadable_literal.fixed index 4c466035a04..eede10c771c 100644 --- a/tests/ui/unreadable_literal.fixed +++ b/tests/ui/unreadable_literal.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[warn(clippy::unreadable_literal)] diff --git a/tests/ui/unreadable_literal.rs b/tests/ui/unreadable_literal.rs index 8ade2f6a863..6523f70186f 100644 --- a/tests/ui/unreadable_literal.rs +++ b/tests/ui/unreadable_literal.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #[warn(clippy::unreadable_literal)] diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index 68580485853..8334139120e 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -1,5 +1,5 @@ error: long literal lacking separators - --> $DIR/unreadable_literal.rs:26:16 + --> $DIR/unreadable_literal.rs:17:16 | LL | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` @@ -7,25 +7,25 @@ LL | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32) = note: `-D clippy::unreadable-literal` implied by `-D warnings` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:26:30 + --> $DIR/unreadable_literal.rs:17:30 | LL | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:26:51 + --> $DIR/unreadable_literal.rs:17:51 | LL | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:26:63 + --> $DIR/unreadable_literal.rs:17:63 | LL | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:28:19 + --> $DIR/unreadable_literal.rs:19:19 | LL | let bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` diff --git a/tests/ui/unsafe_removed_from_name.rs b/tests/ui/unsafe_removed_from_name.rs index bfab077375d..a1f616733bd 100644 --- a/tests/ui/unsafe_removed_from_name.rs +++ b/tests/ui/unsafe_removed_from_name.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused_imports)] #![allow(dead_code)] #![warn(clippy::unsafe_removed_from_name)] diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index cdc2b907ec5..1b1c62430b2 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -1,5 +1,5 @@ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell` - --> $DIR/unsafe_removed_from_name.rs:14:1 + --> $DIR/unsafe_removed_from_name.rs:5:1 | LL | use std::cell::UnsafeCell as TotallySafeCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | use std::cell::UnsafeCell as TotallySafeCell; = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` - --> $DIR/unsafe_removed_from_name.rs:16:1 + --> $DIR/unsafe_removed_from_name.rs:7:1 | LL | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed "unsafe" from the name of `Unsafe` in use as `LieAboutModSafety` - --> $DIR/unsafe_removed_from_name.rs:30:1 + --> $DIR/unsafe_removed_from_name.rs:21:1 | LL | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index 4e721527249..c8a38f9fe57 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code)] #![warn(clippy::unused_io_amount)] diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 528d35ebdef..2d00338193c 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -1,5 +1,5 @@ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:16:5 + --> $DIR/unused_io_amount.rs:7:5 | LL | try!(s.write(b"test")); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | try!(s.write(b"test")); = 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: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:18:5 + --> $DIR/unused_io_amount.rs:9:5 | LL | try!(s.read(&mut buf)); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,25 +16,25 @@ LL | try!(s.read(&mut buf)); = 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: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:23:5 + --> $DIR/unused_io_amount.rs:14:5 | LL | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:25:5 + --> $DIR/unused_io_amount.rs:16:5 | LL | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:30:5 + --> $DIR/unused_io_amount.rs:21:5 | LL | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:32:5 + --> $DIR/unused_io_amount.rs:23:5 | LL | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unused_labels.rs b/tests/ui/unused_labels.rs index 8db29dcf3fc..ae963ad6969 100644 --- a/tests/ui/unused_labels.rs +++ b/tests/ui/unused_labels.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(dead_code, clippy::items_after_statements, clippy::never_loop)] #![warn(clippy::unused_label)] diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index 07ff5083ed2..d2ca0f1b57f 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -1,5 +1,5 @@ error: unused label `'label` - --> $DIR/unused_labels.rs:14:5 + --> $DIR/unused_labels.rs:5:5 | LL | / 'label: for i in 1..2 { LL | | if i > 4 { @@ -11,7 +11,7 @@ LL | | } = note: `-D clippy::unused-label` implied by `-D warnings` error: unused label `'a` - --> $DIR/unused_labels.rs:28:5 + --> $DIR/unused_labels.rs:19:5 | LL | / 'a: loop { LL | | break; @@ -19,7 +19,7 @@ LL | | } | |_____^ error: unused label `'same_label_in_two_fns` - --> $DIR/unused_labels.rs:41:5 + --> $DIR/unused_labels.rs:32:5 | LL | / 'same_label_in_two_fns: loop { LL | | let _ = 1; diff --git a/tests/ui/unused_lt.rs b/tests/ui/unused_lt.rs index 99e80103f1f..ba7c42b3a90 100644 --- a/tests/ui/unused_lt.rs +++ b/tests/ui/unused_lt.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow( unused, dead_code, diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index 30ce7b68578..bf4aedd52a9 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -1,5 +1,5 @@ error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:23:14 + --> $DIR/unused_lt.rs:14:14 | LL | fn unused_lt<'a>(x: u8) {} | ^^ @@ -7,13 +7,13 @@ LL | fn unused_lt<'a>(x: u8) {} = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:25:25 + --> $DIR/unused_lt.rs:16:25 | LL | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { | ^^ error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:50:10 + --> $DIR/unused_lt.rs:41:10 | LL | fn x<'a>(&self) {} | ^^ diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index 88f0b9687be..8d56d2051e2 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -1,13 +1,3 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // compile-pass // The output for humans should just highlight the whole span without showing diff --git a/tests/ui/unused_unit.stderr b/tests/ui/unused_unit.stderr index ac76d75b176..c4cb643cb71 100644 --- a/tests/ui/unused_unit.stderr +++ b/tests/ui/unused_unit.stderr @@ -1,5 +1,5 @@ error: unneeded unit return type - --> $DIR/unused_unit.rs:25:59 + --> $DIR/unused_unit.rs:15:59 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> | ___________________________________________________________^ @@ -7,43 +7,43 @@ LL | | () | |__________^ help: remove the `-> ()` | note: lint level defined here - --> $DIR/unused_unit.rs:19:9 + --> $DIR/unused_unit.rs:9:9 | LL | #![deny(clippy::unused_unit)] | ^^^^^^^^^^^^^^^^^^^ error: unneeded unit return type - --> $DIR/unused_unit.rs:35:19 + --> $DIR/unused_unit.rs:25:19 | LL | fn into(self) -> () { | ^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:36:9 + --> $DIR/unused_unit.rs:26:9 | LL | () | ^^ help: remove the final `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:40:18 + --> $DIR/unused_unit.rs:30:18 | LL | fn return_unit() -> () { () } | ^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:40:26 + --> $DIR/unused_unit.rs:30:26 | LL | fn return_unit() -> () { () } | ^^ help: remove the final `()` error: unneeded `()` - --> $DIR/unused_unit.rs:47:14 + --> $DIR/unused_unit.rs:37:14 | LL | break(); | ^^ help: remove the `()` error: unneeded `()` - --> $DIR/unused_unit.rs:49:11 + --> $DIR/unused_unit.rs:39:11 | LL | return(); | ^^ help: remove the `()` diff --git a/tests/ui/unwrap_or.rs b/tests/ui/unwrap_or.rs index 8573f78d43b..bfb41e43947 100644 --- a/tests/ui/unwrap_or.rs +++ b/tests/ui/unwrap_or.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] fn main() { diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index 3970b68de7a..c3a7464fd47 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:13:47 + --> $DIR/unwrap_or.rs:4:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` @@ -7,7 +7,7 @@ LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()) = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:17:47 + --> $DIR/unwrap_or.rs:8:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` diff --git a/tests/ui/update-all-references.sh b/tests/ui/update-all-references.sh index acc38f15fbd..f438d442ca1 100755 --- a/tests/ui/update-all-references.sh +++ b/tests/ui/update-all-references.sh @@ -1,14 +1,4 @@ #!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. # A script to update the references for all tests. The idea is that # you do a run, which will generate files in the build directory diff --git a/tests/ui/update-references.sh b/tests/ui/update-references.sh index d6995985a3b..c553e4ef2e3 100755 --- a/tests/ui/update-references.sh +++ b/tests/ui/update-references.sh @@ -1,14 +1,4 @@ #!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. # A script to update the references for particular tests. The idea is # that you do a run, which will generate files in the build directory diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed new file mode 100644 index 00000000000..5eae9a7a806 --- /dev/null +++ b/tests/ui/use_self.fixed @@ -0,0 +1,299 @@ +// run-rustfix + +#![warn(clippy::use_self)] +#![allow(dead_code)] +#![allow(clippy::should_implement_trait)] + +fn main() {} + +mod use_self { + struct Foo {} + + impl Foo { + fn new() -> Self { + Self {} + } + fn test() -> Self { + Self::new() + } + } + + impl Default for Foo { + fn default() -> Self { + Self::new() + } + } +} + +mod better { + struct Foo {} + + impl Foo { + fn new() -> Self { + Self {} + } + fn test() -> Self { + Self::new() + } + } + + impl Default for Foo { + fn default() -> Self { + Self::new() + } + } +} + +mod lifetimes { + struct Foo<'a> { + foo_str: &'a str, + } + + impl<'a> Foo<'a> { + // Cannot use `Self` as return type, because the function is actually `fn foo<'b>(s: &'b str) -> + // Foo<'b>` + fn foo(s: &str) -> Foo { + Foo { foo_str: s } + } + // cannot replace with `Self`, because that's `Foo<'a>` + fn bar() -> Foo<'static> { + Foo { foo_str: "foo" } + } + + // FIXME: the lint does not handle lifetimed struct + // `Self` should be applicable here + fn clone(&self) -> Foo<'a> { + Foo { foo_str: self.foo_str } + } + } +} + +#[allow(clippy::boxed_local)] +mod traits { + + use std::ops::Mul; + + trait SelfTrait { + fn refs(p1: &Self) -> &Self; + fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self; + fn mut_refs(p1: &mut Self) -> &mut Self; + fn nested(p1: Box, p2: (&u8, &Self)); + fn vals(r: Self) -> Self; + } + + #[derive(Default)] + struct Bad; + + impl SelfTrait for Bad { + fn refs(p1: &Self) -> &Self { + p1 + } + + fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self { + p1 + } + + fn mut_refs(p1: &mut Self) -> &mut Self { + p1 + } + + fn nested(_p1: Box, _p2: (&u8, &Self)) {} + + fn vals(_: Self) -> Self { + Self::default() + } + } + + impl Mul for Bad { + type Output = Self; + + fn mul(self, rhs: Self) -> Self { + rhs + } + } + + #[derive(Default)] + struct Good; + + impl SelfTrait for Good { + fn refs(p1: &Self) -> &Self { + p1 + } + + fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self { + p1 + } + + fn mut_refs(p1: &mut Self) -> &mut Self { + p1 + } + + fn nested(_p1: Box, _p2: (&u8, &Self)) {} + + fn vals(_: Self) -> Self { + Self::default() + } + } + + impl Mul for Good { + type Output = Self; + + fn mul(self, rhs: Self) -> Self { + rhs + } + } + + trait NameTrait { + fn refs(p1: &u8) -> &u8; + fn ref_refs<'a>(p1: &'a &'a u8) -> &'a &'a u8; + fn mut_refs(p1: &mut u8) -> &mut u8; + fn nested(p1: Box, p2: (&u8, &u8)); + fn vals(p1: u8) -> u8; + } + + // Using `Self` instead of the type name is OK + impl NameTrait for u8 { + fn refs(p1: &Self) -> &Self { + p1 + } + + fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self { + p1 + } + + fn mut_refs(p1: &mut Self) -> &mut Self { + p1 + } + + fn nested(_p1: Box, _p2: (&Self, &Self)) {} + + fn vals(_: Self) -> Self { + Self::default() + } + } + + // Check that self arg isn't linted + impl Clone for Good { + fn clone(&self) -> Self { + // Note: Not linted and it wouldn't be valid + // because "can't use `Self` as a constructor`" + Good + } + } +} + +mod issue2894 { + trait IntoBytes { + fn into_bytes(&self) -> Vec; + } + + // This should not be linted + impl IntoBytes for u8 { + fn into_bytes(&self) -> Vec { + vec![*self] + } + } +} + +mod existential { + struct Foo; + + impl Foo { + fn bad(foos: &[Self]) -> impl Iterator { + foos.iter() + } + + fn good(foos: &[Self]) -> impl Iterator { + foos.iter() + } + } +} + +mod tuple_structs { + pub struct TS(i32); + + impl TS { + pub fn ts() -> Self { + Self(0) + } + } +} + +mod macros { + macro_rules! use_self_expand { + () => { + fn new() -> Self { + Self {} + } + }; + } + + struct Foo {} + + impl Foo { + use_self_expand!(); // Should lint in local macros + } +} + +mod nesting { + struct Foo {} + impl Foo { + fn foo() { + use self::Foo; // Can't use Self here + struct Bar { + foo: Foo, // Foo != Self + } + + impl Bar { + fn bar() -> Self { + Self { foo: Foo {} } + } + } + } + } + + enum Enum { + A, + } + impl Enum { + fn method() { + #[allow(unused_imports)] + use self::Enum::*; // Issue 3425 + static STATIC: Enum = Enum::A; // Can't use Self as type + } + } +} + +mod issue3410 { + + struct A; + struct B; + + trait Trait { + fn a(v: T); + } + + impl Trait> for Vec { + fn a(_: Vec) {} + } +} + +#[allow(clippy::no_effect, path_statements)] +mod rustfix { + mod nested { + pub struct A {} + } + + impl nested::A { + const A: bool = true; + + fn fun_1() {} + + fn fun_2() { + Self::fun_1(); + Self::A; + + Self {}; + } + } +} diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index a117ce5894b..8e28bbbeb9c 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -1,11 +1,4 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// run-rustfix #![warn(clippy::use_self)] #![allow(dead_code)] @@ -264,6 +257,7 @@ mod nesting { } impl Enum { fn method() { + #[allow(unused_imports)] use self::Enum::*; // Issue 3425 static STATIC: Enum = Enum::A; // Can't use Self as type } @@ -283,3 +277,23 @@ mod issue3410 { fn a(_: Vec) {} } } + +#[allow(clippy::no_effect, path_statements)] +mod rustfix { + mod nested { + pub struct A {} + } + + impl nested::A { + const A: bool = true; + + fn fun_1() {} + + fn fun_2() { + nested::A::fun_1(); + nested::A::A; + + nested::A {}; + } + } +} diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 72b60db7fd2..af9e15edb6c 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:20:21 + --> $DIR/use_self.rs:13:21 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` @@ -7,133 +7,133 @@ LL | fn new() -> Foo { = note: `-D clippy::use-self` implied by `-D warnings` error: unnecessary structure name repetition - --> $DIR/use_self.rs:21:13 + --> $DIR/use_self.rs:14:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:23:22 + --> $DIR/use_self.rs:16:22 | LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:24:13 + --> $DIR/use_self.rs:17:13 | LL | Foo::new() - | ^^^^^^^^ help: use the applicable keyword: `Self` + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:29:25 + --> $DIR/use_self.rs:22:25 | LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:30:13 + --> $DIR/use_self.rs:23:13 | LL | Foo::new() - | ^^^^^^^^ help: use the applicable keyword: `Self` + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:95:22 + --> $DIR/use_self.rs:88:22 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:95:31 + --> $DIR/use_self.rs:88:31 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:99:37 + --> $DIR/use_self.rs:92:37 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:99:53 + --> $DIR/use_self.rs:92:53 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:103:30 + --> $DIR/use_self.rs:96:30 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:103:43 + --> $DIR/use_self.rs:96:43 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:107:28 + --> $DIR/use_self.rs:100:28 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:107:46 + --> $DIR/use_self.rs:100:46 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:109:20 + --> $DIR/use_self.rs:102:20 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:109:28 + --> $DIR/use_self.rs:102:28 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:110:13 + --> $DIR/use_self.rs:103:13 | LL | Bad::default() - | ^^^^^^^^^^^^ help: use the applicable keyword: `Self` + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:115:23 + --> $DIR/use_self.rs:108:23 | LL | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:117:27 + --> $DIR/use_self.rs:110:27 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:117:35 + --> $DIR/use_self.rs:110:35 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:209:56 + --> $DIR/use_self.rs:202:56 | LL | fn bad(foos: &[Self]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:224:13 + --> $DIR/use_self.rs:217:13 | LL | TS(0) | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:232:25 + --> $DIR/use_self.rs:225:25 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` @@ -142,7 +142,7 @@ LL | use_self_expand!(); // Should lint in local macros | ------------------- in this macro invocation error: unnecessary structure name repetition - --> $DIR/use_self.rs:233:17 + --> $DIR/use_self.rs:226:17 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` @@ -151,16 +151,34 @@ LL | use_self_expand!(); // Should lint in local macros | ------------------- in this macro invocation error: unnecessary structure name repetition - --> $DIR/use_self.rs:255:29 + --> $DIR/use_self.rs:248:29 | LL | fn bar() -> Bar { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:256:21 + --> $DIR/use_self.rs:249:21 | LL | Bar { foo: Foo {} } | ^^^ help: use the applicable keyword: `Self` -error: aborting due to 26 previous errors +error: unnecessary structure name repetition + --> $DIR/use_self.rs:293:13 + | +LL | nested::A::fun_1(); + | ^^^^^^^^^ help: use the applicable keyword: `Self` + +error: unnecessary structure name repetition + --> $DIR/use_self.rs:294:13 + | +LL | nested::A::A; + | ^^^^^^^^^ help: use the applicable keyword: `Self` + +error: unnecessary structure name repetition + --> $DIR/use_self.rs:296:13 + | +LL | nested::A {}; + | ^^^^^^^^^ help: use the applicable keyword: `Self` + +error: aborting due to 29 previous errors diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index bd20cc5f48a..702f1793ed5 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::all)] #![allow(clippy::blacklisted_name)] #![warn(clippy::used_underscore_binding)] diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 798dde2ea0e..2e2f2056d84 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,5 +1,5 @@ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:23:5 + --> $DIR/used_underscore_binding.rs:14:5 | LL | _foo + 1 | ^^^^ @@ -7,25 +7,25 @@ LL | _foo + 1 = note: `-D clippy::used-underscore-binding` implied by `-D warnings` error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:28:20 + --> $DIR/used_underscore_binding.rs:19:20 | LL | println!("{}", _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:29:16 + --> $DIR/used_underscore_binding.rs:20:16 | LL | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:29:22 + --> $DIR/used_underscore_binding.rs:20:22 | LL | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:42:5 + --> $DIR/used_underscore_binding.rs:33:5 | LL | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/useful_asref.rs b/tests/ui/useful_asref.rs index d7e56af2590..a9f0170a79c 100644 --- a/tests/ui/useful_asref.rs +++ b/tests/ui/useful_asref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::useless_asref)] trait Trait { diff --git a/tests/ui/useless_asref.rs b/tests/ui/useless_asref.rs index 34c0f5095db..fe3dae5fc4c 100644 --- a/tests/ui/useless_asref.rs +++ b/tests/ui/useless_asref.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![deny(clippy::useless_asref)] #![allow(clippy::trivially_copy_pass_by_ref)] use std::fmt::Debug; diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 2e4a7f80444..cc594559032 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,71 +1,71 @@ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:50:18 + --> $DIR/useless_asref.rs:41:18 | LL | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try this: `rstr` | note: lint level defined here - --> $DIR/useless_asref.rs:10:9 + --> $DIR/useless_asref.rs:1:9 | LL | #![deny(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:52:20 + --> $DIR/useless_asref.rs:43:20 | LL | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try this: `rslice` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:56:21 + --> $DIR/useless_asref.rs:47:21 | LL | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:58:20 + --> $DIR/useless_asref.rs:49:20 | LL | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:65:20 + --> $DIR/useless_asref.rs:56:20 | LL | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:67:18 + --> $DIR/useless_asref.rs:58:18 | LL | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:72:21 + --> $DIR/useless_asref.rs:63:21 | LL | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:74:20 + --> $DIR/useless_asref.rs:65:20 | LL | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:77:16 + --> $DIR/useless_asref.rs:68:16 | LL | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:127:13 + --> $DIR/useless_asref.rs:118:13 | LL | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try this: `mrt` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:129:12 + --> $DIR/useless_asref.rs:120:12 | LL | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try this: `mrt` diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index 2d7a9ae04d1..7da251101f5 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::useless_attribute)] #[allow(dead_code)] diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index b9340ce8c02..2f7a010fc3e 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,5 +1,5 @@ error: useless lint attribute - --> $DIR/useless_attribute.rs:12:1 + --> $DIR/useless_attribute.rs:3:1 | LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` @@ -7,7 +7,7 @@ LL | #[allow(dead_code)] = note: `-D clippy::useless-attribute` implied by `-D warnings` error: useless lint attribute - --> $DIR/useless_attribute.rs:13:1 + --> $DIR/useless_attribute.rs:4:1 | LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` diff --git a/tests/ui/vec.fixed b/tests/ui/vec.fixed index 2eaba1c408a..e73a791891f 100644 --- a/tests/ui/vec.fixed +++ b/tests/ui/vec.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![warn(clippy::useless_vec)] diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index 1648215ed35..3eb960f53d7 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![warn(clippy::useless_vec)] diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index 96dd187ccc5..37e28ebddb5 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,5 +1,5 @@ error: useless use of `vec!` - --> $DIR/vec.rs:32:14 + --> $DIR/vec.rs:23:14 | LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` @@ -7,31 +7,31 @@ LL | on_slice(&vec![]); = note: `-D clippy::useless-vec` implied by `-D warnings` error: useless use of `vec!` - --> $DIR/vec.rs:35:14 + --> $DIR/vec.rs:26:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:38:14 + --> $DIR/vec.rs:29:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:41:14 + --> $DIR/vec.rs:32:14 | LL | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:44:14 + --> $DIR/vec.rs:35:14 | LL | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:57:14 + --> $DIR/vec.rs:48:14 | LL | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` diff --git a/tests/ui/while_loop.rs b/tests/ui/while_loop.rs index e4c7047df91..8c3bf1cc674 100644 --- a/tests/ui/while_loop.rs +++ b/tests/ui/while_loop.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::while_let_loop, clippy::empty_loop, clippy::while_let_on_iterator)] #![allow(dead_code, clippy::never_loop, unused, clippy::cyclomatic_complexity)] @@ -225,4 +216,14 @@ fn refutable() { while let Some(..) = values.iter().next() { values.remove(&1); } + + // Issue 3670 + { + let array = [Some(0), None, Some(1)]; + let mut iter = array.iter(); + + while let Some(elem) = iter.next() { + let _ = elem.or_else(|| *iter.next()?); + } + } } diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index 0e6c97e48d4..dde98da46c3 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -1,5 +1,5 @@ error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:15:5 + --> $DIR/while_loop.rs:6:5 | LL | / loop { LL | | if let Some(_x) = y { @@ -13,7 +13,7 @@ LL | | } = note: `-D clippy::while-let-loop` implied by `-D warnings` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:29:5 + --> $DIR/while_loop.rs:20:5 | LL | / loop { LL | | match y { @@ -24,7 +24,7 @@ LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:35:5 + --> $DIR/while_loop.rs:26:5 | LL | / loop { LL | | let x = match y { @@ -36,7 +36,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:43:5 + --> $DIR/while_loop.rs:34:5 | LL | / loop { LL | | let x = match y { @@ -48,7 +48,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:71:5 + --> $DIR/while_loop.rs:62:5 | LL | / loop { LL | | let (e, l) = match "".split_whitespace().next() { @@ -60,7 +60,7 @@ LL | | } | |_____^ help: try: `while let Some(word) = "".split_whitespace().next() { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:81:33 + --> $DIR/while_loop.rs:72:33 | LL | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` @@ -68,19 +68,19 @@ LL | while let Option::Some(x) = iter.next() { = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:86:25 + --> $DIR/while_loop.rs:77:25 | LL | while let Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:91:25 + --> $DIR/while_loop.rs:82:25 | LL | while let Some(_) = iter.next() {} | ^^^^^^^^^^^ help: try: `for _ in iter { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:134:5 + --> $DIR/while_loop.rs:125:5 | LL | / loop { LL | | let _ = match iter.next() { @@ -92,7 +92,7 @@ LL | | } | |_____^ help: try: `while let Some(ele) = iter.next() { .. }` error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body. - --> $DIR/while_loop.rs:139:9 + --> $DIR/while_loop.rs:130:9 | LL | loop {} | ^^^^^^^ @@ -100,13 +100,13 @@ LL | loop {} = note: `-D clippy::empty-loop` implied by `-D warnings` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:197:29 + --> $DIR/while_loop.rs:188:29 | LL | while let Some(v) = y.next() { | ^^^^^^^^ help: try: `for v in y { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:225:26 + --> $DIR/while_loop.rs:216:26 | LL | while let Some(..) = values.iter().next() { | ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }` diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index 0ba1943e6d8..d8205c5eb67 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(unused_must_use)] #![warn(clippy::write_literal)] diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 7daf52a4445..54a787fe555 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:36:79 + --> $DIR/write_literal.rs:27:79 | LL | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ @@ -7,79 +7,79 @@ LL | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't = note: `-D clippy::write-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/write_literal.rs:37:32 + --> $DIR/write_literal.rs:28:32 | LL | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:38:44 + --> $DIR/write_literal.rs:29:44 | LL | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:39:34 + --> $DIR/write_literal.rs:30:34 | LL | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:40:38 + --> $DIR/write_literal.rs:31:38 | LL | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:36 + --> $DIR/write_literal.rs:32:36 | LL | writeln!(&mut v, "2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/write_literal.rs:46:33 + --> $DIR/write_literal.rs:37:33 | LL | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:46:42 + --> $DIR/write_literal.rs:37:42 | LL | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:47:33 + --> $DIR/write_literal.rs:38:33 | LL | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:47:42 + --> $DIR/write_literal.rs:38:42 | LL | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:50:43 + --> $DIR/write_literal.rs:41:43 | LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:50:58 + --> $DIR/write_literal.rs:41:58 | LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:51:43 + --> $DIR/write_literal.rs:42:43 | LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:51:58 + --> $DIR/write_literal.rs:42:58 | LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs index 5d8543e578d..2f53d4561af 100644 --- a/tests/ui/write_with_newline.rs +++ b/tests/ui/write_with_newline.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![allow(clippy::write_literal)] #![warn(clippy::write_with_newline)] diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index c18ec184876..1f4395c2621 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,5 +1,5 @@ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:19:5 + --> $DIR/write_with_newline.rs:10:5 | LL | write!(&mut v, "Hello/n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ LL | write!(&mut v, "Hello/n"); = note: `-D clippy::write-with-newline` implied by `-D warnings` error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:20:5 + --> $DIR/write_with_newline.rs:11:5 | LL | write!(&mut v, "Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:21:5 + --> $DIR/write_with_newline.rs:12:5 | LL | write!(&mut v, "Hello {} {}/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:22:5 + --> $DIR/write_with_newline.rs:13:5 | LL | write!(&mut v, "{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:41:5 + --> $DIR/write_with_newline.rs:32:5 | LL | write!(&mut v, "//n"); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/writeln_empty_string.fixed b/tests/ui/writeln_empty_string.fixed index 68b8185083d..c3ac15b0375 100644 --- a/tests/ui/writeln_empty_string.fixed +++ b/tests/ui/writeln_empty_string.fixed @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![allow(unused_must_use)] diff --git a/tests/ui/writeln_empty_string.rs b/tests/ui/writeln_empty_string.rs index ba43552af23..9a8894b6c0d 100644 --- a/tests/ui/writeln_empty_string.rs +++ b/tests/ui/writeln_empty_string.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // run-rustfix #![allow(unused_must_use)] diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 119710c0cdb..99635229b3e 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,5 +1,5 @@ error: using `writeln!(&mut v, "")` - --> $DIR/writeln_empty_string.rs:20:5 + --> $DIR/writeln_empty_string.rs:11:5 | LL | writeln!(&mut v, ""); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` @@ -7,7 +7,7 @@ LL | writeln!(&mut v, ""); = note: `-D clippy::writeln-empty-string` implied by `-D warnings` error: using `writeln!(&mut suggestion, "")` - --> $DIR/writeln_empty_string.rs:23:5 + --> $DIR/writeln_empty_string.rs:14:5 | LL | writeln!(&mut suggestion, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)` diff --git a/tests/ui/wrong_self_convention.rs b/tests/ui/wrong_self_convention.rs index 3c69c9ad03f..bdffb5af87e 100644 --- a/tests/ui/wrong_self_convention.rs +++ b/tests/ui/wrong_self_convention.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(clippy::wrong_self_convention)] #![warn(clippy::wrong_pub_self_convention)] #![allow(dead_code, clippy::trivially_copy_pass_by_ref)] diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index f9d20cb3d47..0d0eb19cd07 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,5 +1,5 @@ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:26:17 + --> $DIR/wrong_self_convention.rs:17:17 | LL | fn from_i32(self) {} | ^^^^ @@ -7,67 +7,67 @@ LL | fn from_i32(self) {} = note: `-D clippy::wrong-self-convention` implied by `-D warnings` error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:32:21 + --> $DIR/wrong_self_convention.rs:23:21 | LL | pub fn from_i64(self) {} | ^^^^ error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:44:15 + --> $DIR/wrong_self_convention.rs:35:15 | LL | fn as_i32(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:46:17 + --> $DIR/wrong_self_convention.rs:37:17 | LL | fn into_i32(&self) {} | ^^^^^ error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:48:15 + --> $DIR/wrong_self_convention.rs:39:15 | LL | fn is_i32(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:50:15 + --> $DIR/wrong_self_convention.rs:41:15 | LL | fn to_i32(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:52:17 + --> $DIR/wrong_self_convention.rs:43:17 | LL | fn from_i32(self) {} | ^^^^ error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:54:19 + --> $DIR/wrong_self_convention.rs:45:19 | LL | pub fn as_i64(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:55:21 + --> $DIR/wrong_self_convention.rs:46:21 | LL | pub fn into_i64(&self) {} | ^^^^^ error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:56:19 + --> $DIR/wrong_self_convention.rs:47:19 | LL | pub fn is_i64(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:57:19 + --> $DIR/wrong_self_convention.rs:48:19 | LL | pub fn to_i64(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:58:21 + --> $DIR/wrong_self_convention.rs:49:21 | LL | pub fn from_i64(self) {} | ^^^^ diff --git a/tests/ui/zero_div_zero.rs b/tests/ui/zero_div_zero.rs index 68e9437273f..09db130a764 100644 --- a/tests/ui/zero_div_zero.rs +++ b/tests/ui/zero_div_zero.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(unused_variables)] #[warn(clippy::zero_divided_by_zero)] fn main() { diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 653a76c6978..763859f54fb 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,5 +1,5 @@ error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:13:15 + --> $DIR/zero_div_zero.rs:4:15 | LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let nan = 0.0 / 0.0; = note: #[deny(clippy::eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:13:15 + --> $DIR/zero_div_zero.rs:4:15 | LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ @@ -16,13 +16,13 @@ LL | let nan = 0.0 / 0.0; = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:14:19 + --> $DIR/zero_div_zero.rs:5:19 | LL | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:14:19 + --> $DIR/zero_div_zero.rs:5:19 | LL | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ @@ -30,13 +30,13 @@ LL | let f64_nan = 0.0 / 0.0f64; = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:15:25 + --> $DIR/zero_div_zero.rs:6:25 | LL | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:15:25 + --> $DIR/zero_div_zero.rs:6:25 | LL | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ @@ -44,13 +44,13 @@ LL | let other_f64_nan = 0.0f64 / 0.0; = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:16:28 + --> $DIR/zero_div_zero.rs:7:28 | LL | let one_more_f64_nan = 0.0f64 / 0.0f64; | ^^^^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:16:28 + --> $DIR/zero_div_zero.rs:7:28 | LL | let one_more_f64_nan = 0.0f64 / 0.0f64; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/zero_ptr.rs b/tests/ui/zero_ptr.rs index 9930b8a4c6b..2291c77d56e 100644 --- a/tests/ui/zero_ptr.rs +++ b/tests/ui/zero_ptr.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[allow(unused_variables)] fn main() { let x = 0 as *const usize; diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 5aa5e275ee6..b79c3457b9b 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -1,5 +1,5 @@ error: `0 as *const _` detected. Consider using `ptr::null()` - --> $DIR/zero_ptr.rs:12:13 + --> $DIR/zero_ptr.rs:3:13 | LL | let x = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let x = 0 as *const usize; = note: `-D clippy::zero-ptr` implied by `-D warnings` error: `0 as *mut _` detected. Consider using `ptr::null_mut()` - --> $DIR/zero_ptr.rs:13:13 + --> $DIR/zero_ptr.rs:4:13 | LL | let y = 0 as *mut f64; | ^^^^^^^^^^^^^ diff --git a/tests/versioncheck.rs b/tests/versioncheck.rs index 945e35f4ebf..9e00571c9d5 100644 --- a/tests/versioncheck.rs +++ b/tests/versioncheck.rs @@ -1,12 +1,3 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use semver::VersionReq; #[test] diff --git a/util/cov.sh b/util/cov.sh index d927a5cfcd0..3f9a6b06f72 100755 --- a/util/cov.sh +++ b/util/cov.sh @@ -1,16 +1,5 @@ #!/usr/bin/bash -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - - # This run `kcov` on Clippy. The coverage report will be at # `./target/cov/index.html`. # `compile-test` is special. `kcov` does not work directly on it so these files diff --git a/util/export.py b/util/export.py index d8598ed8037..827b1e31905 100755 --- a/util/export.py +++ b/util/export.py @@ -1,16 +1,5 @@ #!/usr/bin/env python -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - - # Build the gh-pages import re diff --git a/util/lintlib.py b/util/lintlib.py index 098fcf256a6..1c49ab770d5 100644 --- a/util/lintlib.py +++ b/util/lintlib.py @@ -1,13 +1,3 @@ -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - # Common utils for the several housekeeping scripts. import os diff --git a/util/update_lints.py b/util/update_lints.py index 4467b5c0cf7..1800fa05c90 100755 --- a/util/update_lints.py +++ b/util/update_lints.py @@ -1,15 +1,5 @@ #!/usr/bin/env python -# Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - import sys def main():