diff options
| author | Peter Fürstenau <fuerstenau@mathematik.tu-darmstadt.de> | 2018-12-28 20:19:51 +0100 |
|---|---|---|
| committer | Peter Fürstenau <fuerstenau@mathematik.tu-darmstadt.de> | 2018-12-28 20:19:51 +0100 |
| commit | 6ee0e222040382d210ef68acf7b7c57c23a42ecf (patch) | |
| tree | 1c7442c70136ce6c806c5a18e61503db17b565f7 | |
| parent | 65c35333a4269a987350272339f3a078fd64f2b7 (diff) | |
| parent | f7bdf500d93895b6c02f8ae6a73002207f85e523 (diff) | |
| download | rust-6ee0e222040382d210ef68acf7b7c57c23a42ecf.tar.gz rust-6ee0e222040382d210ef68acf7b7c57c23a42ecf.zip | |
Merge remote-tracking branch 'upstream/master'
265 files changed, 5099 insertions, 5054 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1713fda031f..606f16061ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -760,6 +760,7 @@ All notable changes to this project will be documented in this file. [`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes [`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals [`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception +[`module_name_repetitions`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions [`modulo_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_one [`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions [`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl @@ -850,7 +851,6 @@ All notable changes to this project will be documented in this file. [`string_extend_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_extend_chars [`string_lit_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_lit_as_bytes [`string_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_to_string -[`stutter`]: https://rust-lang.github.io/rust-clippy/master/index.html#stutter [`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl [`suspicious_assignment_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_assignment_formatting [`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5548bdd732..94120a3771a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,8 +19,8 @@ All contributors are expected to follow the [Rust Code of Conduct](http://www.ru * [Running test suite](#running-test-suite) * [Running rustfmt](#running-rustfmt) * [Testing manually](#testing-manually) - * [How Clippy works](#how-clippy-works) - * [Fixing nightly build failures](#fixing-build-failures-caused-by-rust) +* [How Clippy works](#how-clippy-works) +* [Fixing nightly build failures](#fixing-build-failures-caused-by-rust) * [Issue and PR Triage](#issue-and-pr-triage) * [Bors and Homu](#bors-and-homu) * [Contributions](#contributions) @@ -42,6 +42,13 @@ Some issues are easier than others. The [`good first issue`](https://github.com/ label can be used to find the easy issues. If you want to work on an issue, please leave a comment so that we can assign it to you! +There are also some abandoned PRs, marked with +[`S-inactive-closed`](https://github.com/rust-lang/rust-clippy/pulls?q=is%3Aclosed+label%3AS-inactive-closed). +Pretty often these PRs are nearly completed and just need some extra steps +(formatting, addressing review comments, ...) to be merged. If you want to +complete such a PR, please leave a comment in the PR and open a new one based +on it. + Issues marked [`T-AST`](https://github.com/rust-lang/rust-clippy/labels/T-AST) involve simple matching of the syntax tree structure, and are generally easier than [`T-middle`](https://github.com/rust-lang/rust-clippy/labels/T-middle) issues, which involve types @@ -168,7 +175,7 @@ Manually testing against an example file is useful if you have added some local modifications, run `env CLIPPY_TESTS=true cargo run --bin clippy-driver -- -L ./target/debug input.rs` from the working copy root. -### How Clippy works +## How Clippy works Clippy is a [rustc compiler plugin][compiler_plugin]. The main entry point is at [`src/lib.rs`][main_entry]. In there, the lint registration is delegated to the [`clippy_lints`][lint_crate] crate. @@ -218,7 +225,7 @@ The difference between `EarlyLintPass` and `LateLintPass` is that the methods of That's why the `else_if_without_else` example uses the `register_early_lint_pass` function. Because the [actual lint logic][else_if_without_else] does not depend on any type information. -### Fixing build failures caused by Rust +## Fixing build failures caused by Rust Clippy will sometimes fail to build from source because building it depends on unstable internal Rust features. Most of the times we have to adapt to the changes and only very rarely there's an actual bug in Rust. Fixing build failures caused by Rust updates, can be a good way to learn about Rust internals. diff --git a/README.md b/README.md index 5c5d32e4a89..be24f1be827 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ To have cargo compile your crate with Clippy without Clippy installation in your code, you can use: ```terminal -cargo run --bin cargo-clippy --manifest-path=path_to_clippys_Cargo.toml +RUSTFLAGS=--sysroot=`rustc --print sysroot` cargo run --bin cargo-clippy --manifest-path=path_to_clippys_Cargo.toml ``` *[Note](https://github.com/rust-lang/rust-clippy/wiki#a-word-of-warning):* @@ -151,6 +151,10 @@ Note: `deny` produces errors instead of warnings. If you do not want to include your lint levels in your code, you can globally enable/disable lints by passing extra flags to Clippy during the run: `cargo clippy -- -A clippy::lint_name` will run Clippy with `lint_name` disabled and `cargo clippy -- -W clippy::lint_name` will run it with that enabled. This also works with lint groups. For example you can run Clippy with warnings for all lints enabled: `cargo clippy -- -W clippy::pedantic` +## Contributing + +If you want to contribute to Clippy, you can find more information in [CONTRIBUTING.md](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md). + ## License Copyright 2014-2018 The Rust Project Developers diff --git a/ci/base-tests.sh b/ci/base-tests.sh index 85b86fe0588..b69e86ad3ac 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -26,23 +26,38 @@ cd clippy_lints && cargo test && cd .. cd rustc_tools_util && cargo test && cd .. cd clippy_dev && cargo test && cd .. +# make sure clippy can be called via ./path/to/cargo-clippy +cd clippy_workspace_tests +../target/debug/cargo-clippy +cd .. + # Perform various checks for lint registration ./util/dev update_lints --check cargo +nightly fmt --all -- --check - -#avoid loop spam -set +x # make sure tests are formatted # some lints are sensitive to formatting, exclude some files -needs_formatting=false +tests_need_reformatting="false" +# switch to nightly +rustup default nightly +# avoid loop spam and allow cmds with exit status != 0 +set +ex + for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do -rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true + rustfmt ${file} --check + if [ $? -ne 0 ]; then + echo "${file} needs reformatting!" + tests_need_reformatting="true" + fi done -if [ "${needs_reformatting}" = true ] ; then +set -ex # reset + +if [ "${tests_need_reformatting}" == "true" ] ; then echo "Tests need reformatting!" exit 2 fi -set -x + +# switch back to master +rustup default master diff --git a/ci/integration-tests.sh b/ci/integration-tests.sh index 75decab940e..bf43d5b6811 100755 --- a/ci/integration-tests.sh +++ b/ci/integration-tests.sh @@ -21,7 +21,7 @@ function check() { # run clippy on a project, try to be verbose and trigger as many warnings as possible for greater coverage RUST_BACKTRACE=full cargo clippy --all-targets --all-features -- --cap-lints warn -W clippy::pedantic -W clippy::nursery &> clippy_output cat clippy_output - ! cat clippy_output | grep -q "internal compiler error\|query stack during panic" + ! cat clippy_output | grep -q "internal compiler error\|query stack during panic\|E0463" if [[ $? != 0 ]]; then return 1 fi diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 626afceecff..60f1a3df522 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -432,7 +432,7 @@ fn test_gen_deprecated() { "should_assert_eq", "group1", "abc", - Some("has been superseeded by should_assert_eq2"), + Some("has been superseded by should_assert_eq2"), "module_name", ), Lint::new( @@ -447,7 +447,7 @@ fn test_gen_deprecated() { let expected: Vec<String> = vec![ " store.register_removed(", " \"should_assert_eq\",", - " \"has been superseeded by should_assert_eq2\",", + " \"has been superseded by should_assert_eq2\",", " );", " store.register_removed(", " \"another_deprecated\",", diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index a8b03d21482..7310e35116f 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -337,7 +337,9 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) { &name_lower, Some(tool_name.as_str()) ) { - CheckLintNameResult::NoLint => (), + // FIXME: can we suggest similar lint names here? + // https://github.com/rust-lang/rust/pull/56992 + CheckLintNameResult::NoLint(None) => (), _ => { db.span_suggestion(lint.span, "lowercase the lint name", diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 25ce883cac8..89440845e5c 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -17,7 +17,7 @@ use crate::syntax::source_map::Span; use crate::utils::{snippet_with_applicability, span_lint_and_sugg, SpanlessEq}; -/// **What it does:** Checks for double comparions that could be simpified to a single expression. +/// **What it does:** Checks for double comparions that could be simplified to a single expression. /// /// /// **Why is this bad?** Readability. diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index ae87c4273e9..c6142a16854 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -75,7 +75,7 @@ declare_clippy_lint! { /// } /// ``` declare_clippy_lint! { - pub STUTTER, + pub MODULE_NAME_REPETITIONS, pedantic, "type names prefixed/postfixed with their containing module's name" } @@ -126,7 +126,12 @@ impl EnumVariantNames { impl LintPass for EnumVariantNames { fn get_lints(&self) -> LintArray { - lint_array!(ENUM_VARIANT_NAMES, PUB_ENUM_VARIANT_NAMES, STUTTER, MODULE_INCEPTION) + lint_array!( + ENUM_VARIANT_NAMES, + PUB_ENUM_VARIANT_NAMES, + MODULE_NAME_REPETITIONS, + MODULE_INCEPTION + ) } } @@ -277,7 +282,7 @@ impl EarlyLintPass for EnumVariantNames { match item_camel.chars().nth(nchars) { Some(c) if is_word_beginning(c) => span_lint( cx, - STUTTER, + MODULE_NAME_REPETITIONS, item.span, "item name starts with its containing module's name", ), @@ -287,7 +292,7 @@ impl EarlyLintPass for EnumVariantNames { if rmatching == nchars { span_lint( cx, - STUTTER, + MODULE_NAME_REPETITIONS, item.span, "item name ends with its containing module's name", ); diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 48ee383482c..cc3801423c8 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -31,8 +31,8 @@ declare_clippy_lint! { "suspicious formatting of `*=`, `-=` or `!=`" } -/// **What it does:** Checks for formatting of `else if`. It lints if the `else` -/// and `if` are not on the same line or the `else` seems to be missing. +/// **What it does:** Checks for formatting of `else`. It lints if the `else` +/// is followed immediately by a newline or the `else` seems to be missing. /// /// **Why is this bad?** This is probably some refactoring remnant, even if the /// code is correct, it might look confusing. @@ -42,19 +42,29 @@ declare_clippy_lint! { /// **Example:** /// ```rust,ignore /// if foo { +/// } { // looks like an `else` is missing here +/// } +/// +/// if foo { /// } if bar { // looks like an `else` is missing here /// } /// /// if foo { /// } else /// +/// { // this is the `else` block of the previous `if`, but should it be? +/// } +/// +/// if foo { +/// } else +/// /// if bar { // this is the `else` block of the previous `if`, but should it be? /// } /// ``` declare_clippy_lint! { pub SUSPICIOUS_ELSE_FORMATTING, style, - "suspicious formatting of `else if`" + "suspicious formatting of `else`" } /// **What it does:** Checks for possible missing comma in an array. It lints if @@ -96,7 +106,7 @@ impl EarlyLintPass for Formatting { match (&w[0].node, &w[1].node) { (&ast::StmtKind::Expr(ref first), &ast::StmtKind::Expr(ref second)) | (&ast::StmtKind::Expr(ref first), &ast::StmtKind::Semi(ref second)) => { - check_consecutive_ifs(cx, first, second); + check_missing_else(cx, first, second); }, _ => (), } @@ -105,7 +115,7 @@ impl EarlyLintPass for Formatting { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) { check_assign(cx, expr); - check_else_if(cx, expr); + check_else(cx, expr); check_array(cx, expr); } } @@ -139,10 +149,18 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &ast::Expr) { } } -/// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for weird `else if`. -fn check_else_if(cx: &EarlyContext<'_>, expr: &ast::Expr) { +/// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for weird `else`. +fn check_else(cx: &EarlyContext<'_>, expr: &ast::Expr) { if let Some((then, &Some(ref else_))) = unsugar_if(expr) { - if unsugar_if(else_).is_some() && !differing_macro_contexts(then.span, else_.span) && !in_macro(then.span) { + if (is_block(else_) || unsugar_if(else_).is_some()) + && !differing_macro_contexts(then.span, else_.span) + && !in_macro(then.span) + { + // workaround for rust-lang/rust#43081 + if expr.span.lo().0 == 0 && expr.span.hi().0 == 0 { + return; + } + // this will be a span from the closing ‘}’ of the “then” block (excluding) to // the // “if” of the “else if” block (excluding) @@ -154,14 +172,19 @@ fn check_else_if(cx: &EarlyContext<'_>, expr: &ast::Expr) { let else_pos = else_snippet.find("else").expect("there must be a `else` here"); if else_snippet[else_pos..].contains('\n') { + let else_desc = if unsugar_if(else_).is_some() { "if" } else { "{..}" }; + span_note_and_lint( cx, SUSPICIOUS_ELSE_FORMATTING, else_span, - "this is an `else if` but the formatting might hide it", + &format!("this is an `else {}` but the formatting might hide it", else_desc), else_span, - "to remove this lint, remove the `else` or remove the new line between `else` \ - and `if`", + &format!( + "to remove this lint, remove the `else` or remove the new line between \ + `else` and `{}`", + else_desc, + ), ); } } @@ -200,32 +223,47 @@ fn check_array(cx: &EarlyContext<'_>, expr: &ast::Expr) { } } -/// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for consecutive ifs. -fn check_consecutive_ifs(cx: &EarlyContext<'_>, first: &ast::Expr, second: &ast::Expr) { +fn check_missing_else(cx: &EarlyContext<'_>, first: &ast::Expr, second: &ast::Expr) { if !differing_macro_contexts(first.span, second.span) && !in_macro(first.span) && unsugar_if(first).is_some() - && unsugar_if(second).is_some() + && (is_block(second) || unsugar_if(second).is_some()) { // where the else would be let else_span = first.span.between(second.span); if let Some(else_snippet) = snippet_opt(cx, else_span) { if !else_snippet.contains('\n') { + let (looks_like, next_thing) = if unsugar_if(second).is_some() { + ("an `else if`", "the second `if`") + } else { + ("an `else {..}`", "the next block") + }; + span_note_and_lint( cx, SUSPICIOUS_ELSE_FORMATTING, else_span, - "this looks like an `else if` but the `else` is missing", + &format!("this looks like {} but the `else` is missing", looks_like), else_span, - "to remove this lint, add the missing `else` or add a new line before the second \ - `if`", + &format!( + "to remove this lint, add the missing `else` or add a new line before {}", + next_thing, + ), ); } } } } +fn is_block(expr: &ast::Expr) -> bool { + if let ast::ExprKind::Block(..) = expr.node { + true + } else { + false + } +} + /// Match `if` or `if let` expressions and return the `then` and `else` block. fn unsugar_if(expr: &ast::Expr) -> Option<(&P<ast::Block>, &Option<P<ast::Expr>>)> { match expr.node { diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 96022db56aa..dc1869ae04e 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -12,7 +12,7 @@ use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use crate::rustc::{declare_tool_lint, lint_array}; use crate::rustc_errors::Applicability; use crate::syntax::{ast::NodeId, source_map::Span}; -use crate::utils::{snippet_opt, span_lint_and_then}; +use crate::utils::{in_macro, snippet_opt, span_lint_and_then}; /// **What it does:** Checks for missing return statements at the end of a block. /// @@ -116,14 +116,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { _: FnKind<'tcx>, _: &'tcx FnDecl, body: &'tcx Body, - _: Span, + span: Span, _: NodeId, ) { let def_id = cx.tcx.hir().body_owner_def_id(body.id()); let mir = cx.tcx.optimized_mir(def_id); // checking return type through MIR, HIR is not able to determine inferred closure return types - if !mir.return_ty().is_unit() { + // make sure it's not a macro + if !mir.return_ty().is_unit() && !in_macro(span) { Self::expr_match(cx, &body.value); } } diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index f4b5edee84c..8ce5861a939 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -517,8 +517,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { doc::DOC_MARKDOWN, empty_enum::EMPTY_ENUM, enum_glob_use::ENUM_GLOB_USE, + enum_variants::MODULE_NAME_REPETITIONS, enum_variants::PUB_ENUM_VARIANT_NAMES, - enum_variants::STUTTER, if_not_else::IF_NOT_ELSE, infinite_iter::MAYBE_INFINITE_ITER, items_after_statements::ITEMS_AFTER_STATEMENTS, @@ -1030,6 +1030,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { ]); } +pub fn register_renamed(ls: &mut rustc::lint::LintStore) { + ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions"); +} + // only exists to let the dogfood integration test works. // Don't run clippy as an executable directly #[allow(dead_code)] diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 7ff43bd2da2..8bf509844ac 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -478,6 +478,11 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { + // we don't want to check expanded macros + if in_macro(expr.span) { + return; + } + if let Some((pat, arg, body)) = higher::for_loop(expr) { check_for_loop(cx, pat, arg, body, expr); } @@ -751,7 +756,8 @@ fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult { | ExprKind::Closure(_, _, _, _, _) | ExprKind::InlineAsm(_, _, _) | ExprKind::Path(_) - | ExprKind::Lit(_) => NeverLoopResult::Otherwise, + | ExprKind::Lit(_) + | ExprKind::Err => NeverLoopResult::Otherwise, } } diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 8ca1fbb2759..d45fcc7e860 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -27,7 +27,9 @@ pub struct Pass; /// /// **Why is this bad?** Readability, this can be written more concisely /// -/// **Known problems:** None. +/// **Known problems:** Sometimes `.cloned()` requires stricter trait +/// bound than `.map(|e| e.clone())` (which works because of the coercion). +/// See [#498](https://github.com/rust-lang-nursery/rust-clippy/issues/498). /// /// **Example:** /// diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 39450deb84c..e5c17beb404 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -199,7 +199,6 @@ fn suggestion_msg(function_type: &str, map_type: &str) -> String { fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr, map_args: &[hir::Expr]) { let var_arg = &map_args[0]; - let fn_arg = &map_args[1]; let (map_type, variant, lint) = if match_type(cx, cx.tables.expr_ty(var_arg), &paths::OPTION) { ("Option", "Some", OPTION_MAP_UNIT_FN) @@ -208,6 +207,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr } else { return; }; + let fn_arg = &map_args[1]; if is_unit_function(cx, fn_arg) { let msg = suggestion_msg("function", map_type); diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 34683934eca..fb467d886b5 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -22,7 +22,7 @@ use crate::utils::{match_type, paths, span_lint}; /// /// **Why is this bad?** Using a mutex just to make access to a plain bool or /// reference sequential is shooting flies with cannons. -/// `std::atomic::AtomicBool` and `std::atomic::AtomicPtr` are leaner and +/// `std::sync::atomic::AtomicBool` and `std::sync::atomic::AtomicPtr` are leaner and /// faster. /// /// **Known problems:** This lint cannot detect if the mutex is actually used @@ -43,7 +43,7 @@ declare_clippy_lint! { /// /// **Why is this bad?** Using a mutex just to make access to a plain integer /// sequential is -/// shooting flies with cannons. `std::atomic::usize` is leaner and faster. +/// shooting flies with cannons. `std::sync::atomic::AtomicUsize` is leaner and faster. /// /// **Known problems:** This lint cannot detect if the mutex is actually used /// for waiting before a critical section. diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 7e09eae1e93..9eb543db6d4 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -504,6 +504,9 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { self.current = value_pat; self.visit_expr(value); }, + ExprKind::Err => { + println!("Err = {}", current); + }, } } diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 73169414a02..d7a57945658 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -615,6 +615,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { self.hash_name(l.ident.name); } }, + ExprKind::Err => {}, } } diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 93a5845ad45..b9a58c51706 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -347,6 +347,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) { println!("{}repeat count:", ind); print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1); }, + hir::ExprKind::Err => { + println!("{}Err", ind); + }, } } diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 66f18b51f21..f087b73bef4 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -79,7 +79,8 @@ impl<'a> Sugg<'a> { | hir::ExprKind::Ret(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Tup(..) - | hir::ExprKind::While(..) => Sugg::NonParen(snippet), + | hir::ExprKind::While(..) + | hir::ExprKind::Err => Sugg::NonParen(snippet), hir::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet), hir::ExprKind::AssignOp(op, ..) => Sugg::BinOp(hirbinop2assignop(op), snippet), hir::ExprKind::Binary(op, ..) => Sugg::BinOp(AssocOp::from_ast_binop(higher::binop(op.node)), snippet), @@ -158,7 +159,8 @@ impl<'a> Sugg<'a> { | ast::ExprKind::Tup(..) | ast::ExprKind::Array(..) | ast::ExprKind::While(..) - | ast::ExprKind::WhileLet(..) => Sugg::NonParen(snippet), + | ast::ExprKind::WhileLet(..) + | ast::ExprKind::Err => Sugg::NonParen(snippet), ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet), ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotEq, snippet), ast::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet), diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 416ba4ca18d..d226c6559c3 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -257,7 +257,7 @@ impl EarlyLintPass for Pass { } /// Checks the arguments of `print[ln]!` and `write[ln]!` calls. It will return a tuple of two -/// options. The first part of the tuple is `format_str` of the macros. The secund part of the tuple +/// options. The first part of the tuple is `format_str` of the macros. The second part of the tuple /// is in the `write[ln]!` case the expression the `format_str` should be written to. /// /// Example: @@ -292,7 +292,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - }; let tmp = fmtstr.clone(); let mut args = vec![]; - let mut fmt_parser = Parser::new(&tmp, None); + let mut fmt_parser = Parser::new(&tmp, None, Vec::new(), false); while let Some(piece) = fmt_parser.next() { if !fmt_parser.errors.is_empty() { return (None, expr); diff --git a/rustc_tools_util/Cargo.toml b/rustc_tools_util/Cargo.toml index 020de6c3393..b73d7ca5606 100644 --- a/rustc_tools_util/Cargo.toml +++ b/rustc_tools_util/Cargo.toml @@ -2,5 +2,11 @@ name = "rustc_tools_util" version = "0.1.0" authors = ["Matthias Krüger <matthias.krueger@famsik.de>"] +description = "small helper to generate version information for git packages" +repository = "https://github.com/rust-lang/rust-clippy" +readme = "README.md" +license = "MIT/Apache-2.0" +keywords = ["rustc", "tool", "git", "version", "hash"] +categories = ["development-tools"] edition = "2018" [dependencies] diff --git a/rustc_tools_util/README.md b/rustc_tools_util/README.md new file mode 100644 index 00000000000..b101f55e509 --- /dev/null +++ b/rustc_tools_util/README.md @@ -0,0 +1,58 @@ +# rustc_tools_util + +A small tool to help you generate version information +for packages installed from a git repo + +## Usage + +Add a `build.rs` file to your repo and list it in `Cargo.toml` +```` +build = "build.rs" +```` + +List rustc_tools_util as regular AND build dependency. +```` +[dependencies] +rustc_tools_util = "0.1" + +[build-dependencies] +rustc_tools_util = "0.1" +```` + +In `build.rs`, generate the data in your `main()` +````rust +fn main() { + println!( + "cargo:rustc-env=GIT_HASH={}", + rustc_tools_util::get_commit_hash().unwrap_or_default() + ); + println!( + "cargo:rustc-env=COMMIT_DATE={}", + rustc_tools_util::get_commit_date().unwrap_or_default() + ); +} + +```` + +Use the version information in your main.rs +````rust +use rustc_tools_util::*; + +fn show_version() { + let version_info = rustc_tools_util::get_version_info!(); + println!("{}", version_info); +} +```` +This gives the following output in clippy: +`clippy 0.0.212 (a416c5e 2018-12-14)` + + +## License + +Copyright 2014-2018 The Rust Project Developers + +Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +option. All files in the project carrying such notice may not be +copied, modified, or distributed except according to those terms. diff --git a/src/driver.rs b/src/driver.rs index 6b327d08207..269228988f7 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -23,7 +23,7 @@ use self::rustc_driver::{driver::CompileController, Compilation}; use std::convert::TryInto; use std::path::Path; -use std::process::exit; +use std::process::{exit, Command}; fn show_version() { println!(env!("CARGO_PKG_VERSION")); @@ -40,22 +40,54 @@ pub fn main() { exit(0); } + let sys_root = option_env!("SYSROOT") + .map(String::from) + .or_else(|| std::env::var("SYSROOT").ok()) + .or_else(|| { + let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); + let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); + home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain))) + }) + .or_else(|| { + Command::new("rustc") + .arg("--print") + .arg("sysroot") + .output() + .ok() + .and_then(|out| String::from_utf8(out.stdout).ok()) + .map(|s| s.trim().to_owned()) + }) + .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); + // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. // We're invoking the compiler programmatically, so we ignore this/ - let mut args: Vec<String> = env::args().collect(); - if args.len() <= 1 { + let mut orig_args: Vec<String> = env::args().collect(); + if orig_args.len() <= 1 { std::process::exit(1); } - if Path::new(&args[1]).file_stem() == Some("rustc".as_ref()) { + if Path::new(&orig_args[1]).file_stem() == Some("rustc".as_ref()) { // we still want to be able to invoke it normally though - args.remove(1); + orig_args.remove(1); } + // this conditional check for the --sysroot flag is there so users can call + // `clippy_driver` directly + // without having to pass --sysroot or anything + let mut args: Vec<String> = if orig_args.iter().any(|s| s == "--sysroot") { + orig_args.clone() + } else { + orig_args + .clone() + .into_iter() + .chain(Some("--sysroot".to_owned())) + .chain(Some(sys_root)) + .collect() + }; // this check ensures that dependencies are built but not linted and the final // crate is // linted but not built let clippy_enabled = env::var("CLIPPY_TESTS").ok().map_or(false, |val| val == "true") - || args.iter().any(|s| s == "--emit=dep-info,metadata"); + || orig_args.iter().any(|s| s == "--emit=dep-info,metadata"); if clippy_enabled { args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]); @@ -110,6 +142,7 @@ pub fn main() { ls.register_group(Some(sess), true, name, deprecated_name, to); } clippy_lints::register_pre_expansion_lints(sess, &mut ls, &conf); + clippy_lints::register_renamed(&mut ls); sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes); sess.plugin_attributes.borrow_mut().extend(attributes); diff --git a/src/lib.rs b/src/lib.rs index 4069472612d..ef6f4cd7b3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,8 @@ // FIXME: switch to something more ergonomic here, once available. // (currently there is no way to opt into sysroot crates w/o `extern crate`) #[allow(unused_extern_crates)] +extern crate rustc_driver; +#[allow(unused_extern_crates)] extern crate rustc_plugin; use self::rustc_plugin::Registry; diff --git a/src/main.rs b/src/main.rs index 6c5cfe69166..369528f1954 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,10 +33,9 @@ with: -D --deny OPT Set lint denied -F --forbid OPT Set lint forbidden -The feature `cargo-clippy` is automatically defined for convenience. You can use -it to allow or deny lints from the code, eg.: +You can use tool lints to allow or deny lints from your code, eg.: - #[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))] + #[allow(clippy::needless_lifetimes)] "#; fn show_help() { diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 62fa17d388a..8b8ffe86f19 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -17,7 +17,6 @@ use std::ffi::OsStr; use std::fs; use std::io; use std::path::{Path, PathBuf}; -use std::process::Command; fn clippy_driver_path() -> PathBuf { if let Some(path) = option_env!("CLIPPY_DRIVER_PATH") { @@ -43,28 +42,6 @@ fn rustc_lib_path() -> PathBuf { option_env!("RUSTC_LIB_PATH").unwrap().into() } -fn rustc_sysroot_path() -> PathBuf { - option_env!("SYSROOT") - .map(String::from) - .or_else(|| std::env::var("SYSROOT").ok()) - .or_else(|| { - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); - home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain))) - }) - .or_else(|| { - Command::new("rustc") - .arg("--print") - .arg("sysroot") - .output() - .ok() - .and_then(|out| String::from_utf8(out.stdout).ok()) - .map(|s| s.trim().to_owned()) - }) - .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust") - .into() -} - fn config(mode: &str, dir: PathBuf) -> compiletest::Config { let mut config = compiletest::Config::default(); @@ -79,9 +56,8 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { config.compile_lib_path = rustc_lib_path(); } config.target_rustcflags = Some(format!( - "-L {0} -L {0}/deps -Dwarnings --sysroot {1}", - host_libs().display(), - rustc_sysroot_path().display() + "-L {0} -L {0}/deps -Dwarnings -Zui-testing", + host_libs().display() )); config.mode = cfg_mode; diff --git a/tests/dogfood.rs b/tests/dogfood.rs index 69f4f9901b7..c1f02b9fcef 100644 --- a/tests/dogfood.rs +++ b/tests/dogfood.rs @@ -7,31 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::path::PathBuf; -use std::process::Command; - -fn rustc_sysroot_path() -> PathBuf { - option_env!("SYSROOT") - .map(String::from) - .or_else(|| std::env::var("SYSROOT").ok()) - .or_else(|| { - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); - home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain))) - }) - .or_else(|| { - Command::new("rustc") - .arg("--print") - .arg("sysroot") - .output() - .ok() - .and_then(|out| String::from_utf8(out.stdout).ok()) - .map(|s| s.trim().to_owned()) - }) - .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust") - .into() -} - #[test] fn dogfood() { if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) { @@ -46,7 +21,6 @@ fn dogfood() { let output = std::process::Command::new(clippy_cmd) .current_dir(root_dir) .env("CLIPPY_DOGFOOD", "1") - .env("RUSTFLAGS", format!("--sysroot {}", rustc_sysroot_path().display())) .arg("clippy") .arg("--all-targets") .arg("--all-features") @@ -85,7 +59,6 @@ fn dogfood_tests() { let output = std::process::Command::new(&clippy_cmd) .current_dir(root_dir.join(d)) .env("CLIPPY_DOGFOOD", "1") - .env("RUSTFLAGS", format!("--sysroot {}", rustc_sysroot_path().display())) .arg("clippy") .arg("--") .args(&["-D", "clippy::all"]) 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 e67cdd8f9dd..9f35b1751ac 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr @@ -1,7 +1,7 @@ error: use of a blacklisted/placeholder name `toto` --> $DIR/conf_french_blacklisted_name.rs:15:9 | -15 | fn test(toto: ()) {} +LL | fn test(toto: ()) {} | ^^^^ | = note: `-D clippy::blacklisted-name` implied by `-D warnings` @@ -9,37 +9,37 @@ error: use of a blacklisted/placeholder name `toto` error: use of a blacklisted/placeholder name `toto` --> $DIR/conf_french_blacklisted_name.rs:18:9 | -18 | let toto = 42; +LL | let toto = 42; | ^^^^ error: use of a blacklisted/placeholder name `tata` --> $DIR/conf_french_blacklisted_name.rs:19:9 | -19 | let tata = 42; +LL | let tata = 42; | ^^^^ error: use of a blacklisted/placeholder name `titi` --> $DIR/conf_french_blacklisted_name.rs:20:9 | -20 | let titi = 42; +LL | let titi = 42; | ^^^^ error: use of a blacklisted/placeholder name `toto` --> $DIR/conf_french_blacklisted_name.rs:26:10 | -26 | (toto, Some(tata), titi @ Some(_)) => (), +LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `tata` --> $DIR/conf_french_blacklisted_name.rs:26:21 | -26 | (toto, Some(tata), titi @ Some(_)) => (), +LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `titi` --> $DIR/conf_french_blacklisted_name.rs:26:28 | -26 | (toto, Some(tata), titi @ Some(_)) => (), +LL | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index efa9223bde8..49cbc0691bc 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,7 +1,7 @@ error: this argument is passed by reference, but would be more efficient if passed by value --> $DIR/test.rs:20:11 | -20 | fn bad(x: &u16, y: &Foo) {} +LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `u16` | = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` @@ -9,7 +9,7 @@ error: this argument is passed by reference, but would be more efficient if pass error: this argument is passed by reference, but would be more efficient if passed by value --> $DIR/test.rs:20:20 | -20 | fn bad(x: &u16, y: &Foo) {} +LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 00f7086dc55..5c8d537b21c 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,7 +1,7 @@ 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 | -23 | u <= 0; +LL | u <= 0; | ^^^^^^ | = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` @@ -10,7 +10,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -24 | u <= Z; +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 @@ -18,7 +18,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -25 | u < Z; +LL | u < Z; | ^^^^^ | = help: because Z is the minimum value for this type, this comparison is always false @@ -26,7 +26,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -26 | Z >= u; +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 @@ -34,7 +34,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -27 | Z > u; +LL | Z > u; | ^^^^^ | = help: because Z is the minimum value for this type, this comparison is always false @@ -42,7 +42,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -28 | u > std::u32::MAX; +LL | u > std::u32::MAX; | ^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, this comparison is always false @@ -50,7 +50,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -29 | u >= std::u32::MAX; +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 @@ -58,7 +58,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -30 | std::u32::MAX < u; +LL | std::u32::MAX < u; | ^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, this comparison is always false @@ -66,7 +66,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -31 | std::u32::MAX <= u; +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 @@ -74,7 +74,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -32 | 1-1 > u; +LL | 1-1 > u; | ^^^^^^^ | = help: because 1-1 is the minimum value for this type, this comparison is always false @@ -82,7 +82,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -33 | u >= !0; +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 @@ -90,7 +90,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -34 | u <= 12 - 2*6; +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 @@ -98,7 +98,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -36 | i < -127 - 1; +LL | i < -127 - 1; | ^^^^^^^^^^^^ | = help: because -127 - 1 is the minimum value for this type, this comparison is always false @@ -106,7 +106,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -37 | std::i8::MAX >= i; +LL | std::i8::MAX >= i; | ^^^^^^^^^^^^^^^^^ | = help: because std::i8::MAX is the maximum value for this type, this comparison is always true @@ -114,7 +114,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -38 | 3-7 < std::i32::MIN; +LL | 3-7 < std::i32::MIN; | ^^^^^^^^^^^^^^^^^^^ | = help: because std::i32::MIN is the minimum value for this type, this comparison is always false @@ -122,7 +122,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -40 | b >= true; +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 @@ -130,7 +130,7 @@ error: this comparison involving the minimum or maximum element for this type co 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 | -41 | false > b; +LL | false > b; | ^^^^^^^^^ | = help: because false is the minimum value for this type, this comparison is always false @@ -138,7 +138,7 @@ error: this comparison involving the minimum or maximum element for this type co error: <-comparison of unit values detected. This will always be false --> $DIR/absurd-extreme-comparisons.rs:44:5 | -44 | () < {}; +LL | () < {}; | ^^^^^^^ | = note: #[deny(clippy::unit_cmp)] on by default diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index cee7fe6919a..c29ea3d467a 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,7 +1,7 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly --> $DIR/approx_const.rs:13:16 | -13 | let my_e = 2.7182; +LL | let my_e = 2.7182; | ^^^^^^ | = note: `-D clippy::approx-constant` implied by `-D warnings` @@ -9,109 +9,109 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it dire error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly --> $DIR/approx_const.rs:14:20 | -14 | let almost_e = 2.718; +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 | -17 | let my_1_frac_pi = 0.3183; +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 | -20 | let my_frac_1_sqrt_2 = 0.70710678; +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 | -21 | let almost_frac_1_sqrt_2 = 0.70711; +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 | -24 | let my_frac_2_pi = 0.63661977; +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 | -27 | let my_frac_2_sq_pi = 1.128379; +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 | -30 | let my_frac_pi_2 = 1.57079632679; +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 | -33 | let my_frac_pi_3 = 1.04719755119; +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 | -36 | let my_frac_pi_4 = 0.785398163397; +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 | -39 | let my_frac_pi_6 = 0.523598775598; +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 | -42 | let my_frac_pi_8 = 0.3926990816987; +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 | -45 | let my_ln_10 = 2.302585092994046; +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 | -48 | let my_ln_2 = 0.6931471805599453; +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 | -51 | let my_log10_e = 0.4342944819032518; +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 | -54 | let my_log2_e = 1.4426950408889634; +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 | -57 | let my_pi = 3.1415; +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 | -58 | let almost_pi = 3.14; +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 | -61 | let my_sq2 = 1.4142; +LL | let my_sq2 = 1.4142; | ^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index 1dff9941bb2..cea9676c2b8 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -1,7 +1,7 @@ error: integer arithmetic detected --> $DIR/arithmetic.rs:22:5 | -22 | 1 + i; +LL | 1 + i; | ^^^^^ | = note: `-D clippy::integer-arithmetic` implied by `-D warnings` @@ -9,32 +9,32 @@ error: integer arithmetic detected error: integer arithmetic detected --> $DIR/arithmetic.rs:23:5 | -23 | i * 2; +LL | i * 2; | ^^^^^ error: integer arithmetic detected --> $DIR/arithmetic.rs:24:5 | -24 | / 1 % -25 | | i / 2; // no error, this is part of the expression in the preceding line +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 | -26 | i - 2 + 2 - i; +LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: integer arithmetic detected --> $DIR/arithmetic.rs:27:5 | -27 | -i; +LL | -i; | ^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:37:5 | -37 | f * 2.0; +LL | f * 2.0; | ^^^^^^^ | = note: `-D clippy::float-arithmetic` implied by `-D warnings` @@ -42,31 +42,31 @@ error: floating-point arithmetic detected error: floating-point arithmetic detected --> $DIR/arithmetic.rs:39:5 | -39 | 1.0 + f; +LL | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:40:5 | -40 | f * 2.0; +LL | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:41:5 | -41 | f / 2.0; +LL | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:42:5 | -42 | f - 2.0 * 4.2; +LL | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:43:5 | -43 | -f; +LL | -f; | ^^ error: aborting due to 11 previous errors diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 7acbdc89984..194033981e1 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,7 +1,7 @@ error: manual implementation of an assign operation --> $DIR/assign_ops.rs:14:5 | -14 | a = a + 1; +LL | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` @@ -9,49 +9,49 @@ error: manual implementation of an assign operation error: manual implementation of an assign operation --> $DIR/assign_ops.rs:15:5 | -15 | a = 1 + a; +LL | a = 1 + a; | ^^^^^^^^^ help: replace it with: `a += 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:16:5 | -16 | a = a - 1; +LL | a = a - 1; | ^^^^^^^^^ help: replace it with: `a -= 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:17:5 | -17 | a = a * 99; +LL | a = a * 99; | ^^^^^^^^^^ help: replace it with: `a *= 99` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:18:5 | -18 | a = 42 * a; +LL | a = 42 * a; | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:19:5 | -19 | a = a / 2; +LL | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:20:5 | -20 | a = a % 5; +LL | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:21:5 | -21 | a = a & 1; +LL | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:27:5 | -27 | s = s + "bla"; +LL | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` error: aborting due to 9 previous errors diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 26ff079ad62..99983c0d054 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,135 +1,135 @@ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:14:5 | -14 | a += a + 1; +LL | a += a + 1; | ^^^^^^^^^^ | = note: `-D clippy::misrefactored-assign-op` implied by `-D warnings` help: Did you mean a = a + 1 or a = a + a + 1? Consider replacing it with | -14 | a += 1; +LL | a += 1; | ^^^^^^ help: or | -14 | a = a + a + 1; +LL | a = a + a + 1; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:15:5 | -15 | a += 1 + a; +LL | a += 1 + a; | ^^^^^^^^^^ help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with | -15 | a += 1; +LL | a += 1; | ^^^^^^ help: or | -15 | a = a + 1 + a; +LL | a = a + 1 + a; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:16:5 | -16 | a -= a - 1; +LL | a -= a - 1; | ^^^^^^^^^^ help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with | -16 | a -= 1; +LL | a -= 1; | ^^^^^^ help: or | -16 | a = a - (a - 1); +LL | a = a - (a - 1); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:17:5 | -17 | a *= a * 99; +LL | a *= a * 99; | ^^^^^^^^^^^ help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with | -17 | a *= 99; +LL | a *= 99; | ^^^^^^^ help: or | -17 | a = a * a * 99; +LL | a = a * a * 99; | ^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:18:5 | -18 | a *= 42 * a; +LL | a *= 42 * a; | ^^^^^^^^^^^ help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with | -18 | a *= 42; +LL | a *= 42; | ^^^^^^^ help: or | -18 | a = a * 42 * a; +LL | a = a * 42 * a; | ^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:19:5 | -19 | a /= a / 2; +LL | a /= a / 2; | ^^^^^^^^^^ help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with | -19 | a /= 2; +LL | a /= 2; | ^^^^^^ help: or | -19 | a = a / (a / 2); +LL | a = a / (a / 2); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:20:5 | -20 | a %= a % 5; +LL | a %= a % 5; | ^^^^^^^^^^ help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with | -20 | a %= 5; +LL | a %= 5; | ^^^^^^ help: or | -20 | a = a % (a % 5); +LL | a = a % (a % 5); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:21:5 | -21 | a &= a & 1; +LL | a &= a & 1; | ^^^^^^^^^^ help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with | -21 | a &= 1; +LL | a &= 1; | ^^^^^^ help: or | -21 | a = a & a & 1; +LL | a = a & a & 1; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:22:5 | -22 | a *= a * a; +LL | a *= a * a; | ^^^^^^^^^^ help: Did you mean a = a * a or a = a * a * a? Consider replacing it with | -22 | a *= a; +LL | a *= a; | ^^^^^^ help: or | -22 | a = a * a * a; +LL | a = a * a * a; | ^^^^^^^^^^^^^ error: manual implementation of an assign operation --> $DIR/assign_ops2.rs:59:5 | -59 | buf = buf + cows.clone(); +LL | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index 1331fa2912c..bc40cb8c86d 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,7 +1,7 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea --> $DIR/attrs.rs:12:1 | -12 | #[inline(always)] +LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::inline-always` implied by `-D warnings` @@ -9,7 +9,7 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usuall error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:32:14 | -32 | #[deprecated(since = "forever")] +LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::deprecated-semver` implied by `-D warnings` @@ -17,7 +17,7 @@ error: the since field must contain a semver-compliant version error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:35:14 | -35 | #[deprecated(since = "1")] +LL | #[deprecated(since = "1")] | ^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr index 4b895b0b8e3..5fb2a01f1b2 100644 --- a/tests/ui/author/matches.stderr +++ b/tests/ui/author/matches.stderr @@ -1,14 +1,14 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. --> $DIR/matches.rs:18:13 | -18 | x +LL | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned --> $DIR/matches.rs:17:21 | -17 | let x = 3; +LL | let x = 3; | ^ error: aborting due to previous error diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index 853f5a992f3..da883dcbfc4 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,7 +1,7 @@ error: &-masking with zero --> $DIR/bit_masks.rs:23:5 | -23 | x & 0 == 0; +LL | x & 0 == 0; | ^^^^^^^^^^ | = note: `-D clippy::bad-bit-mask` implied by `-D warnings` @@ -9,7 +9,7 @@ error: &-masking with zero error: this operation will always return zero. This is likely not the intended outcome --> $DIR/bit_masks.rs:23:5 | -23 | x & 0 == 0; +LL | x & 0 == 0; | ^^^^^ | = note: #[deny(clippy::erasing_op)] on by default @@ -17,73 +17,73 @@ error: this operation will always return zero. This is likely not the intended o error: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:26:5 | -26 | x & 2 == 1; +LL | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` --> $DIR/bit_masks.rs:30:5 | -30 | x | 3 == 2; +LL | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` --> $DIR/bit_masks.rs:32:5 | -32 | x & 1 > 1; +LL | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` --> $DIR/bit_masks.rs:36:5 | -36 | x | 2 > 1; +LL | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` --> $DIR/bit_masks.rs:43:5 | -43 | x & THREE_BITS == 8; +LL | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` --> $DIR/bit_masks.rs:44:5 | -44 | x | EVEN_MORE_REDIRECTION < 7; +LL | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero --> $DIR/bit_masks.rs:46:5 | -46 | 0 & x == 0; +LL | 0 & x == 0; | ^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome --> $DIR/bit_masks.rs:46:5 | -46 | 0 & x == 0; +LL | 0 & x == 0; | ^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` --> $DIR/bit_masks.rs:50:5 | -50 | 1 < 2 | x; +LL | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` --> $DIR/bit_masks.rs:51:5 | -51 | 2 == 3 | x; +LL | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:52:5 | -52 | 1 == x & 2; +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 | -63 | x | 1 > 3; +LL | x | 1 > 3; | ^^^^^^^^^ | = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` @@ -91,19 +91,19 @@ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly --> $DIR/bit_masks.rs:64:5 | -64 | x | 1 < 4; +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 | -65 | x | 1 <= 3; +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 | -66 | x | 1 >= 8; +LL | x | 1 >= 8; | ^^^^^^^^^^ error: aborting due to 17 previous errors diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 707d36b24b2..5b65d4ed13f 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -1,7 +1,7 @@ error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:20:9 | -20 | fn test(foo: ()) {} +LL | fn test(foo: ()) {} | ^^^ | = note: `-D clippy::blacklisted-name` implied by `-D warnings` @@ -9,79 +9,79 @@ error: use of a blacklisted/placeholder name `foo` error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:23:9 | -23 | let foo = 42; +LL | let foo = 42; | ^^^ error: use of a blacklisted/placeholder name `bar` --> $DIR/blacklisted_name.rs:24:9 | -24 | let bar = 42; +LL | let bar = 42; | ^^^ error: use of a blacklisted/placeholder name `baz` --> $DIR/blacklisted_name.rs:25:9 | -25 | let baz = 42; +LL | let baz = 42; | ^^^ error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:31:10 | -31 | (foo, Some(bar), baz @ Some(_)) => (), +LL | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `bar` --> $DIR/blacklisted_name.rs:31:20 | -31 | (foo, Some(bar), baz @ Some(_)) => (), +LL | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `baz` --> $DIR/blacklisted_name.rs:31:26 | -31 | (foo, Some(bar), baz @ Some(_)) => (), +LL | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:36:19 | -36 | fn issue_1647(mut foo: u8) { +LL | fn issue_1647(mut foo: u8) { | ^^^ error: use of a blacklisted/placeholder name `bar` --> $DIR/blacklisted_name.rs:37:13 | -37 | let mut bar = 0; +LL | let mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` --> $DIR/blacklisted_name.rs:38:21 | -38 | if let Some(mut baz) = Some(42) {} +LL | if let Some(mut baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` --> $DIR/blacklisted_name.rs:42:13 | -42 | let ref bar = 0; +LL | let ref bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` --> $DIR/blacklisted_name.rs:43:21 | -43 | if let Some(ref baz) = Some(42) {} +LL | if let Some(ref baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` --> $DIR/blacklisted_name.rs:47:17 | -47 | let ref mut bar = 0; +LL | let ref mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` --> $DIR/blacklisted_name.rs:48:25 | -48 | if let Some(ref mut baz) = Some(42) {} +LL | if let Some(ref mut baz) = Some(42) {} | ^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index d83cef26a8b..522c7dc779e 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -1,11 +1,11 @@ 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 | -35 | if { +LL | if { | ________^ -36 | | let x = 3; -37 | | x == 3 -38 | | } { +LL | | let x = 3; +LL | | x == 3 +LL | | } { | |_____^ | = note: `-D clippy::block-in-if-condition-stmt` implied by `-D warnings` @@ -21,7 +21,7 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste error: omit braces around single expression condition --> $DIR/block_in_if_condition.rs:46:8 | -46 | if { true } { +LL | if { true } { | ^^^^^^^^ | = note: `-D clippy::block-in-if-condition-expr` implied by `-D warnings` @@ -33,27 +33,27 @@ error: omit braces around single expression condition 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 | -66 | |x| { +LL | |x| { | _________________^ -67 | | let target = 3; -68 | | x == target -69 | | }, +LL | | let target = 3; +LL | | x == target +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 | -75 | |x| { +LL | |x| { | _____________^ -76 | | let target = 3; -77 | | x == target -78 | | }, +LL | | let target = 3; +LL | | x == target +LL | | }, | |_________^ error: this boolean expression can be simplified --> $DIR/block_in_if_condition.rs:85:8 | -85 | if true && x == 3 { +LL | if true && x == 3 { | ^^^^^^^^^^^^^^ help: try: `x == 3` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 9a12a8f089a..7bd48f2e3dc 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -1,7 +1,7 @@ error: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:13:8 | -13 | if x == true { +LL | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` | = note: `-D clippy::bool-comparison` implied by `-D warnings` @@ -9,79 +9,79 @@ error: equality checks against true are unnecessary error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:18:8 | -18 | if x == false { +LL | if x == false { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:23:8 | -23 | if true == x { +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 | -28 | if false == x { +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 | -33 | if x != true { +LL | if x != true { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary --> $DIR/bool_comparison.rs:38:8 | -38 | if x != false { +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 | -43 | if true != x { +LL | if true != x { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary --> $DIR/bool_comparison.rs:48:8 | -48 | if false != x { +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 | -53 | if x < true { +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 | -58 | if false < x { +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 | -63 | if x > false { +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 | -68 | if true > x { +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 | -74 | if x < y { +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 | -79 | if x > y { +LL | if x > y { | ^^^^^ help: try simplifying it as shown: `x & !y` error: aborting due to 14 previous errors diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index 45205b978ef..c9446f5e4bc 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -1,20 +1,20 @@ error: this boolean expression contains a logic bug --> $DIR/booleans.rs:19:13 | -19 | let _ = a && b || a; +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 | -19 | let _ = a && b || a; +LL | let _ = a && b || a; | ^ error: this boolean expression can be simplified --> $DIR/booleans.rs:21:13 | -21 | let _ = !true; +LL | let _ = !true; | ^^^^^ help: try: `false` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` @@ -22,182 +22,182 @@ error: this boolean expression can be simplified error: this boolean expression can be simplified --> $DIR/booleans.rs:22:13 | -22 | let _ = !false; +LL | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified --> $DIR/booleans.rs:23:13 | -23 | let _ = !!a; +LL | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression contains a logic bug --> $DIR/booleans.rs:24:13 | -24 | let _ = false && a; +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 | -24 | let _ = false && a; +LL | let _ = false && a; | ^ error: this boolean expression can be simplified --> $DIR/booleans.rs:25:13 | -25 | let _ = false || a; +LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified --> $DIR/booleans.rs:30:13 | -30 | let _ = !(!a && b); +LL | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `!b || a` error: this boolean expression contains a logic bug --> $DIR/booleans.rs:40:13 | -40 | let _ = a == b && a != b; +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 | -40 | let _ = a == b && a != b; +LL | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression can be simplified --> $DIR/booleans.rs:41:13 | -41 | let _ = a == b && c == 5 && a == b; +LL | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -41 | let _ = a == b && c == 5; +LL | let _ = a == b && c == 5; | ^^^^^^^^^^^^^^^^ -41 | let _ = !(c != 5 || a != b); +LL | let _ = !(c != 5 || a != b); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified --> $DIR/booleans.rs:42:13 | -42 | let _ = a == b && c == 5 && b == a; +LL | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -42 | let _ = a == b && c == 5; +LL | let _ = a == b && c == 5; | ^^^^^^^^^^^^^^^^ -42 | let _ = !(c != 5 || a != b); +LL | let _ = !(c != 5 || a != b); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression contains a logic bug --> $DIR/booleans.rs:43:13 | -43 | let _ = a < b && a >= b; +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 | -43 | let _ = a < b && a >= b; +LL | let _ = a < b && a >= b; | ^^^^^ error: this boolean expression contains a logic bug --> $DIR/booleans.rs:44:13 | -44 | let _ = a > b && a <= b; +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 | -44 | let _ = a > b && a <= b; +LL | let _ = a > b && a <= b; | ^^^^^ error: this boolean expression can be simplified --> $DIR/booleans.rs:46:13 | -46 | let _ = a != b || !(a != b || c == d); +LL | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -46 | let _ = c != d || a != b; +LL | let _ = c != d || a != b; | ^^^^^^^^^^^^^^^^ -46 | let _ = !(a == b && c == d); +LL | let _ = !(a == b && c == d); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified --> $DIR/booleans.rs:54:13 | -54 | let _ = !a.is_some(); +LL | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified --> $DIR/booleans.rs:56:13 | -56 | let _ = !a.is_none(); +LL | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` error: this boolean expression can be simplified --> $DIR/booleans.rs:58:13 | -58 | let _ = !b.is_err(); +LL | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` error: this boolean expression can be simplified --> $DIR/booleans.rs:60:13 | -60 | let _ = !b.is_ok(); +LL | let _ = !b.is_ok(); | ^^^^^^^^^^ help: try: `b.is_err()` error: this boolean expression can be simplified --> $DIR/booleans.rs:62:13 | -62 | let _ = !(a.is_some() && !c); +LL | let _ = !(a.is_some() && !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()` error: this boolean expression can be simplified --> $DIR/booleans.rs:63:13 | -63 | let _ = !(!c ^ c) || !a.is_some(); +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 | -64 | let _ = (!c ^ c) || !a.is_some(); +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 | -65 | let _ = !c ^ c || !a.is_some(); +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 - | -137 | if !res.is_ok() {} - | ^^^^^^^^^^^^ help: try: `res.is_err()` + --> $DIR/booleans.rs:137:8 + | +LL | if !res.is_ok() {} + | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:138:8 - | -138 | if !res.is_err() {} - | ^^^^^^^^^^^^^ help: try: `res.is_ok()` + --> $DIR/booleans.rs:138:8 + | +LL | if !res.is_err() {} + | ^^^^^^^^^^^^^ help: try: `res.is_ok()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:141:8 - | -141 | if !res.is_some() {} - | ^^^^^^^^^^^^^^ help: try: `res.is_none()` + --> $DIR/booleans.rs:141:8 + | +LL | if !res.is_some() {} + | ^^^^^^^^^^^^^^ help: try: `res.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:142:8 - | -142 | if !res.is_none() {} - | ^^^^^^^^^^^^^^ help: try: `res.is_some()` + --> $DIR/booleans.rs:142:8 + | +LL | if !res.is_none() {} + | ^^^^^^^^^^^^^^ help: try: `res.is_some()` error: aborting due to 25 previous errors diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 0e42fe177ba..33bd50286a5 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -1,31 +1,31 @@ error: you seem to be trying to use `&Box<T>`. Consider using just `&T` --> $DIR/borrow_box.rs:15:19 | -15 | pub fn test1(foo: &mut Box<bool>) { +LL | pub fn test1(foo: &mut Box<bool>) { | ^^^^^^^^^^^^^^ help: try: `&mut bool` | note: lint level defined here --> $DIR/borrow_box.rs:10:9 | -10 | #![deny(clippy::borrowed_box)] +LL | #![deny(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box<T>`. Consider using just `&T` --> $DIR/borrow_box.rs:20:14 | -20 | let foo: &Box<bool>; +LL | let foo: &Box<bool>; | ^^^^^^^^^^ help: try: `&bool` error: you seem to be trying to use `&Box<T>`. Consider using just `&T` --> $DIR/borrow_box.rs:24:10 | -24 | foo: &'a Box<bool>, +LL | foo: &'a Box<bool>, | ^^^^^^^^^^^^^ help: try: `&'a bool` error: you seem to be trying to use `&Box<T>`. Consider using just `&T` --> $DIR/borrow_box.rs:28:17 | -28 | fn test4(a: &Box<bool>); +LL | fn test4(a: &Box<bool>); | ^^^^^^^^^^ help: try: `&bool` error: aborting due to 4 previous errors diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index 84c0b6c36e3..8b5fc24a371 100644 --- a/tests/ui/box_vec.stderr +++ b/tests/ui/box_vec.stderr @@ -1,7 +1,7 @@ error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>` --> $DIR/box_vec.rs:23:18 | -23 | pub fn test(foo: Box<Vec<bool>>) { +LL | pub fn test(foo: Box<Vec<bool>>) { | ^^^^^^^^^^^^^^ | = note: `-D clippy::box-vec` implied by `-D warnings` diff --git a/tests/ui/builtin-type-shadow.rs b/tests/ui/builtin-type-shadow.rs index 66a7e318f8a..e9df0992c5e 100644 --- a/tests/ui/builtin-type-shadow.rs +++ b/tests/ui/builtin-type-shadow.rs @@ -8,6 +8,7 @@ // except according to those terms. #![warn(clippy::builtin_type_shadow)] +#![allow(non_camel_case_types)] fn foo<u32>(a: u32) -> u32 { 42 diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 540d9f4f458..9bfed9dbba8 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -1,17 +1,17 @@ error: This generic shadows the built-in type `u32` - --> $DIR/builtin-type-shadow.rs:12:8 + --> $DIR/builtin-type-shadow.rs:13:8 | -12 | fn foo<u32>(a: u32) -> u32 { +LL | fn foo<u32>(a: u32) -> u32 { | ^^^ | = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` error[E0308]: mismatched types - --> $DIR/builtin-type-shadow.rs:13:5 + --> $DIR/builtin-type-shadow.rs:14:5 | -12 | fn foo<u32>(a: u32) -> u32 { +LL | fn foo<u32>(a: u32) -> u32 { | --- expected `u32` because of return type -13 | 42 +LL | 42 | ^^ expected type parameter, found integral variable | = note: expected type `u32` diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index 605cf287419..a2890fe5a6d 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -1,25 +1,25 @@ error: You appear to be counting bytes the naive way --> $DIR/bytecount.rs:14:13 | -14 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count +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 | -10 | #[deny(clippy::naive_bytecount)] +LL | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: You appear to be counting bytes the naive way --> $DIR/bytecount.rs:16:13 | -16 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count +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 | -28 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count +LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)` error: aborting due to 3 previous errors diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 1b6b1e6319c..78631ffa8c8 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,7 +1,7 @@ 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 | -20 | 1i32 as f32; +LL | 1i32 as f32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` @@ -9,37 +9,37 @@ error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f 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 | -21 | 1i64 as f32; +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 | -22 | 1i64 as f64; +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 | -23 | 1u32 as f32; +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 | -24 | 1u64 as f32; +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 | -25 | 1u64 as f64; +LL | 1u64 as f64; | ^^^^^^^^^^^ error: casting f32 to i32 may truncate the value --> $DIR/cast.rs:27:5 | -27 | 1f32 as i32; +LL | 1f32 as i32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` @@ -47,13 +47,13 @@ error: casting f32 to i32 may truncate the value error: casting f32 to u32 may truncate the value --> $DIR/cast.rs:28:5 | -28 | 1f32 as u32; +LL | 1f32 as u32; | ^^^^^^^^^^^ error: casting f32 to u32 may lose the sign of the value --> $DIR/cast.rs:28:5 | -28 | 1f32 as u32; +LL | 1f32 as u32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` @@ -61,49 +61,49 @@ error: casting f32 to u32 may lose the sign of the value error: casting f64 to f32 may truncate the value --> $DIR/cast.rs:29:5 | -29 | 1f64 as f32; +LL | 1f64 as f32; | ^^^^^^^^^^^ error: casting i32 to i8 may truncate the value --> $DIR/cast.rs:30:5 | -30 | 1i32 as i8; +LL | 1i32 as i8; | ^^^^^^^^^^ error: casting i32 to u8 may lose the sign of the value --> $DIR/cast.rs:31:5 | -31 | 1i32 as u8; +LL | 1i32 as u8; | ^^^^^^^^^^ error: casting i32 to u8 may truncate the value --> $DIR/cast.rs:31:5 | -31 | 1i32 as u8; +LL | 1i32 as u8; | ^^^^^^^^^^ error: casting f64 to isize may truncate the value --> $DIR/cast.rs:32:5 | -32 | 1f64 as isize; +LL | 1f64 as isize; | ^^^^^^^^^^^^^ error: casting f64 to usize may truncate the value --> $DIR/cast.rs:33:5 | -33 | 1f64 as usize; +LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting f64 to usize may lose the sign of the value --> $DIR/cast.rs:33:5 | -33 | 1f64 as usize; +LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting u8 to i8 may wrap around the value --> $DIR/cast.rs:35:5 | -35 | 1u8 as i8; +LL | 1u8 as i8; | ^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` @@ -111,31 +111,31 @@ error: casting u8 to i8 may wrap around the value error: casting u16 to i16 may wrap around the value --> $DIR/cast.rs:36:5 | -36 | 1u16 as i16; +LL | 1u16 as i16; | ^^^^^^^^^^^ error: casting u32 to i32 may wrap around the value --> $DIR/cast.rs:37:5 | -37 | 1u32 as i32; +LL | 1u32 as i32; | ^^^^^^^^^^^ error: casting u64 to i64 may wrap around the value --> $DIR/cast.rs:38:5 | -38 | 1u64 as i64; +LL | 1u64 as i64; | ^^^^^^^^^^^ error: casting usize to isize may wrap around the value --> $DIR/cast.rs:39:5 | -39 | 1usize as isize; +LL | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting f32 to f64 may become silently lossy if types change --> $DIR/cast.rs:41:5 | -41 | 1.0f32 as f64; +LL | 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` @@ -143,25 +143,25 @@ error: casting f32 to f64 may become silently lossy if types change error: casting u8 to u16 may become silently lossy if types change --> $DIR/cast.rs:43:5 | -43 | (1u8 + 1u8) as u16; +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 | -45 | 1i32 as u32; +LL | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value --> $DIR/cast.rs:46:5 | -46 | 1isize as usize; +LL | 1isize as usize; | ^^^^^^^^^^^^^^^ error: casting to the same type is unnecessary (`i32` -> `i32`) --> $DIR/cast.rs:49:5 | -49 | 1i32 as i32; +LL | 1i32 as i32; | ^^^^^^^^^^^ | = note: `-D clippy::unnecessary-cast` implied by `-D warnings` @@ -169,13 +169,13 @@ error: casting to the same type is unnecessary (`i32` -> `i32`) error: casting to the same type is unnecessary (`f32` -> `f32`) --> $DIR/cast.rs:50:5 | -50 | 1f32 as f32; +LL | 1f32 as f32; | ^^^^^^^^^^^ error: casting to the same type is unnecessary (`bool` -> `bool`) --> $DIR/cast.rs:51:5 | -51 | false as bool; +LL | false as bool; | ^^^^^^^^^^^^^ error: aborting due to 28 previous errors diff --git a/tests/ui/cast_alignment.rs b/tests/ui/cast_alignment.rs index 77f50b3add2..dba19dfd023 100644 --- a/tests/ui/cast_alignment.rs +++ b/tests/ui/cast_alignment.rs @@ -9,7 +9,6 @@ //! Test casts for alignment issues - #![feature(rustc_private)] extern crate libc; diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index 1c7d53c3ce7..261bce613bf 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,15 +1,15 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) - --> $DIR/cast_alignment.rs:22:5 + --> $DIR/cast_alignment.rs:21:5 | -22 | (&1u8 as *const u8) as *const u16; +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:23:5 + --> $DIR/cast_alignment.rs:22:5 | -23 | (&mut 1u8 as *mut u8) as *mut u16; +LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 8380c7c84e2..2164315c35e 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,7 +1,7 @@ error: casting i8 to f32 may become silently lossy if types change --> $DIR/cast_lossless_float.rs:14:5 | -14 | 1i8 as f32; +LL | 1i8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` @@ -9,55 +9,55 @@ error: casting i8 to f32 may become silently lossy if types change error: casting i8 to f64 may become silently lossy if types change --> $DIR/cast_lossless_float.rs:15:5 | -15 | 1i8 as f64; +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:16:5 | -16 | 1u8 as f32; +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:17:5 | -17 | 1u8 as f64; +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:18:5 | -18 | 1i16 as f32; +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:19:5 | -19 | 1i16 as f64; +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:20:5 | -20 | 1u16 as f32; +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:21:5 | -21 | 1u16 as f64; +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:22:5 | -22 | 1i32 as f64; +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:23:5 | -23 | 1u32 as f64; +LL | 1u32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u32)` error: aborting due to 10 previous errors diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index e5558b66681..d9eb1be57f7 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,7 +1,7 @@ error: casting i8 to i16 may become silently lossy if types change --> $DIR/cast_lossless_integer.rs:14:5 | -14 | 1i8 as i16; +LL | 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` @@ -9,103 +9,103 @@ error: casting i8 to i16 may become silently lossy if types change error: casting i8 to i32 may become silently lossy if types change --> $DIR/cast_lossless_integer.rs:15:5 | -15 | 1i8 as i32; +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:16:5 | -16 | 1i8 as i64; +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:17:5 | -17 | 1u8 as i16; +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:18:5 | -18 | 1u8 as i32; +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:19:5 | -19 | 1u8 as i64; +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:20:5 | -20 | 1u8 as u16; +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:21:5 | -21 | 1u8 as u32; +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:22:5 | -22 | 1u8 as u64; +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:23:5 | -23 | 1i16 as i32; +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:24:5 | -24 | 1i16 as i64; +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:25:5 | -25 | 1u16 as i32; +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:26:5 | -26 | 1u16 as i64; +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:27:5 | -27 | 1u16 as u32; +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:28:5 | -28 | 1u16 as u64; +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:29:5 | -29 | 1i32 as i64; +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:30:5 | -30 | 1u32 as i64; +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:31:5 | -31 | 1u32 as u64; +LL | 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` error: aborting due to 18 previous errors diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index 9f658d40523..eab1014128a 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -1,7 +1,7 @@ error: casting isize to i8 may truncate the value --> $DIR/cast_size.rs:20:5 | -20 | 1isize as i8; +LL | 1isize as i8; | ^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` @@ -9,7 +9,7 @@ error: casting isize to i8 may truncate the value 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 | -21 | 1isize as f64; +LL | 1isize as f64; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` @@ -17,31 +17,31 @@ error: casting isize to f64 causes a loss of precision on targets with 64-bit wi 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 | -22 | 1usize as f64; +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 | -23 | 1isize as f32; +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 | -24 | 1usize as f32; +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 | -25 | 1isize as i32; +LL | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value --> $DIR/cast_size.rs:26:5 | -26 | 1isize as u32; +LL | 1isize as u32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` @@ -49,25 +49,25 @@ error: casting isize to u32 may lose the sign of the value error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:26:5 | -26 | 1isize as u32; +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 | -27 | 1usize as u32; +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 | -28 | 1usize as i32; +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 | -28 | 1usize as i32; +LL | 1usize as i32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` @@ -75,49 +75,49 @@ error: casting usize to i32 may wrap around the value on targets with 32-bit wid error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:30:5 | -30 | 1i64 as isize; +LL | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value --> $DIR/cast_size.rs:31:5 | -31 | 1i64 as usize; +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 | -31 | 1i64 as usize; +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 | -32 | 1u64 as isize; +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 | -32 | 1u64 as isize; +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 | -33 | 1u64 as usize; +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 | -34 | 1u32 as isize; +LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value --> $DIR/cast_size.rs:37:5 | -37 | 1i32 as usize; +LL | 1i32 as usize; | ^^^^^^^^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/cfg_attr_rustfmt.stderr b/tests/ui/cfg_attr_rustfmt.stderr index a6a27bd2ee8..233aafc3c79 100644 --- a/tests/ui/cfg_attr_rustfmt.stderr +++ b/tests/ui/cfg_attr_rustfmt.stderr @@ -1,7 +1,7 @@ error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes --> $DIR/cfg_attr_rustfmt.rs:25:5 | -25 | #[cfg_attr(rustfmt, rustfmt::skip)] +LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` | = note: `-D clippy::deprecated-cfg-attr` implied by `-D warnings` @@ -9,13 +9,13 @@ error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes --> $DIR/cfg_attr_rustfmt.rs:29:1 | -29 | #[cfg_attr(rustfmt, rustfmt_skip)] +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 | -35 | #![cfg_attr(rustfmt, rustfmt_skip)] +LL | #![cfg_attr(rustfmt, rustfmt_skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#![rustfmt::skip]` error: aborting due to 3 previous errors diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index cee27df2a7d..a577c55d261 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -1,7 +1,7 @@ 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 | -13 | let c = 'a' as u8; +LL | let c = 'a' as u8; | ^^^^^^^^^ | = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` diff --git a/tests/ui/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index bce37d50226..7e6a487ad1e 100644 --- a/tests/ui/checked_unwrap.stderr +++ b/tests/ui/checked_unwrap.stderr @@ -1,313 +1,313 @@ 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 | -15 | if x.is_some() { +LL | if x.is_some() { | ----------- the check is happening here -16 | x.unwrap(); // unnecessary +LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ | note: lint level defined here --> $DIR/checked_unwrap.rs:10:35 | -10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:18:9 | -15 | if x.is_some() { +LL | if x.is_some() { | ----------- because of this check ... -18 | x.unwrap(); // will panic +LL | x.unwrap(); // will panic | ^^^^^^^^^^ | note: lint level defined here --> $DIR/checked_unwrap.rs:10:9 | -10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:21:9 | -20 | if x.is_none() { +LL | if x.is_none() { | ----------- because of this check -21 | x.unwrap(); // will panic +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 | -20 | if x.is_none() { +LL | if x.is_none() { | ----------- the check is happening here ... -23 | x.unwrap(); // unnecessary +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 | -26 | if x.is_ok() { +LL | if x.is_ok() { | --------- the check is happening here -27 | x.unwrap(); // unnecessary +LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:28:9 | -26 | if x.is_ok() { +LL | if x.is_ok() { | --------- because of this check -27 | x.unwrap(); // unnecessary -28 | x.unwrap_err(); // will panic +LL | x.unwrap(); // unnecessary +LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:30:9 | -26 | if x.is_ok() { +LL | if x.is_ok() { | --------- because of this check ... -30 | x.unwrap(); // will panic +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 | -26 | if x.is_ok() { +LL | if x.is_ok() { | --------- the check is happening here ... -31 | x.unwrap_err(); // unnecessary +LL | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:34:9 | -33 | if x.is_err() { +LL | if x.is_err() { | ---------- because of this check -34 | x.unwrap(); // will panic +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 | -33 | if x.is_err() { +LL | if x.is_err() { | ---------- the check is happening here -34 | x.unwrap(); // will panic -35 | x.unwrap_err(); // unnecessary +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 | -33 | if x.is_err() { +LL | if x.is_err() { | ---------- the check is happening here ... -37 | x.unwrap(); // unnecessary +LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:38:9 | -33 | if x.is_err() { +LL | if x.is_err() { | ---------- because of this check ... -38 | x.unwrap_err(); // will panic +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 | -54 | if x.is_ok() && y.is_err() { +LL | if x.is_ok() && y.is_err() { | --------- the check is happening here -55 | x.unwrap(); // unnecessary +LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:56:9 | -54 | if x.is_ok() && y.is_err() { +LL | if x.is_ok() && y.is_err() { | --------- because of this check -55 | x.unwrap(); // unnecessary -56 | x.unwrap_err(); // will panic +LL | x.unwrap(); // unnecessary +LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:57:9 | -54 | if x.is_ok() && y.is_err() { +LL | if x.is_ok() && y.is_err() { | ---------- because of this check ... -57 | y.unwrap(); // will panic +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 | -54 | if x.is_ok() && y.is_err() { +LL | if x.is_ok() && y.is_err() { | ---------- the check is happening here ... -58 | y.unwrap_err(); // unnecessary +LL | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:72:9 | -67 | if x.is_ok() || y.is_ok() { +LL | if x.is_ok() || y.is_ok() { | --------- because of this check ... -72 | x.unwrap(); // will panic +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 | -67 | if x.is_ok() || y.is_ok() { +LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -73 | x.unwrap_err(); // unnecessary +LL | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:74:9 | -67 | if x.is_ok() || y.is_ok() { +LL | if x.is_ok() || y.is_ok() { | --------- because of this check ... -74 | y.unwrap(); // will panic +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 | -67 | if x.is_ok() || y.is_ok() { +LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -75 | y.unwrap_err(); // unnecessary +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 | -78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here -79 | x.unwrap(); // unnecessary +LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:80:9 | -78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check -79 | x.unwrap(); // unnecessary -80 | x.unwrap_err(); // will panic +LL | x.unwrap(); // unnecessary +LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:81:9 | -78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check ... -81 | y.unwrap(); // will panic +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 | -78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here ... -82 | y.unwrap_err(); // unnecessary +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 | -78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here ... -83 | z.unwrap(); // unnecessary +LL | z.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:84:9 | -78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check ... -84 | z.unwrap_err(); // will panic +LL | z.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:92:9 | -86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check ... -92 | x.unwrap(); // will panic +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 | -86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here ... -93 | x.unwrap_err(); // unnecessary +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 | -86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here ... -94 | y.unwrap(); // unnecessary +LL | y.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:95:9 | -86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check ... -95 | y.unwrap_err(); // will panic +LL | y.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:96:9 | -86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check ... -96 | z.unwrap(); // will panic +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 | -86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- the check is happening here ... -97 | z.unwrap_err(); // unnecessary +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 - | -104 | if x.is_some() { - | ----------- the check is happening here -105 | x.unwrap(); // unnecessary - | ^^^^^^^^^^ + --> $DIR/checked_unwrap.rs:105:13 + | +LL | if x.is_some() { + | ----------- the check is happening here +LL | x.unwrap(); // unnecessary + | ^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:107:13 - | -104 | if x.is_some() { - | ----------- because of this check + --> $DIR/checked_unwrap.rs:107:13 + | +LL | if x.is_some() { + | ----------- because of this check ... -107 | x.unwrap(); // will panic - | ^^^^^^^^^^ +LL | x.unwrap(); // will panic + | ^^^^^^^^^^ error: aborting due to 34 previous errors diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index 6838e6ad7ae..2a7772308b8 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -1,7 +1,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:14:5 | -14 | x == std::f32::NAN; +LL | x == std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-nan` implied by `-D warnings` @@ -9,67 +9,67 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:15:5 | -15 | x != std::f32::NAN; +LL | x != std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:16:5 | -16 | x < std::f32::NAN; +LL | x < std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:17:5 | -17 | x > std::f32::NAN; +LL | x > std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:18:5 | -18 | x <= std::f32::NAN; +LL | x <= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:19:5 | -19 | x >= std::f32::NAN; +LL | x >= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:22:5 | -22 | y == std::f64::NAN; +LL | y == std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:23:5 | -23 | y != std::f64::NAN; +LL | y != std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:24:5 | -24 | y < std::f64::NAN; +LL | y < std::f64::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:25:5 | -25 | y > std::f64::NAN; +LL | y > std::f64::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:26:5 | -26 | y <= std::f64::NAN; +LL | y <= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:27:5 | -27 | y >= std::f64::NAN; +LL | y >= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 5038298d9c4..68789b5b635 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,7 +1,7 @@ error: Comparing with null is better expressed by the .is_null() method --> $DIR/cmp_null.rs:18:8 | -18 | if p == ptr::null() { +LL | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-null` implied by `-D warnings` @@ -9,7 +9,7 @@ error: Comparing with null is better expressed by the .is_null() method error: Comparing with null is better expressed by the .is_null() method --> $DIR/cmp_null.rs:23:8 | -23 | if m == ptr::null_mut() { +LL | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index 2d06f736967..9177c6bd73e 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -1,7 +1,7 @@ error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:14:14 | -14 | x != "foo".to_string(); +LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` | = note: `-D clippy::cmp-owned` implied by `-D warnings` @@ -9,49 +9,49 @@ error: this creates an owned instance just for comparison error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:16:9 | -16 | "foo".to_string() != x; +LL | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:23:10 | -23 | x != "foo".to_owned(); +LL | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:25:10 | -25 | x != String::from("foo"); +LL | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:29:5 | -29 | Foo.to_owned() == Foo; +LL | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:31:30 | -31 | "abc".chars().filter(|c| c.to_owned() != 'X'); +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 | -38 | y.to_owned() == *x; +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 | -43 | y.to_owned() == **x; +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 | -50 | self.to_owned() == *other +LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: aborting due to 9 previous errors diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 1884045a2db..2c60234eb5d 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,260 +1,260 @@ error: this if statement can be collapsed --> $DIR/collapsible_if.rs:15:5 | -15 | / if x == "hello" { -16 | | if y == "world" { -17 | | println!("Hello world!"); -18 | | } -19 | | } +LL | / if x == "hello" { +LL | | if y == "world" { +LL | | println!("Hello world!"); +LL | | } +LL | | } | |_____^ | = note: `-D clippy::collapsible-if` implied by `-D warnings` help: try | -15 | if x == "hello" && y == "world" { -16 | println!("Hello world!"); -17 | } +LL | if x == "hello" && y == "world" { +LL | println!("Hello world!"); +LL | } | error: this if statement can be collapsed --> $DIR/collapsible_if.rs:21:5 | -21 | / if x == "hello" || x == "world" { -22 | | if y == "world" || y == "hello" { -23 | | println!("Hello world!"); -24 | | } -25 | | } +LL | / if x == "hello" || x == "world" { +LL | | if y == "world" || y == "hello" { +LL | | println!("Hello world!"); +LL | | } +LL | | } | |_____^ help: try | -21 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { -22 | println!("Hello world!"); -23 | } +LL | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { +LL | println!("Hello world!"); +LL | } | error: this if statement can be collapsed --> $DIR/collapsible_if.rs:27:5 | -27 | / if x == "hello" && x == "world" { -28 | | if y == "world" || y == "hello" { -29 | | println!("Hello world!"); -30 | | } -31 | | } +LL | / if x == "hello" && x == "world" { +LL | | if y == "world" || y == "hello" { +LL | | println!("Hello world!"); +LL | | } +LL | | } | |_____^ help: try | -27 | if x == "hello" && x == "world" && (y == "world" || y == "hello") { -28 | println!("Hello world!"); -29 | } +LL | if x == "hello" && x == "world" && (y == "world" || y == "hello") { +LL | println!("Hello world!"); +LL | } | error: this if statement can be collapsed --> $DIR/collapsible_if.rs:33:5 | -33 | / if x == "hello" || x == "world" { -34 | | if y == "world" && y == "hello" { -35 | | println!("Hello world!"); -36 | | } -37 | | } +LL | / if x == "hello" || x == "world" { +LL | | if y == "world" && y == "hello" { +LL | | println!("Hello world!"); +LL | | } +LL | | } | |_____^ help: try | -33 | if (x == "hello" || x == "world") && y == "world" && y == "hello" { -34 | println!("Hello world!"); -35 | } +LL | if (x == "hello" || x == "world") && y == "world" && y == "hello" { +LL | println!("Hello world!"); +LL | } | error: this if statement can be collapsed --> $DIR/collapsible_if.rs:39:5 | -39 | / if x == "hello" && x == "world" { -40 | | if y == "world" && y == "hello" { -41 | | println!("Hello world!"); -42 | | } -43 | | } +LL | / if x == "hello" && x == "world" { +LL | | if y == "world" && y == "hello" { +LL | | println!("Hello world!"); +LL | | } +LL | | } | |_____^ help: try | -39 | if x == "hello" && x == "world" && y == "world" && y == "hello" { -40 | println!("Hello world!"); -41 | } +LL | if x == "hello" && x == "world" && y == "world" && y == "hello" { +LL | println!("Hello world!"); +LL | } | error: this if statement can be collapsed --> $DIR/collapsible_if.rs:45:5 | -45 | / if 42 == 1337 { -46 | | if 'a' != 'A' { -47 | | println!("world!") -48 | | } -49 | | } +LL | / if 42 == 1337 { +LL | | if 'a' != 'A' { +LL | | println!("world!") +LL | | } +LL | | } | |_____^ help: try | -45 | if 42 == 1337 && 'a' != 'A' { -46 | println!("world!") -47 | } +LL | if 42 == 1337 && 'a' != 'A' { +LL | println!("world!") +LL | } | error: this `else { if .. }` block can be collapsed --> $DIR/collapsible_if.rs:54:12 | -54 | } else { +LL | } else { | ____________^ -55 | | if y == "world" { -56 | | println!("world!") -57 | | } -58 | | } +LL | | if y == "world" { +LL | | println!("world!") +LL | | } +LL | | } | |_____^ help: try | -54 | } else if y == "world" { -55 | println!("world!") -56 | } +LL | } else if y == "world" { +LL | println!("world!") +LL | } | error: this `else { if .. }` block can be collapsed --> $DIR/collapsible_if.rs:62:12 | -62 | } else { +LL | } else { | ____________^ -63 | | if let Some(42) = Some(42) { -64 | | println!("world!") -65 | | } -66 | | } +LL | | if let Some(42) = Some(42) { +LL | | println!("world!") +LL | | } +LL | | } | |_____^ help: try | -62 | } else if let Some(42) = Some(42) { -63 | println!("world!") -64 | } +LL | } else if let Some(42) = Some(42) { +LL | println!("world!") +LL | } | error: this `else { if .. }` block can be collapsed --> $DIR/collapsible_if.rs:70:12 | -70 | } else { +LL | } else { | ____________^ -71 | | if y == "world" { -72 | | println!("world") -73 | | } +LL | | if y == "world" { +LL | | println!("world") +LL | | } ... | -76 | | } -77 | | } +LL | | } +LL | | } | |_____^ help: try | -70 | } else if y == "world" { -71 | println!("world") -72 | } -73 | else { -74 | println!("!") -75 | } +LL | } else if y == "world" { +LL | println!("world") +LL | } +LL | else { +LL | println!("!") +LL | } | error: this `else { if .. }` block can be collapsed --> $DIR/collapsible_if.rs:81:12 | -81 | } else { +LL | } else { | ____________^ -82 | | if let Some(42) = Some(42) { -83 | | println!("world") -84 | | } +LL | | if let Some(42) = Some(42) { +LL | | println!("world") +LL | | } ... | -87 | | } -88 | | } +LL | | } +LL | | } | |_____^ help: try | -81 | } else if let Some(42) = Some(42) { -82 | println!("world") -83 | } -84 | else { -85 | println!("!") -86 | } +LL | } else if let Some(42) = Some(42) { +LL | println!("world") +LL | } +LL | else { +LL | println!("!") +LL | } | error: this `else { if .. }` block can be collapsed --> $DIR/collapsible_if.rs:92:12 | -92 | } else { +LL | } else { | ____________^ -93 | | if let Some(42) = Some(42) { -94 | | println!("world") -95 | | } +LL | | if let Some(42) = Some(42) { +LL | | println!("world") +LL | | } ... | -98 | | } -99 | | } +LL | | } +LL | | } | |_____^ help: try | -92 | } else if let Some(42) = Some(42) { -93 | println!("world") -94 | } -95 | else { -96 | println!("!") -97 | } +LL | } else if let Some(42) = Some(42) { +LL | println!("world") +LL | } +LL | else { +LL | println!("!") +LL | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:103:12 - | -103 | } else { - | ____________^ -104 | | if x == "hello" { -105 | | println!("world") -106 | | } -... | -109 | | } -110 | | } - | |_____^ + --> $DIR/collapsible_if.rs:103:12 + | +LL | } else { + | ____________^ +LL | | if x == "hello" { +LL | | println!("world") +LL | | } +... | +LL | | } +LL | | } + | |_____^ help: try - | -103 | } else if x == "hello" { -104 | println!("world") -105 | } -106 | else { -107 | println!("!") -108 | } - | + | +LL | } else if x == "hello" { +LL | println!("world") +LL | } +LL | else { +LL | println!("!") +LL | } + | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:114:12 - | -114 | } else { - | ____________^ -115 | | if let Some(42) = Some(42) { -116 | | println!("world") -117 | | } -... | -120 | | } -121 | | } - | |_____^ + --> $DIR/collapsible_if.rs:114:12 + | +LL | } else { + | ____________^ +LL | | if let Some(42) = Some(42) { +LL | | println!("world") +LL | | } +... | +LL | | } +LL | | } + | |_____^ help: try - | -114 | } else if let Some(42) = Some(42) { -115 | println!("world") -116 | } -117 | else { -118 | println!("!") -119 | } - | + | +LL | } else if let Some(42) = Some(42) { +LL | println!("world") +LL | } +LL | else { +LL | println!("!") +LL | } + | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:173:5 - | -173 | / if x == "hello" { -174 | | if y == "world" { // Collapsible -175 | | println!("Hello world!"); -176 | | } -177 | | } - | |_____^ + --> $DIR/collapsible_if.rs:173:5 + | +LL | / if x == "hello" { +LL | | if y == "world" { // Collapsible +LL | | println!("Hello world!"); +LL | | } +LL | | } + | |_____^ help: try - | -173 | if x == "hello" && y == "world" { // Collapsible -174 | println!("Hello world!"); -175 | } - | + | +LL | if x == "hello" && y == "world" { // Collapsible +LL | println!("Hello world!"); +LL | } + | error: aborting due to 14 previous errors diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index 80f133fd1ce..8f46d38921d 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -1,7 +1,7 @@ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:16:12 | -16 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::type-complexity` implied by `-D warnings` @@ -9,85 +9,85 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:17:12 | -17 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +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 | -20 | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>, +LL | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:23:11 | -23 | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>); +LL | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:26:11 | -26 | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>), +LL | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:27:17 | -27 | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> }, +LL | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:31:14 | -31 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +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 | -32 | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {} +LL | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:36:14 | -36 | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>; +LL | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:37:14 | -37 | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>; +LL | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:38:25 | -38 | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>); +LL | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:39:29 | -39 | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {} +LL | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:42:15 | -42 | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { +LL | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:46:14 | -46 | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {} +LL | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:49:13 | -49 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![]; +LL | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 15 previous errors diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index ba53d0718fc..b3fabb3522f 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -1,7 +1,7 @@ error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:13:17 | -13 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. +LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` | = note: `-D clippy::const-static-lifetime` implied by `-D warnings` @@ -9,73 +9,73 @@ error: Constants have by default a `'static` lifetime error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:17:21 | -17 | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +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 | -19 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +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 | -19 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +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 | -21 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +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 | -21 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +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 | -23 | const VAR_SIX: &'static u8 = &5; +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 | -25 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; +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 | -25 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; +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 | -27 | const VAR_HEIGHT: &'static Foo = &Foo {}; +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 | -29 | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. +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 | -31 | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +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 | -33 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: aborting due to 13 previous errors diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index e41fac0f686..659abf6fa7e 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,392 +1,392 @@ error: this `if` has identical blocks --> $DIR/copies.rs:50:12 | -50 | } else { +LL | } else { | ____________^ -51 | | //~ ERROR same body as `if` block -52 | | Foo { bar: 42 }; -53 | | 0..10; +LL | | //~ ERROR same body as `if` block +LL | | Foo { bar: 42 }; +LL | | 0..10; ... | -58 | | foo(); -59 | | } +LL | | foo(); +LL | | } | |_____^ | = note: `-D clippy::if-same-then-else` implied by `-D warnings` note: same as this --> $DIR/copies.rs:42:13 | -42 | if true { +LL | if true { | _____________^ -43 | | Foo { bar: 42 }; -44 | | 0..10; -45 | | ..; +LL | | Foo { bar: 42 }; +LL | | 0..10; +LL | | ..; ... | -49 | | foo(); -50 | | } else { +LL | | foo(); +LL | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:96:14 - | -96 | _ => { - | ______________^ -97 | | //~ ERROR match arms have same body -98 | | foo(); -99 | | let mut a = 42 + [23].len() as i32; -... | -104 | | a -105 | | }, - | |_________^ - | - = note: `-D clippy::match-same-arms` implied by `-D warnings` + --> $DIR/copies.rs:96:14 + | +LL | _ => { + | ______________^ +LL | | //~ ERROR match arms have same body +LL | | foo(); +LL | | let mut a = 42 + [23].len() as i32; +... | +LL | | a +LL | | }, + | |_________^ + | + = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:87:15 - | -87 | 42 => { - | _______________^ -88 | | foo(); -89 | | let mut a = 42 + [23].len() as i32; -90 | | if true { -... | -94 | | a -95 | | }, - | |_________^ + --> $DIR/copies.rs:87:15 + | +LL | 42 => { + | _______________^ +LL | | foo(); +LL | | let mut a = 42 + [23].len() as i32; +LL | | if true { +... | +LL | | a +LL | | }, + | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:87:15 - | -87 | 42 => { - | _______________^ -88 | | foo(); -89 | | let mut a = 42 + [23].len() as i32; -90 | | if true { -... | -94 | | a -95 | | }, - | |_________^ + --> $DIR/copies.rs:87:15 + | +LL | 42 => { + | _______________^ +LL | | foo(); +LL | | let mut a = 42 + [23].len() as i32; +LL | | if true { +... | +LL | | a +LL | | }, + | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:111:14 - | -111 | _ => 0, //~ ERROR match arms have same body - | ^ - | + --> $DIR/copies.rs:111:14 + | +LL | _ => 0, //~ ERROR match arms have same body + | ^ + | note: same as this - --> $DIR/copies.rs:109:19 - | -109 | Abc::A => 0, - | ^ + --> $DIR/copies.rs:109:19 + | +LL | Abc::A => 0, + | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:109:19 - | -109 | Abc::A => 0, - | ^ + --> $DIR/copies.rs:109:19 + | +LL | Abc::A => 0, + | ^ error: this `if` has identical blocks - --> $DIR/copies.rs:120:12 - | -120 | } else { - | ____________^ -121 | | //~ ERROR same body as `if` block -122 | | 42 -123 | | }; - | |_____^ - | + --> $DIR/copies.rs:120:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | 42 +LL | | }; + | |_____^ + | note: same as this - --> $DIR/copies.rs:118:21 - | -118 | let _ = if true { - | _____________________^ -119 | | 42 -120 | | } else { - | |_____^ + --> $DIR/copies.rs:118:21 + | +LL | let _ = if true { + | _____________________^ +LL | | 42 +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:134:12 - | -134 | } else { - | ____________^ -135 | | //~ ERROR same body as `if` block -136 | | for _ in &[42] { -137 | | let foo: &Option<_> = &Some::<u8>(42); -... | -143 | | } -144 | | } - | |_____^ - | + --> $DIR/copies.rs:134:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | for _ in &[42] { +LL | | let foo: &Option<_> = &Some::<u8>(42); +... | +LL | | } +LL | | } + | |_____^ + | note: same as this - --> $DIR/copies.rs:125:13 - | -125 | if true { - | _____________^ -126 | | for _ in &[42] { -127 | | let foo: &Option<_> = &Some::<u8>(42); -128 | | if true { -... | -133 | | } -134 | | } else { - | |_____^ + --> $DIR/copies.rs:125:13 + | +LL | if true { + | _____________^ +LL | | for _ in &[42] { +LL | | let foo: &Option<_> = &Some::<u8>(42); +LL | | if true { +... | +LL | | } +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:153:12 - | -153 | } else { - | ____________^ -154 | | //~ ERROR same body as `if` block -155 | | let bar = if true { 42 } else { 43 }; -156 | | -... | -160 | | bar + 1; -161 | | } - | |_____^ - | + --> $DIR/copies.rs:153:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | let bar = if true { 42 } else { 43 }; +LL | | +... | +LL | | bar + 1; +LL | | } + | |_____^ + | note: same as this - --> $DIR/copies.rs:146:13 - | -146 | if true { - | _____________^ -147 | | let bar = if true { 42 } else { 43 }; -148 | | -149 | | while foo() { -... | -152 | | bar + 1; -153 | | } else { - | |_____^ + --> $DIR/copies.rs:146:13 + | +LL | if true { + | _____________^ +LL | | let bar = if true { 42 } else { 43 }; +LL | | +LL | | while foo() { +... | +LL | | bar + 1; +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:183:12 - | -183 | } else { - | ____________^ -184 | | //~ ERROR same body as `if` block -185 | | if let Some(a) = Some(42) {} -186 | | } - | |_____^ - | + --> $DIR/copies.rs:183:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | if let Some(a) = Some(42) {} +LL | | } + | |_____^ + | note: same as this - --> $DIR/copies.rs:181:13 - | -181 | if true { - | _____________^ -182 | | if let Some(a) = Some(42) {} -183 | | } else { - | |_____^ + --> $DIR/copies.rs:181:13 + | +LL | if true { + | _____________^ +LL | | if let Some(a) = Some(42) {} +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:190:12 - | -190 | } else { - | ____________^ -191 | | //~ ERROR same body as `if` block -192 | | if let (1, .., 3) = (1, 2, 3) {} -193 | | } - | |_____^ - | + --> $DIR/copies.rs:190:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | if let (1, .., 3) = (1, 2, 3) {} +LL | | } + | |_____^ + | note: same as this - --> $DIR/copies.rs:188:13 - | -188 | if true { - | _____________^ -189 | | if let (1, .., 3) = (1, 2, 3) {} -190 | | } else { - | |_____^ + --> $DIR/copies.rs:188:13 + | +LL | if true { + | _____________^ +LL | | if let (1, .., 3) = (1, 2, 3) {} +LL | | } else { + | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:239:15 - | -239 | 51 => foo(), //~ ERROR match arms have same body - | ^^^^^ - | + --> $DIR/copies.rs:239:15 + | +LL | 51 => foo(), //~ ERROR match arms have same body + | ^^^^^ + | note: same as this - --> $DIR/copies.rs:238:15 - | -238 | 42 => foo(), - | ^^^^^ + --> $DIR/copies.rs:238:15 + | +LL | 42 => foo(), + | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:238:15 - | -238 | 42 => foo(), - | ^^^^^ + --> $DIR/copies.rs:238:15 + | +LL | 42 => foo(), + | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:245:17 - | -245 | None => 24, //~ ERROR match arms have same body - | ^^ - | + --> $DIR/copies.rs:245:17 + | +LL | None => 24, //~ ERROR match arms have same body + | ^^ + | note: same as this - --> $DIR/copies.rs:244:20 - | -244 | Some(_) => 24, - | ^^ + --> $DIR/copies.rs:244:20 + | +LL | Some(_) => 24, + | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:244:20 - | -244 | Some(_) => 24, - | ^^ + --> $DIR/copies.rs:244:20 + | +LL | Some(_) => 24, + | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:267:28 - | -267 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body - | ^^^^^^ - | + --> $DIR/copies.rs:267:28 + | +LL | (None, Some(a)) => bar(a), //~ ERROR match arms have same body + | ^^^^^^ + | note: same as this - --> $DIR/copies.rs:266:28 - | -266 | (Some(a), None) => bar(a), - | ^^^^^^ + --> $DIR/copies.rs:266:28 + | +LL | (Some(a), None) => bar(a), + | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:266:28 - | -266 | (Some(a), None) => bar(a), - | ^^^^^^ + --> $DIR/copies.rs:266:28 + | +LL | (Some(a), None) => bar(a), + | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:273:26 - | -273 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body - | ^^^^^^ - | + --> $DIR/copies.rs:273:26 + | +LL | (.., Some(a)) => bar(a), //~ ERROR match arms have same body + | ^^^^^^ + | note: same as this - --> $DIR/copies.rs:272:26 - | -272 | (Some(a), ..) => bar(a), - | ^^^^^^ + --> $DIR/copies.rs:272:26 + | +LL | (Some(a), ..) => bar(a), + | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:272:26 - | -272 | (Some(a), ..) => bar(a), - | ^^^^^^ + --> $DIR/copies.rs:272:26 + | +LL | (Some(a), ..) => bar(a), + | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:279:20 - | -279 | (.., 3) => 42, //~ ERROR match arms have same body - | ^^ - | + --> $DIR/copies.rs:279:20 + | +LL | (.., 3) => 42, //~ ERROR match arms have same body + | ^^ + | note: same as this - --> $DIR/copies.rs:278:23 - | -278 | (1, .., 3) => 42, - | ^^ + --> $DIR/copies.rs:278:23 + | +LL | (1, .., 3) => 42, + | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:278:23 - | -278 | (1, .., 3) => 42, - | ^^ + --> $DIR/copies.rs:278:23 + | +LL | (1, .., 3) => 42, + | ^^ error: this `if` has identical blocks - --> $DIR/copies.rs:285:12 - | -285 | } else { - | ____________^ -286 | | //~ ERROR same body as `if` block -287 | | 0.0 -288 | | }; - | |_____^ - | + --> $DIR/copies.rs:285:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | 0.0 +LL | | }; + | |_____^ + | note: same as this - --> $DIR/copies.rs:283:21 - | -283 | let _ = if true { - | _____________________^ -284 | | 0.0 -285 | | } else { - | |_____^ + --> $DIR/copies.rs:283:21 + | +LL | let _ = if true { + | _____________________^ +LL | | 0.0 +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:292:12 - | -292 | } else { - | ____________^ -293 | | //~ ERROR same body as `if` block -294 | | -0.0 -295 | | }; - | |_____^ - | + --> $DIR/copies.rs:292:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | -0.0 +LL | | }; + | |_____^ + | note: same as this - --> $DIR/copies.rs:290:21 - | -290 | let _ = if true { - | _____________________^ -291 | | -0.0 -292 | | } else { - | |_____^ + --> $DIR/copies.rs:290:21 + | +LL | let _ = if true { + | _____________________^ +LL | | -0.0 +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:305:12 - | -305 | } else { - | ____________^ -306 | | //~ ERROR same body as `if` block -307 | | std::f32::NAN -308 | | }; - | |_____^ - | + --> $DIR/copies.rs:305:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | std::f32::NAN +LL | | }; + | |_____^ + | note: same as this - --> $DIR/copies.rs:303:21 - | -303 | let _ = if true { - | _____________________^ -304 | | std::f32::NAN -305 | | } else { - | |_____^ + --> $DIR/copies.rs:303:21 + | +LL | let _ = if true { + | _____________________^ +LL | | std::f32::NAN +LL | | } else { + | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:323:12 - | -323 | } else { - | ____________^ -324 | | //~ ERROR same body as `if` block -325 | | try!(Ok("foo")); -326 | | } - | |_____^ - | + --> $DIR/copies.rs:323:12 + | +LL | } else { + | ____________^ +LL | | //~ ERROR same body as `if` block +LL | | try!(Ok("foo")); +LL | | } + | |_____^ + | note: same as this - --> $DIR/copies.rs:321:13 - | -321 | if true { - | _____________^ -322 | | try!(Ok("foo")); -323 | | } else { - | |_____^ + --> $DIR/copies.rs:321:13 + | +LL | if true { + | _____________^ +LL | | try!(Ok("foo")); +LL | | } else { + | |_____^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:347:15 - | -347 | } else if b { - | ^ - | - = note: `-D clippy::ifs-same-cond` implied by `-D warnings` + --> $DIR/copies.rs:347:15 + | +LL | } else if b { + | ^ + | + = note: `-D clippy::ifs-same-cond` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:346:8 - | -346 | if b { - | ^ + --> $DIR/copies.rs:346:8 + | +LL | if b { + | ^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:352:15 - | -352 | } else if a == 1 { - | ^^^^^^ - | + --> $DIR/copies.rs:352:15 + | +LL | } else if a == 1 { + | ^^^^^^ + | note: same as this - --> $DIR/copies.rs:351:8 - | -351 | if a == 1 { - | ^^^^^^ + --> $DIR/copies.rs:351:8 + | +LL | if a == 1 { + | ^^^^^^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:358:15 - | -358 | } else if 2 * a == 1 { - | ^^^^^^^^^^ - | + --> $DIR/copies.rs:358:15 + | +LL | } else if 2 * a == 1 { + | ^^^^^^^^^^ + | note: same as this - --> $DIR/copies.rs:356:8 - | -356 | if 2 * a == 1 { - | ^^^^^^^^^^ + --> $DIR/copies.rs:356:8 + | +LL | if 2 * a == 1 { + | ^^^^^^^^^^ error: aborting due to 20 previous errors diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index ced9293d1dc..34606df8595 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,13 +1,13 @@ error: you are implementing `Iterator` on a `Copy` type --> $DIR/copy_iterator.rs:15:1 | -15 | / impl Iterator for Countdown { -16 | | type Item = u8; -17 | | -18 | | fn next(&mut self) -> Option<u8> { +LL | / impl Iterator for Countdown { +LL | | type Item = u8; +LL | | +LL | | fn next(&mut self) -> Option<u8> { ... | -23 | | } -24 | | } +LL | | } +LL | | } | |_^ | = note: `-D clippy::copy-iterator` implied by `-D warnings` diff --git a/tests/ui/cstring.stderr b/tests/ui/cstring.stderr index 490a655ca26..d2968eb9d18 100644 --- a/tests/ui/cstring.stderr +++ b/tests/ui/cstring.stderr @@ -1,7 +1,7 @@ error: you are getting the inner pointer of a temporary `CString` --> $DIR/cstring.rs:16:5 | -16 | CString::new("foo").unwrap().as_ptr(); +LL | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(clippy::temporary_cstring_as_ptr)] on by default @@ -9,7 +9,7 @@ error: you are getting the inner pointer of a temporary `CString` help: assign the `CString` to a variable to extend its lifetime --> $DIR/cstring.rs:16:5 | -16 | CString::new("foo").unwrap().as_ptr(); +LL | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index de9e5c77f1b..f8e3a54debd 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -1,272 +1,272 @@ error: the function has a cyclomatic complexity of 28 --> $DIR/cyclomatic_complexity.rs:15:1 | -15 | / fn main() { -16 | | if true { -17 | | println!("a"); -18 | | } +LL | / fn main() { +LL | | if true { +LL | | println!("a"); +LL | | } ... | -96 | | } -97 | | } +LL | | } +LL | | } | |_^ | = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` = 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 - | -100 | / fn kaboom() { -101 | | let n = 0; -102 | | 'a: for i in 0..20 { -103 | | 'b: for j in i..20 { -... | -118 | | } -119 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:100:1 + | +LL | / fn kaboom() { +LL | | let n = 0; +LL | | 'a: for i in 0..20 { +LL | | 'b: for j in i..20 { +... | +LL | | } +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 - | -146 | / fn lots_of_short_circuits() -> bool { -147 | | true && false && true && false && true && false && true -148 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:146:1 + | +LL | / fn lots_of_short_circuits() -> bool { +LL | | true && false && true && false && true && false && true +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 - | -151 | / fn lots_of_short_circuits2() -> bool { -152 | | true || false || true || false || true || false || true -153 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:151:1 + | +LL | / fn lots_of_short_circuits2() -> bool { +LL | | true || false || true || false || true || false || true +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 - | -156 | / fn baa() { -157 | | let x = || match 99 { -158 | | 0 => 0, -159 | | 1 => 1, -... | -170 | | } -171 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:156:1 + | +LL | / fn baa() { +LL | | let x = || match 99 { +LL | | 0 => 0, +LL | | 1 => 1, +... | +LL | | } +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 - | -157 | let x = || match 99 { - | _____________^ -158 | | 0 => 0, -159 | | 1 => 1, -160 | | 2 => 2, -... | -164 | | _ => 42, -165 | | }; - | |_____^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:157:13 + | +LL | let x = || match 99 { + | _____________^ +LL | | 0 => 0, +LL | | 1 => 1, +LL | | 2 => 2, +... | +LL | | _ => 42, +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 - | -174 | / fn bar() { -175 | | match 99 { -176 | | 0 => println!("hi"), -177 | | _ => println!("bye"), -178 | | } -179 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:174:1 + | +LL | / fn bar() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | _ => println!("bye"), +LL | | } +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 - | -193 | / fn barr() { -194 | | match 99 { -195 | | 0 => println!("hi"), -196 | | 1 => println!("bla"), -... | -199 | | } -200 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:193:1 + | +LL | / fn barr() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | 1 => println!("bla"), +... | +LL | | } +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 - | -203 | / fn barr2() { -204 | | match 99 { -205 | | 0 => println!("hi"), -206 | | 1 => println!("bla"), -... | -215 | | } -216 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:203:1 + | +LL | / fn barr2() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | 1 => println!("bla"), +... | +LL | | } +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 - | -219 | / fn barrr() { -220 | | match 99 { -221 | | 0 => println!("hi"), -222 | | 1 => panic!("bla"), -... | -225 | | } -226 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:219:1 + | +LL | / fn barrr() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | 1 => panic!("bla"), +... | +LL | | } +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 - | -229 | / fn barrr2() { -230 | | match 99 { -231 | | 0 => println!("hi"), -232 | | 1 => panic!("bla"), -... | -241 | | } -242 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:229:1 + | +LL | / fn barrr2() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | 1 => panic!("bla"), +... | +LL | | } +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 - | -245 | / fn barrrr() { -246 | | match 99 { -247 | | 0 => println!("hi"), -248 | | 1 => println!("bla"), -... | -251 | | } -252 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:245:1 + | +LL | / fn barrrr() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | 1 => println!("bla"), +... | +LL | | } +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 - | -255 | / fn barrrr2() { -256 | | match 99 { -257 | | 0 => println!("hi"), -258 | | 1 => println!("bla"), -... | -267 | | } -268 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:255:1 + | +LL | / fn barrrr2() { +LL | | match 99 { +LL | | 0 => println!("hi"), +LL | | 1 => println!("bla"), +... | +LL | | } +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 - | -271 | / fn cake() { -272 | | if 4 == 5 { -273 | | println!("yea"); -274 | | } else { -... | -277 | | println!("whee"); -278 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:271:1 + | +LL | / fn cake() { +LL | | if 4 == 5 { +LL | | println!("yea"); +LL | | } else { +... | +LL | | println!("whee"); +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 - | -281 | / pub fn read_file(input_path: &str) -> String { -282 | | use std::fs::File; -283 | | use std::io::{Read, Write}; -284 | | use std::path::Path; -... | -306 | | } -307 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:281:1 + | +LL | / pub fn read_file(input_path: &str) -> String { +LL | | use std::fs::File; +LL | | use std::io::{Read, Write}; +LL | | use std::path::Path; +... | +LL | | } +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 - | -312 | / fn void(void: Void) { -313 | | if true { -314 | | match void {} -315 | | } -316 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:312:1 + | +LL | / fn void(void: Void) { +LL | | if true { +LL | | match void {} +LL | | } +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 - | -325 | / fn try() -> Result<i32, &'static str> { -326 | | match 5 { -327 | | 5 => Ok(5), -328 | | _ => return Err("bla"), -329 | | } -330 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:325:1 + | +LL | / fn try() -> Result<i32, &'static str> { +LL | | match 5 { +LL | | 5 => Ok(5), +LL | | _ => return Err("bla"), +LL | | } +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 - | -333 | / fn try_again() -> Result<i32, &'static str> { -334 | | let _ = try!(Ok(42)); -335 | | let _ = try!(Ok(43)); -336 | | let _ = try!(Ok(44)); -... | -345 | | } -346 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:333:1 + | +LL | / fn try_again() -> Result<i32, &'static str> { +LL | | let _ = try!(Ok(42)); +LL | | let _ = try!(Ok(43)); +LL | | let _ = try!(Ok(44)); +... | +LL | | } +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 - | -349 | / fn early() -> Result<i32, &'static str> { -350 | | return Ok(5); -351 | | return Ok(5); -352 | | return Ok(5); -... | -358 | | return Ok(5); -359 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:349:1 + | +LL | / fn early() -> Result<i32, &'static str> { +LL | | return Ok(5); +LL | | return Ok(5); +LL | | return Ok(5); +... | +LL | | return Ok(5); +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 - | -363 | / fn early_ret() -> i32 { -364 | | let a = if true { 42 } else { return 0; }; -365 | | let a = if a < 99 { 42 } else { return 0; }; -366 | | let a = if a < 99 { 42 } else { return 0; }; -... | -379 | | } -380 | | } - | |_^ - | - = help: you could split it up into multiple smaller functions + --> $DIR/cyclomatic_complexity.rs:363:1 + | +LL | / fn early_ret() -> i32 { +LL | | let a = if true { 42 } else { return 0; }; +LL | | let a = if a < 99 { 42 } else { return 0; }; +LL | | let a = if a < 99 { 42 } else { return 0; }; +... | +LL | | } +LL | | } + | |_^ + | + = help: you could split it up into multiple smaller functions error: aborting due to 20 previous errors diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index 3493c0d9ea5..dde803880ca 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -1,13 +1,13 @@ error: the function has a cyclomatic complexity of 3 --> $DIR/cyclomatic_complexity_attr_used.rs:18:1 | -18 | / fn kaboom() { -19 | | if 42 == 43 { -20 | | panic!(); -21 | | } else if "cake" == "lie" { -22 | | println!("what?"); -23 | | } -24 | | } +LL | / fn kaboom() { +LL | | if 42 == 43 { +LL | | panic!(); +LL | | } else if "cake" == "lie" { +LL | | println!("what?"); +LL | | } +LL | | } | |_^ | = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index c68a25f3dc3..cc908ca11f3 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,7 +1,7 @@ error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:25:9 | -25 | 32_773, // 0x8005 +LL | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` @@ -9,25 +9,25 @@ error: integer literal has a better hexadecimal representation error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:26:9 | -26 | 65_280, // 0xFF00 +LL | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:27:9 | -27 | 2_131_750_927, // 0x7F0F_F00F +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 | -28 | 2_147_483_647, // 0x7FFF_FFFF +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 | -29 | 4_042_322_160, // 0xF0F0_F0F0 +LL | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` error: aborting due to 5 previous errors diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index b838f6a3bf4..9fcf359b72f 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,7 +1,7 @@ error: Calling std::string::String::default() is more clear than this expression --> $DIR/default_trait_access.rs:17:22 | -17 | let s1: String = Default::default(); +LL | let s1: String = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` | = note: `-D clippy::default-trait-access` implied by `-D warnings` @@ -9,43 +9,43 @@ error: Calling std::string::String::default() is more clear than this expression error: Calling std::string::String::default() is more clear than this expression --> $DIR/default_trait_access.rs:21:22 | -21 | let s3: String = D2::default(); +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 | -23 | let s4: String = std::default::Default::default(); +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 | -27 | let s6: String = default::Default::default(); +LL | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling GenericDerivedDefault<std::string::String>::default() is more clear than this expression --> $DIR/default_trait_access.rs:37:46 | -37 | let s11: GenericDerivedDefault<String> = Default::default(); +LL | let s11: GenericDerivedDefault<String> = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault<std::string::String>::default()` error: Calling TupleDerivedDefault::default() is more clear than this expression --> $DIR/default_trait_access.rs:43:36 | -43 | let s14: TupleDerivedDefault = Default::default(); +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 | -45 | let s15: ArrayDerivedDefault = Default::default(); +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 | -49 | let s17: TupleStructDerivedDefault = Default::default(); +LL | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` error: aborting due to 8 previous errors diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index 335f6451e59..3d1f016b9b9 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -1,7 +1,7 @@ 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 | -10 | #[warn(str_to_string)] +LL | #[warn(str_to_string)] | ^^^^^^^^^^^^^ | = note: `-D renamed-and-removed-lints` implied by `-D warnings` @@ -9,25 +9,25 @@ error: lint `str_to_string` has been removed: `using `str::to_string` is common 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 | -11 | #[warn(string_to_string)] +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 | -12 | #[warn(unstable_as_slice)] +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 | -13 | #[warn(unstable_as_mut_slice)] +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 | -14 | #[warn(misaligned_transmute)] +LL | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index dd36f773337..b9629005597 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -1,130 +1,130 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly --> $DIR/derive.rs:25:10 | -25 | #[derive(Hash)] +LL | #[derive(Hash)] | ^^^^ | = note: #[deny(clippy::derive_hash_xor_eq)] on by default note: `PartialEq` implemented here --> $DIR/derive.rs:28:1 | -28 | / impl PartialEq for Bar { -29 | | fn eq(&self, _: &Bar) -> bool { -30 | | true -31 | | } -32 | | } +LL | / impl PartialEq for Bar { +LL | | fn eq(&self, _: &Bar) -> bool { +LL | | true +LL | | } +LL | | } | |_^ error: you are deriving `Hash` but have implemented `PartialEq` explicitly --> $DIR/derive.rs:34:10 | -34 | #[derive(Hash)] +LL | #[derive(Hash)] | ^^^^ | note: `PartialEq` implemented here --> $DIR/derive.rs:37:1 | -37 | / impl PartialEq<Baz> for Baz { -38 | | fn eq(&self, _: &Baz) -> bool { -39 | | true -40 | | } -41 | | } +LL | / impl PartialEq<Baz> for Baz { +LL | | fn eq(&self, _: &Baz) -> bool { +LL | | true +LL | | } +LL | | } | |_^ error: you are implementing `Hash` explicitly but have derived `PartialEq` --> $DIR/derive.rs:46:1 | -46 | / impl Hash for Bah { -47 | | fn hash<H: Hasher>(&self, _: &mut H) {} -48 | | } +LL | / impl Hash for Bah { +LL | | fn hash<H: Hasher>(&self, _: &mut H) {} +LL | | } | |_^ | note: `PartialEq` implemented here --> $DIR/derive.rs:43:10 | -43 | #[derive(PartialEq)] +LL | #[derive(PartialEq)] | ^^^^^^^^^ error: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:53:1 | -53 | / impl Clone for Qux { -54 | | fn clone(&self) -> Self { -55 | | Qux -56 | | } -57 | | } +LL | / impl Clone for Qux { +LL | | fn clone(&self) -> Self { +LL | | Qux +LL | | } +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 | -53 | / impl Clone for Qux { -54 | | fn clone(&self) -> Self { -55 | | Qux -56 | | } -57 | | } +LL | / impl Clone for Qux { +LL | | fn clone(&self) -> Self { +LL | | Qux +LL | | } +LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:77:1 | -77 | / impl<'a> Clone for Lt<'a> { -78 | | fn clone(&self) -> Self { -79 | | unimplemented!() -80 | | } -81 | | } +LL | / impl<'a> Clone for Lt<'a> { +LL | | fn clone(&self) -> Self { +LL | | unimplemented!() +LL | | } +LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` --> $DIR/derive.rs:77:1 | -77 | / impl<'a> Clone for Lt<'a> { -78 | | fn clone(&self) -> Self { -79 | | unimplemented!() -80 | | } -81 | | } +LL | / impl<'a> Clone for Lt<'a> { +LL | | fn clone(&self) -> Self { +LL | | unimplemented!() +LL | | } +LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:89:1 | -89 | / impl Clone for BigArray { -90 | | fn clone(&self) -> Self { -91 | | unimplemented!() -92 | | } -93 | | } +LL | / impl Clone for BigArray { +LL | | fn clone(&self) -> Self { +LL | | unimplemented!() +LL | | } +LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` --> $DIR/derive.rs:89:1 | -89 | / impl Clone for BigArray { -90 | | fn clone(&self) -> Self { -91 | | unimplemented!() -92 | | } -93 | | } +LL | / impl Clone for BigArray { +LL | | fn clone(&self) -> Self { +LL | | unimplemented!() +LL | | } +LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:101:1 - | -101 | / impl Clone for FnPtr { -102 | | fn clone(&self) -> Self { -103 | | unimplemented!() -104 | | } -105 | | } - | |_^ - | + --> $DIR/derive.rs:101:1 + | +LL | / impl Clone for FnPtr { +LL | | fn clone(&self) -> Self { +LL | | unimplemented!() +LL | | } +LL | | } + | |_^ + | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:101:1 - | -101 | / impl Clone for FnPtr { -102 | | fn clone(&self) -> Self { -103 | | unimplemented!() -104 | | } -105 | | } - | |_^ + --> $DIR/derive.rs:101:1 + | +LL | / impl Clone for FnPtr { +LL | | fn clone(&self) -> Self { +LL | | unimplemented!() +LL | | } +LL | | } + | |_^ error: aborting due to 7 previous errors diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index fea2bd1aa41..1cfec07c560 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -1,7 +1,7 @@ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:30:10 | -30 | b || diverge(); +LL | b || diverge(); | ^^^^^^^^^ | = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` @@ -9,31 +9,31 @@ error: sub-expression diverges error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:31:10 | -31 | b || A.foo(); +LL | b || A.foo(); | ^^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:40:26 | -40 | 6 => true || return, +LL | 6 => true || return, | ^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:41:26 | -41 | 7 => true || continue, +LL | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:44:26 | -44 | 3 => true || diverge(), +LL | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:49:26 | -49 | _ => true || break, +LL | _ => true || break, | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index f2ca4dab997..6b0413fdf23 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -1,7 +1,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:19:16 | -19 | type Baz = LinkedList<u8>; +LL | type Baz = LinkedList<u8>; | ^^^^^^^^^^^^^^ | = note: `-D clippy::linkedlist` implied by `-D warnings` @@ -10,7 +10,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:20:12 | -20 | fn foo(LinkedList<u8>); +LL | fn foo(LinkedList<u8>); | ^^^^^^^^^^^^^^ | = help: a VecDeque might work @@ -18,7 +18,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:21:23 | -21 | const BAR: Option<LinkedList<u8>>; +LL | const BAR: Option<LinkedList<u8>>; | ^^^^^^^^^^^^^^ | = help: a VecDeque might work @@ -26,7 +26,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:32:15 | -32 | fn foo(_: LinkedList<u8>) {} +LL | fn foo(_: LinkedList<u8>) {} | ^^^^^^^^^^^^^^ | = help: a VecDeque might work @@ -34,7 +34,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:35:39 | -35 | pub fn test(my_favourite_linked_list: LinkedList<u8>) { +LL | pub fn test(my_favourite_linked_list: LinkedList<u8>) { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work @@ -42,7 +42,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:39:29 | -39 | pub fn test_ret() -> Option<LinkedList<u8>> { +LL | pub fn test_ret() -> Option<LinkedList<u8>> { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work diff --git a/tests/ui/doc.stderr b/tests/ui/doc.stderr index 26ac8103558..964e351348a 100644 --- a/tests/ui/doc.stderr +++ b/tests/ui/doc.stderr @@ -1,7 +1,7 @@ error: you should put `DOC_MARKDOWN` between ticks in the documentation --> $DIR/doc.rs:10:29 | -10 | //! This file tests for the DOC_MARKDOWN lint +LL | //! This file tests for the DOC_MARKDOWN lint | ^^^^^^^^^^^^ | = note: `-D clippy::doc-markdown` implied by `-D warnings` @@ -9,182 +9,182 @@ error: you should put `DOC_MARKDOWN` between ticks in the documentation error: you should put `foo_bar` between ticks in the documentation --> $DIR/doc.rs:15:9 | -15 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) +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 | -15 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) +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 | -16 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun +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 | -18 | /// Here be ::a::global:path. +LL | /// Here be ::a::global:path. | ^^^^^^^^^^^^^^ error: you should put `NotInCodeBlock` between ticks in the documentation --> $DIR/doc.rs:19:22 | -19 | /// That's not code ~NotInCodeBlock~. +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 | -20 | /// be_sure_we_got_to_the_end_of_it +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 | -34 | /// be_sure_we_got_to_the_end_of_it +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 | -41 | /// be_sure_we_got_to_the_end_of_it +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 | -55 | /// be_sure_we_got_to_the_end_of_it +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 | -59 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. +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 | -62 | /// It can also be [inline_link2]. +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 | -72 | /// be_sure_we_got_to_the_end_of_it +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 | -80 | /// ## CamelCaseThing +LL | /// ## CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation --> $DIR/doc.rs:83:7 | -83 | /// # CamelCaseThing +LL | /// # CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation --> $DIR/doc.rs:85:22 | -85 | /// Not a title #897 CamelCaseThing +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 | -86 | /// be_sure_we_got_to_the_end_of_it +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 | -93 | /// be_sure_we_got_to_the_end_of_it +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 - | -106 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:106: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 - | -117 | /** E.g. serialization of an empty list: FooBar - | ^^^^^^ + --> $DIR/doc.rs:117: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 - | -122 | And BarQuz too. - | ^^^^^^ + --> $DIR/doc.rs:122: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 - | -123 | be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:123: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 - | -128 | /** E.g. serialization of an empty list: FooBar - | ^^^^^^ + --> $DIR/doc.rs:128: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 - | -133 | And BarQuz too. - | ^^^^^^ + --> $DIR/doc.rs:133: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 - | -134 | be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:134: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 - | -145 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:145: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 - | -172 | /// Not ok: http://www.unicode.org - | ^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:172: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 - | -173 | /// Not ok: https://www.unicode.org - | ^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:173: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 - | -174 | /// Not ok: http://www.unicode.org/ - | ^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:174: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 - | -175 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:175: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 - | -181 | /// An iterator over mycrate::Collection's values. - | ^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:181:22 + | +LL | /// An iterator over mycrate::Collection's values. + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 31 previous errors diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index a06f278efc0..f4ec229fbfd 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -1,7 +1,7 @@ error: This binary expression can be simplified --> $DIR/double_comparison.rs:13:8 | -13 | if x == y || x < y { +LL | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` | = note: `-D clippy::double-comparisons` implied by `-D warnings` @@ -9,43 +9,43 @@ error: This binary expression can be simplified error: This binary expression can be simplified --> $DIR/double_comparison.rs:16:8 | -16 | if x < y || x == y { +LL | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` error: This binary expression can be simplified --> $DIR/double_comparison.rs:19:8 | -19 | if x == y || x > y { +LL | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified --> $DIR/double_comparison.rs:22:8 | -22 | if x > y || x == y { +LL | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified --> $DIR/double_comparison.rs:25:8 | -25 | if x < y || x > y { +LL | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified --> $DIR/double_comparison.rs:28:8 | -28 | if x > y || x < y { +LL | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified --> $DIR/double_comparison.rs:31:8 | -31 | if x <= y && x >= y { +LL | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: This binary expression can be simplified --> $DIR/double_comparison.rs:34:8 | -34 | if x >= y && x <= y { +LL | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: aborting due to 8 previous errors diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index 11ad5601286..6ff18e5504d 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,7 +1,7 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op --> $DIR/double_neg.rs:15:5 | -15 | --x; +LL | --x; | ^^^ | = note: `-D clippy::double-neg` implied by `-D warnings` diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index d736d72c143..0e7f62ca3e3 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -1,7 +1,7 @@ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:21:5 | -21 | ((0)) +LL | ((0)) | ^^^^^ | = note: `-D clippy::double-parens` implied by `-D warnings` @@ -9,31 +9,31 @@ error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:25:14 | -25 | dummy_fn((0)); +LL | dummy_fn((0)); | ^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:29:20 | -29 | x.dummy_method((0)); +LL | x.dummy_method((0)); | ^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:33:5 | -33 | ((1, 2)) +LL | ((1, 2)) | ^^^^^^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:37:5 | -37 | (()) +LL | (()) | ^^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:59:16 | -59 | assert_eq!(((1, 2)), (1, 2), "Error"); +LL | assert_eq!(((1, 2)), (1, 2), "Error"); | ^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index 3b950eaebe3..6fc69c4bcda 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -1,75 +1,75 @@ 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 | -42 | drop(s1); +LL | drop(s1); | ^^^^^^^^ | = note: `-D clippy::drop-copy` implied by `-D warnings` note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:42:10 | -42 | drop(s1); +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 | -43 | drop(s2); +LL | drop(s2); | ^^^^^^^^ | note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:43:10 | -43 | drop(s2); +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 | -45 | drop(s4); +LL | drop(s4); | ^^^^^^^^ | note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:45:10 | -45 | drop(s4); +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 | -48 | forget(s1); +LL | forget(s1); | ^^^^^^^^^^ | = note: `-D clippy::forget-copy` implied by `-D warnings` note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:48:12 | -48 | forget(s1); +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 | -49 | forget(s2); +LL | forget(s2); | ^^^^^^^^^^ | note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:49:12 | -49 | forget(s2); +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 | -51 | forget(s4); +LL | forget(s4); | ^^^^^^^^^^ | note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:51:12 | -51 | forget(s4); +LL | forget(s4); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 972ab298c4c..005adceca50 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -1,219 +1,219 @@ 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 | -18 | drop(&SomeStruct); +LL | drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::drop-ref` implied by `-D warnings` note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:18:10 | -18 | drop(&SomeStruct); +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 | -19 | forget(&SomeStruct); +LL | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:19:12 | -19 | forget(&SomeStruct); +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 | -22 | drop(&owned1); +LL | drop(&owned1); | ^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:22:10 | -22 | drop(&owned1); +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 | -23 | drop(&&owned1); +LL | drop(&&owned1); | ^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct --> $DIR/drop_forget_ref.rs:23:10 | -23 | drop(&&owned1); +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 | -24 | drop(&mut owned1); +LL | drop(&mut owned1); | ^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:24:10 | -24 | drop(&mut owned1); +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 | -27 | forget(&owned2); +LL | forget(&owned2); | ^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:27:12 | -27 | forget(&owned2); +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 | -28 | forget(&&owned2); +LL | forget(&&owned2); | ^^^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct --> $DIR/drop_forget_ref.rs:28:12 | -28 | forget(&&owned2); +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 | -29 | forget(&mut owned2); +LL | forget(&mut owned2); | ^^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:29:12 | -29 | forget(&mut owned2); +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 | -33 | drop(reference1); +LL | drop(reference1); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:33:10 | -33 | drop(reference1); +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 | -34 | forget(&*reference1); +LL | forget(&*reference1); | ^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:34:12 | -34 | forget(&*reference1); +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 | -37 | drop(reference2); +LL | drop(reference2); | ^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:37:10 | -37 | drop(reference2); +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:39:5 | -39 | forget(reference3); +LL | forget(reference3); | ^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:39:12 | -39 | forget(reference3); +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 | -42 | drop(reference4); +LL | drop(reference4); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:42:10 | -42 | drop(reference4); +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 | -43 | forget(reference4); +LL | forget(reference4); | ^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:43:12 | -43 | forget(reference4); +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 | -48 | drop(&val); +LL | drop(&val); | ^^^^^^^^^^ | note: argument has type &T --> $DIR/drop_forget_ref.rs:48:10 | -48 | drop(&val); +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 | -54 | forget(&val); +LL | forget(&val); | ^^^^^^^^^^^^ | note: argument has type &T --> $DIR/drop_forget_ref.rs:54:12 | -54 | forget(&val); +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 | -62 | std::mem::drop(&SomeStruct); +LL | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:62:20 | -62 | std::mem::drop(&SomeStruct); +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 | -65 | std::mem::forget(&SomeStruct); +LL | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:65:22 | -65 | std::mem::forget(&SomeStruct); +LL | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ error: aborting due to 18 previous errors diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index ba1b5b1ded7..e4bdd3f96b2 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -1,7 +1,7 @@ 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 | -13 | fn join_the_dark_side(darth: i32, _darth: i32) {} +LL | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | = note: `-D clippy::duplicate-underscore-argument` implied by `-D warnings` diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index 1310ac12340..e87c9839b33 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,7 +1,7 @@ error: Calling `subsec_millis()` is more concise than this calculation --> $DIR/duration_subsec.rs:17:24 | -17 | let bad_millis_1 = dur.subsec_micros() / 1_000; +LL | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` | = note: `-D clippy::duration-subsec` implied by `-D warnings` @@ -9,25 +9,25 @@ error: Calling `subsec_millis()` is more concise than this calculation error: Calling `subsec_millis()` is more concise than this calculation --> $DIR/duration_subsec.rs:18:24 | -18 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; +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 | -23 | let bad_micros = dur.subsec_nanos() / 1_000; +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 | -28 | let _ = (&dur).subsec_nanos() / 1_000; +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 | -32 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; +LL | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: aborting due to 5 previous errors diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index 8771df87297..2c1ecbfdb86 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -1,11 +1,11 @@ error: if expression with an `else if`, but without a final `else` --> $DIR/else_if_without_else.rs:54:12 | -54 | } else if bla2() { +LL | } else if bla2() { | ____________^ -55 | | //~ ERROR else if without else -56 | | println!("else if"); -57 | | } +LL | | //~ ERROR else if without else +LL | | println!("else if"); +LL | | } | |_____^ | = note: `-D clippy::else-if-without-else` implied by `-D warnings` @@ -14,11 +14,11 @@ error: if expression with an `else if`, but without a final `else` error: if expression with an `else if`, but without a final `else` --> $DIR/else_if_without_else.rs:63:12 | -63 | } else if bla3() { +LL | } else if bla3() { | ____________^ -64 | | //~ ERROR else if without else -65 | | println!("else if 2"); -66 | | } +LL | | //~ ERROR else if without else +LL | | println!("else if 2"); +LL | | } | |_____^ | = help: add an `else` block here diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index fd981f2210f..d2e3688eb4d 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,14 +1,14 @@ error: enum with no variants --> $DIR/empty_enum.rs:13:1 | -13 | enum Empty {} +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 | -13 | enum Empty {} +LL | enum Empty {} | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/empty_line_after_outer_attribute.stderr b/tests/ui/empty_line_after_outer_attribute.stderr index ec3ee6d018c..59939ea2858 100644 --- a/tests/ui/empty_line_after_outer_attribute.stderr +++ b/tests/ui/empty_line_after_outer_attribute.stderr @@ -1,10 +1,10 @@ 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 | -13 | / #[crate_type = "lib"] -14 | | -15 | | /// some comment -16 | | fn with_one_newline_and_comment() { assert!(true) } +LL | / #[crate_type = "lib"] +LL | | +LL | | /// some comment +LL | | fn with_one_newline_and_comment() { assert!(true) } | |_ | = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` @@ -12,42 +12,42 @@ error: Found an empty line after an outer attribute. Perhaps you forgot to add a 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 | -25 | / #[crate_type = "lib"] -26 | | -27 | | fn with_one_newline() { assert!(true) } +LL | / #[crate_type = "lib"] +LL | | +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 | -30 | / #[crate_type = "lib"] -31 | | -32 | | -33 | | fn with_two_newlines() { assert!(true) } +LL | / #[crate_type = "lib"] +LL | | +LL | | +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 | -37 | / #[crate_type = "lib"] -38 | | -39 | | enum Baz { +LL | / #[crate_type = "lib"] +LL | | +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 | -45 | / #[crate_type = "lib"] -46 | | -47 | | struct Foo { +LL | / #[crate_type = "lib"] +LL | | +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 | -53 | / #[crate_type = "lib"] -54 | | -55 | | mod foo { +LL | / #[crate_type = "lib"] +LL | | +LL | | mod foo { | |_ error: aborting due to 6 previous errors diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 9a4e0ba31ee..78a179d07ef 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,9 +1,9 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:19:5 | -19 | / if !m.contains_key(&k) { -20 | | m.insert(k, v); -21 | | } +LL | / if !m.contains_key(&k) { +LL | | m.insert(k, v); +LL | | } | |_____^ help: consider using: `m.entry(k).or_insert(v)` | = note: `-D clippy::map-entry` implied by `-D warnings` @@ -11,63 +11,63 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:25:5 | -25 | / if !m.contains_key(&k) { -26 | | foo(); -27 | | m.insert(k, v); -28 | | } +LL | / if !m.contains_key(&k) { +LL | | foo(); +LL | | m.insert(k, v); +LL | | } | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:32:5 | -32 | / if !m.contains_key(&k) { -33 | | m.insert(k, v) -34 | | } else { -35 | | None -36 | | }; +LL | / if !m.contains_key(&k) { +LL | | m.insert(k, v) +LL | | } else { +LL | | None +LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:40:5 | -40 | / if m.contains_key(&k) { -41 | | None -42 | | } else { -43 | | m.insert(k, v) -44 | | }; +LL | / if m.contains_key(&k) { +LL | | None +LL | | } else { +LL | | m.insert(k, v) +LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:48:5 | -48 | / if !m.contains_key(&k) { -49 | | foo(); -50 | | m.insert(k, v) -51 | | } else { -52 | | None -53 | | }; +LL | / if !m.contains_key(&k) { +LL | | foo(); +LL | | m.insert(k, v) +LL | | } else { +LL | | None +LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:57:5 | -57 | / if m.contains_key(&k) { -58 | | None -59 | | } else { -60 | | foo(); -61 | | m.insert(k, v) -62 | | }; +LL | / if m.contains_key(&k) { +LL | | None +LL | | } else { +LL | | foo(); +LL | | m.insert(k, v) +LL | | }; | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `BTreeMap` --> $DIR/entry.rs:66:5 | -66 | / if !m.contains_key(&k) { -67 | | foo(); -68 | | m.insert(k, v) -69 | | } else { -70 | | None -71 | | }; +LL | / if !m.contains_key(&k) { +LL | | foo(); +LL | | m.insert(k, v) +LL | | } else { +LL | | None +LL | | }; | |_____^ help: consider using: `m.entry(k)` error: aborting due to 7 previous errors diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 58c6f4d3301..8b89856d4a4 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,7 +1,7 @@ error: don't use glob imports for enum variants --> $DIR/enum_glob_use.rs:13:1 | -13 | use std::cmp::Ordering::*; +LL | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::enum-glob-use` implied by `-D warnings` @@ -9,7 +9,7 @@ error: don't use glob imports for enum variants error: don't use glob imports for enum variants --> $DIR/enum_glob_use.rs:19:1 | -19 | use self::Enum::*; +LL | use self::Enum::*; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/enum_variants.rs b/tests/ui/enum_variants.rs index 0c8f3a36a3d..33472a7f83c 100644 --- a/tests/ui/enum_variants.rs +++ b/tests/ui/enum_variants.rs @@ -9,6 +9,7 @@ #![feature(non_ascii_idents)] #![warn(clippy::all, clippy::pub_enum_variant_names)] +#![allow(non_camel_case_types)] enum FakeCallType { CALL, diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index ff8f9b82ae6..4555e1d0649 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,101 +1,101 @@ error: Variant name ends with the enum's name - --> $DIR/enum_variants.rs:24:5 + --> $DIR/enum_variants.rs:25:5 | -24 | cFoo, +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:35:5 + --> $DIR/enum_variants.rs:36:5 | -35 | FoodGood, +LL | FoodGood, | ^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:36:5 + --> $DIR/enum_variants.rs:37:5 | -36 | FoodMiddle, +LL | FoodMiddle, | ^^^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:37:5 + --> $DIR/enum_variants.rs:38:5 | -37 | FoodBad, +LL | FoodBad, | ^^^^^^^ error: All variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:34:1 + --> $DIR/enum_variants.rs:35:1 | -34 | / enum Food { -35 | | FoodGood, -36 | | FoodMiddle, -37 | | FoodBad, -38 | | } +LL | / enum Food { +LL | | FoodGood, +LL | | FoodMiddle, +LL | | FoodBad, +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:44:1 + --> $DIR/enum_variants.rs:45:1 | -44 | / enum BadCallType { -45 | | CallTypeCall, -46 | | CallTypeCreate, -47 | | CallTypeDestroy, -48 | | } +LL | / enum BadCallType { +LL | | CallTypeCall, +LL | | CallTypeCreate, +LL | | CallTypeDestroy, +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:56:1 + --> $DIR/enum_variants.rs:57:1 | -56 | / enum Consts { -57 | | ConstantInt, -58 | | ConstantCake, -59 | | ConstantLie, -60 | | } +LL | / enum Consts { +LL | | ConstantInt, +LL | | ConstantCake, +LL | | ConstantLie, +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:90:1 + --> $DIR/enum_variants.rs:91:1 | -90 | / enum Seallll { -91 | | WithOutCake, -92 | | WithOutTea, -93 | | WithOut, -94 | | } +LL | / enum Seallll { +LL | | WithOutCake, +LL | | WithOutTea, +LL | | WithOut, +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:96:1 - | -96 | / enum NonCaps { -97 | | Prefix的, -98 | | PrefixTea, -99 | | PrefixCake, -100 | | } - | |_^ - | - = help: remove the prefixes and use full paths to the variants instead of glob imports + --> $DIR/enum_variants.rs:97:1 + | +LL | / enum NonCaps { +LL | | Prefix的, +LL | | PrefixTea, +LL | | PrefixCake, +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:102:1 - | -102 | / pub enum PubSeall { -103 | | WithOutCake, -104 | | WithOutTea, -105 | | WithOut, -106 | | } - | |_^ - | - = note: `-D clippy::pub-enum-variant-names` implied by `-D warnings` - = help: remove the prefixes and use full paths to the variants instead of glob imports + --> $DIR/enum_variants.rs:103:1 + | +LL | / pub enum PubSeall { +LL | | WithOutCake, +LL | | WithOutTea, +LL | | WithOut, +LL | | } + | |_^ + | + = note: `-D clippy::pub-enum-variant-names` implied by `-D warnings` + = help: remove the prefixes and use full paths to the variants instead of glob imports error: aborting due to 10 previous errors diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index 0756b9a80d4..f883529b996 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -1,7 +1,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:17:5 | -17 | X = 0x1_0000_0000, +LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings` @@ -9,43 +9,43 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:24:5 | -24 | X = 0x1_0000_0000, +LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:27:5 | -27 | A = 0xFFFF_FFFF, +LL | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:34:5 | -34 | Z = 0xFFFF_FFFF, +LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:35:5 | -35 | A = 0x1_0000_0000, +LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:37:5 | -37 | C = (std::i32::MIN as isize) - 1, +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 | -43 | Z = 0xFFFF_FFFF, +LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:44:5 | -44 | A = 0x1_0000_0000, +LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index abd351b65a4..a1a257095c2 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -1,7 +1,7 @@ error: this boolean expression can be simplified --> $DIR/eq_op.rs:44:5 | -44 | true && true; +LL | true && true; | ^^^^^^^^^^^^ help: try: `true` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` @@ -9,37 +9,37 @@ error: this boolean expression can be simplified error: this boolean expression can be simplified --> $DIR/eq_op.rs:46:5 | -46 | true || true; +LL | true || true; | ^^^^^^^^^^^^ help: try: `true` error: this boolean expression can be simplified --> $DIR/eq_op.rs:52:5 | -52 | a == b && b == a; +LL | a == b && b == a; | ^^^^^^^^^^^^^^^^ help: try: `a == b` error: this boolean expression can be simplified --> $DIR/eq_op.rs:53:5 | -53 | a != b && b != a; +LL | a != b && b != a; | ^^^^^^^^^^^^^^^^ help: try: `a != b` error: this boolean expression can be simplified --> $DIR/eq_op.rs:54:5 | -54 | a < b && b > a; +LL | a < b && b > a; | ^^^^^^^^^^^^^^ help: try: `a < b` error: this boolean expression can be simplified --> $DIR/eq_op.rs:55:5 | -55 | a <= b && b >= a; +LL | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ help: try: `a <= b` error: equal expressions as operands to `==` --> $DIR/eq_op.rs:17:5 | -17 | 1 == 1; +LL | 1 == 1; | ^^^^^^ | = note: `-D clippy::eq-op` implied by `-D warnings` @@ -47,157 +47,157 @@ error: equal expressions as operands to `==` error: equal expressions as operands to `==` --> $DIR/eq_op.rs:18:5 | -18 | "no" == "no"; +LL | "no" == "no"; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` --> $DIR/eq_op.rs:20:5 | -20 | false != false; +LL | false != false; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `<` --> $DIR/eq_op.rs:21:5 | -21 | 1.5 < 1.5; +LL | 1.5 < 1.5; | ^^^^^^^^^ error: equal expressions as operands to `>=` --> $DIR/eq_op.rs:22:5 | -22 | 1u64 >= 1u64; +LL | 1u64 >= 1u64; | ^^^^^^^^^^^^ error: equal expressions as operands to `&` --> $DIR/eq_op.rs:25:5 | -25 | (1 as u64) & (1 as u64); +LL | (1 as u64) & (1 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `^` --> $DIR/eq_op.rs:26:5 | -26 | 1 ^ ((((((1)))))); +LL | 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `<` --> $DIR/eq_op.rs:29:5 | -29 | (-(2) < -(2)); +LL | (-(2) < -(2)); | ^^^^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:30:5 | -30 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); +LL | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` --> $DIR/eq_op.rs:30:6 | -30 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); +LL | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` --> $DIR/eq_op.rs:30:27 | -30 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); +LL | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:31:5 | -31 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; +LL | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` --> $DIR/eq_op.rs:34:5 | -34 | ([1] != [1]); +LL | ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` --> $DIR/eq_op.rs:35:5 | -35 | ((1, 2) != (1, 2)); +LL | ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:39:5 | -39 | 1 + 1 == 2; +LL | 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:40:5 | -40 | 1 - 1 == 0; +LL | 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` --> $DIR/eq_op.rs:40:5 | -40 | 1 - 1 == 0; +LL | 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` --> $DIR/eq_op.rs:42:5 | -42 | 1 - 1; +LL | 1 - 1; | ^^^^^ error: equal expressions as operands to `/` --> $DIR/eq_op.rs:43:5 | -43 | 1 / 1; +LL | 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:44:5 | -44 | true && true; +LL | true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` --> $DIR/eq_op.rs:46:5 | -46 | true || true; +LL | true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:52:5 | -52 | a == b && b == a; +LL | a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:53:5 | -53 | a != b && b != a; +LL | a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:54:5 | -54 | a < b && b > a; +LL | a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:55:5 | -55 | a <= b && b >= a; +LL | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:58:5 | -58 | a == a; +LL | a == a; | ^^^^^^ error: taken reference of right operand --> $DIR/eq_op.rs:96:13 | -96 | let z = x & &y; +LL | let z = x & &y; | ^^^^-- | | | help: use the right value directly: `y` @@ -205,10 +205,10 @@ error: taken reference of right operand = note: `-D clippy::op-ref` implied by `-D warnings` error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:104:20 - | -104 | const D: u32 = A / A; - | ^^^^^ + --> $DIR/eq_op.rs:104:20 + | +LL | const D: u32 = A / A; + | ^^^^^ error: aborting due to 34 previous errors diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index a500a132af7..85548eefba7 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,7 +1,7 @@ error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:15:5 | -15 | x * 0; +LL | x * 0; | ^^^^^ | = note: `-D clippy::erasing-op` implied by `-D warnings` @@ -9,13 +9,13 @@ error: this operation will always return zero. This is likely not the intended o error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:16:5 | -16 | 0 & x; +LL | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:17:5 | -17 | 0 / x; +LL | 0 / x; | ^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/escape_analysis.stderr b/tests/ui/escape_analysis.stderr index ec9b7317eed..ed7819ed429 100644 --- a/tests/ui/escape_analysis.stderr +++ b/tests/ui/escape_analysis.stderr @@ -1,16 +1,16 @@ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:43:13 | -43 | fn warn_arg(x: Box<A>) { +LL | fn warn_arg(x: Box<A>) { | ^ | = 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 - | -134 | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {} - | ^^^^^^^^^^^ + --> $DIR/escape_analysis.rs:134:12 + | +LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {} + | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index cd14855c49d..fb7daba1578 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,7 +1,7 @@ error: redundant closure found --> $DIR/eta.rs:22:27 | -22 | let a = Some(1u8).map(|a| foo(a)); +LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` | = note: `-D clippy::redundant-closure` implied by `-D warnings` @@ -9,19 +9,19 @@ error: redundant closure found error: redundant closure found --> $DIR/eta.rs:23:10 | -23 | meta(|a| foo(a)); +LL | meta(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` error: redundant closure found --> $DIR/eta.rs:24:27 | -24 | let c = Some(1u8).map(|a| {1+2; foo}(a)); +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 | -26 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted +LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^ help: change this to: `&2` | = note: `-D clippy::needless-borrow` implied by `-D warnings` @@ -29,7 +29,7 @@ error: this expression borrows a reference that is immediately dereferenced by t error: redundant closure found --> $DIR/eta.rs:33:27 | -33 | let e = Some(1u8).map(|a| generic(a)); +LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` error: aborting due to 5 previous errors diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index 38317376fc4..929650a7da8 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -1,50 +1,50 @@ error: unsequenced read of a variable --> $DIR/eval_order_dependence.rs:24:9 | -24 | } + x; +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 | -22 | x = 1; +LL | x = 1; | ^^^^^ error: unsequenced read of a variable --> $DIR/eval_order_dependence.rs:27:5 | -27 | x += { +LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order --> $DIR/eval_order_dependence.rs:28:9 | -28 | x = 20; +LL | x = 20; | ^^^^^^ error: unsequenced read of a variable --> $DIR/eval_order_dependence.rs:40:12 | -40 | a: x, +LL | a: x, | ^ | note: whether read occurs before this write depends on evaluation order --> $DIR/eval_order_dependence.rs:42:13 | -42 | x = 6; +LL | x = 6; | ^^^^^ error: unsequenced read of a variable --> $DIR/eval_order_dependence.rs:49:9 | -49 | x += { +LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order --> $DIR/eval_order_dependence.rs:50:13 | -50 | x = 20; +LL | x = 20; | ^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index a69652373d5..57c33c4719b 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -1,7 +1,7 @@ error: float has excessive precision --> $DIR/excessive_precision.rs:23:26 | -23 | const BAD32_1: f32 = 0.123_456_789_f32; +LL | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` | = note: `-D clippy::excessive-precision` implied by `-D warnings` @@ -9,103 +9,103 @@ error: float has excessive precision error: float has excessive precision --> $DIR/excessive_precision.rs:24:26 | -24 | const BAD32_2: f32 = 0.123_456_789; +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 | -25 | const BAD32_3: f32 = 0.100_000_000_000_1; +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 | -26 | const BAD32_EDGE: f32 = 1.000_000_9; +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 | -28 | const BAD64_1: f64 = 0.123_456_789_012_345_67f64; +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 | -29 | const BAD64_2: f64 = 0.123_456_789_012_345_67; +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 | -30 | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; +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 | -33 | println!("{:?}", 8.888_888_888_888_888_888_888); +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 | -44 | let bad32: f32 = 1.123_456_789; +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 | -45 | let bad32_suf: f32 = 1.123_456_789_f32; +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 | -46 | let bad32_inf = 1.123_456_789_f32; +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 | -48 | let bad64: f64 = 0.123_456_789_012_345_67; +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 | -49 | let bad64_suf: f64 = 0.123_456_789_012_345_67f64; +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 | -50 | let bad64_inf = 0.123_456_789_012_345_67; +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 | -56 | let bad_vec32: Vec<f32> = vec![0.123_456_789]; +LL | let bad_vec32: Vec<f32> = 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 | -57 | let bad_vec64: Vec<f64> = vec![0.123_456_789_123_456_789]; +LL | let bad_vec64: Vec<f64> = 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 | -61 | let bad_e32: f32 = 1.123_456_788_888e-10; +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 | -64 | let bad_bige32: f32 = 1.123_456_788_888E-10; +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` error: aborting due to 18 previous errors diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr index ad8fe14e9a0..72a6995c1ce 100644 --- a/tests/ui/expect_fun_call.stderr +++ b/tests/ui/expect_fun_call.stderr @@ -1,7 +1,7 @@ error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:36:26 | -36 | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); +LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` | = note: `-D clippy::expect-fun-call` implied by `-D warnings` @@ -9,31 +9,31 @@ error: use of `expect` followed by a function call error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:39:26 | -39 | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); +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 | -49 | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); +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 | -52 | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); +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 | -67 | Some("foo").expect({ &format!("error") }); +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 | -68 | Some("foo").expect(format!("error").as_ref()); +LL | Some("foo").expect(format!("error").as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("error"))` error: aborting due to 6 previous errors diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index caafd2375f0..caccaee84b9 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -1,7 +1,7 @@ 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 | -15 | for _v in &vec { +LL | for _v in &vec { | ^^^^ | = note: `-D clippy::explicit-counter-loop` implied by `-D warnings` @@ -9,19 +9,19 @@ error: the variable `_index` is used as a loop counter. Consider using `for (_in 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 | -21 | for _v in &vec { +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 | -60 | for ch in text.chars() { +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 | -71 | for ch in text.chars() { +LL | for ch in text.chars() { | ^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index 1a11dbc169b..1072d9bd0d2 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,7 +1,7 @@ error: use of `write!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:24:9 | -24 | write!(std::io::stdout(), "test").unwrap(); +LL | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")` | = note: `-D clippy::explicit-write` implied by `-D warnings` @@ -9,43 +9,43 @@ error: use of `write!(stdout(), ...).unwrap()` error: use of `write!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:25:9 | -25 | write!(std::io::stderr(), "test").unwrap(); +LL | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:26:9 | -26 | writeln!(std::io::stdout(), "test").unwrap(); +LL | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test")` error: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:27:9 | -27 | writeln!(std::io::stderr(), "test").unwrap(); +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 | -28 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); +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 | -29 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); +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 | -32 | writeln!(std::io::stdout(), "test/ntest").unwrap(); +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 | -33 | writeln!(std::io::stderr(), "test/ntest").unwrap(); +LL | writeln!(std::io::stderr(), "test/ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test/ntest")` error: aborting due to 8 previous errors diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 8af5933a9f8..55efac7951a 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,91 +1,91 @@ error: consider implementing `TryFrom` instead --> $DIR/fallible_impl_from.rs:14:1 | -14 | / impl From<String> for Foo { -15 | | fn from(s: String) -> Self { -16 | | Foo(s.parse().unwrap()) -17 | | } -18 | | } +LL | / impl From<String> for Foo { +LL | | fn from(s: String) -> Self { +LL | | Foo(s.parse().unwrap()) +LL | | } +LL | | } | |_^ | note: lint level defined here --> $DIR/fallible_impl_from.rs:10:9 | -10 | #![deny(clippy::fallible_impl_from)] +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 | -16 | Foo(s.parse().unwrap()) +LL | Foo(s.parse().unwrap()) | ^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead --> $DIR/fallible_impl_from.rs:35:1 | -35 | / impl From<usize> for Invalid { -36 | | fn from(i: usize) -> Invalid { -37 | | if i != 42 { -38 | | panic!(); +LL | / impl From<usize> for Invalid { +LL | | fn from(i: usize) -> Invalid { +LL | | if i != 42 { +LL | | panic!(); ... | -41 | | } -42 | | } +LL | | } +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 | -38 | panic!(); +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 | -44 | / impl From<Option<String>> for Invalid { -45 | | fn from(s: Option<String>) -> Invalid { -46 | | let s = s.unwrap(); -47 | | if !s.is_empty() { +LL | / impl From<Option<String>> for Invalid { +LL | | fn from(s: Option<String>) -> Invalid { +LL | | let s = s.unwrap(); +LL | | if !s.is_empty() { ... | -53 | | } -54 | | } +LL | | } +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 | -46 | let s = s.unwrap(); +LL | let s = s.unwrap(); | ^^^^^^^^^^ -47 | if !s.is_empty() { -48 | panic!(42); +LL | if !s.is_empty() { +LL | panic!(42); | ^^^^^^^^^^^ -49 | } else if s.parse::<u32>().unwrap() != 42 { +LL | } else if s.parse::<u32>().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -50 | panic!("{:?}", s); +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 | -62 | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid { -63 | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid { -64 | | if s.parse::<u32>().ok().unwrap() != 42 { -65 | | panic!("{:?}", s); +LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid { +LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid { +LL | | if s.parse::<u32>().ok().unwrap() != 42 { +LL | | panic!("{:?}", s); ... | -68 | | } -69 | | } +LL | | } +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 | -64 | if s.parse::<u32>().ok().unwrap() != 42 { +LL | if s.parse::<u32>().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -65 | panic!("{:?}", s); +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) diff --git a/tests/ui/filter_methods.stderr b/tests/ui/filter_methods.stderr index 8fde78ca5a7..c10d673148a 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -1,7 +1,7 @@ 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 | -14 | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect(); +LL | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::filter-map` implied by `-D warnings` @@ -9,31 +9,31 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expre 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 | -16 | let _: Vec<_> = vec![5_i8; 6] +LL | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -17 | | .into_iter() -18 | | .filter(|&x| x == 0) -19 | | .flat_map(|x| x.checked_mul(2)) +LL | | .into_iter() +LL | | .filter(|&x| x == 0) +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 | -22 | let _: Vec<_> = vec![5_i8; 6] +LL | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -23 | | .into_iter() -24 | | .filter_map(|x| x.checked_mul(2)) -25 | | .flat_map(|x| x.checked_mul(2)) +LL | | .into_iter() +LL | | .filter_map(|x| x.checked_mul(2)) +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 | -28 | let _: Vec<_> = vec![5_i8; 6] +LL | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -29 | | .into_iter() -30 | | .filter_map(|x| x.checked_mul(2)) -31 | | .map(|x| x.checked_mul(2)) +LL | | .into_iter() +LL | | .filter_map(|x| x.checked_mul(2)) +LL | | .map(|x| x.checked_mul(2)) | |__________________________________^ error: aborting due to 4 previous errors diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 3acd71eb99b..bdbbccee714 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,38 +1,38 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:69:5 | -69 | ONE as f64 != 2.0; +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 | -69 | ONE as f64 != 2.0; +LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:74:5 | -74 | x == 1.0; +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 | -74 | x == 1.0; +LL | x == 1.0; | ^^^^^^^^ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:77:5 | -77 | twice(x) != twice(ONE as f64); +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 | -77 | twice(x) != twice(ONE as f64); +LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index d9b1d268505..2b434f31814 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -1,86 +1,86 @@ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:27:5 | -27 | 1f32 == ONE; +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 | -27 | 1f32 == ONE; +LL | 1f32 == ONE; | ^^^^^^^^^^^ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:28:5 | -28 | TWO == ONE; +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 | -28 | TWO == ONE; +LL | TWO == ONE; | ^^^^^^^^^^ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:29:5 | -29 | TWO != ONE; +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 | -29 | TWO != ONE; +LL | TWO != ONE; | ^^^^^^^^^^ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:30:5 | -30 | ONE + ONE == TWO; +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 | -30 | ONE + ONE == TWO; +LL | ONE + ONE == TWO; | ^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:31:5 | -31 | 1 as f32 == ONE; +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 | -31 | 1 as f32 == ONE; +LL | 1 as f32 == ONE; | ^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:34:5 | -34 | v == ONE; +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 | -34 | v == ONE; +LL | v == ONE; | ^^^^^^^^ error: strict comparison of f32 or f64 constant --> $DIR/float_cmp_const.rs:35:5 | -35 | v != ONE; +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 | -35 | v != ONE; +LL | v != ONE; | ^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/fn_to_numeric_cast.stderr b/tests/ui/fn_to_numeric_cast.stderr index 27eeb909154..16605fd344a 100644 --- a/tests/ui/fn_to_numeric_cast.stderr +++ b/tests/ui/fn_to_numeric_cast.stderr @@ -1,7 +1,7 @@ error: casting function pointer `foo` to `i8`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:19:13 | -19 | let _ = foo as i8; +LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` | = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings` @@ -9,19 +9,19 @@ error: casting function pointer `foo` to `i8`, which truncates the value error: casting function pointer `foo` to `i16`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:20:13 | -20 | let _ = foo as i16; +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 | -21 | let _ = foo as i32; +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 | -22 | let _ = foo as i64; +LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` | = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings` @@ -29,115 +29,115 @@ error: casting function pointer `foo` to `i64` error: casting function pointer `foo` to `i128` --> $DIR/fn_to_numeric_cast.rs:23:13 | -23 | let _ = foo as i128; +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 | -24 | let _ = foo as isize; +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 | -26 | let _ = foo as u8; +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 | -27 | let _ = foo as u16; +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 | -28 | let _ = foo as u32; +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 | -29 | let _ = foo as u64; +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 | -30 | let _ = foo as u128; +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 | -43 | let _ = abc as i8; +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 | -44 | let _ = abc as i16; +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 | -45 | let _ = abc as i32; +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 | -46 | let _ = abc as i64; +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 | -47 | let _ = abc as i128; +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 | -48 | let _ = abc as isize; +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 | -50 | let _ = abc as u8; +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 | -51 | let _ = abc as u16; +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 | -52 | let _ = abc as u32; +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 | -53 | let _ = abc as u64; +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 | -54 | let _ = abc as u128; +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 | -61 | f as i32 +LL | f as i32 | ^^^^^^^^ help: try: `f as usize` error: aborting due to 23 previous errors diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 640cee1bc2f..937bef9f8a6 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -1,421 +1,421 @@ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:50:14 | -50 | for i in 0..vec.len() { +LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | -50 | for <item> in &vec { +LL | for <item> in &vec { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:59:14 | -59 | for i in 0..vec.len() { +LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -59 | for <item> in &vec { +LL | for <item> in &vec { | ^^^^^^ ^^^^ error: the loop variable `j` is only used to index `STATIC`. --> $DIR/for_loop.rs:64:14 | -64 | for j in 0..4 { +LL | for j in 0..4 { | ^^^^ help: consider using an iterator | -64 | for <item> in &STATIC { +LL | for <item> in &STATIC { | ^^^^^^ ^^^^^^^ error: the loop variable `j` is only used to index `CONST`. --> $DIR/for_loop.rs:68:14 | -68 | for j in 0..4 { +LL | for j in 0..4 { | ^^^^ help: consider using an iterator | -68 | for <item> in &CONST { +LL | for <item> in &CONST { | ^^^^^^ ^^^^^^ error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:72:14 | -72 | for i in 0..vec.len() { +LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -72 | for (i, <item>) in vec.iter().enumerate() { +LL | for (i, <item>) in vec.iter().enumerate() { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec2`. --> $DIR/for_loop.rs:80:14 | -80 | for i in 0..vec.len() { +LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -80 | for <item> in vec2.iter().take(vec.len()) { +LL | for <item> in vec2.iter().take(vec.len()) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:84:14 | -84 | for i in 5..vec.len() { +LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -84 | for <item> in vec.iter().skip(5) { +LL | for <item> in vec.iter().skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:88:14 | -88 | for i in 0..MAX_LEN { +LL | for i in 0..MAX_LEN { | ^^^^^^^^^^ help: consider using an iterator | -88 | for <item> in vec.iter().take(MAX_LEN) { +LL | for <item> in vec.iter().take(MAX_LEN) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:92:14 | -92 | for i in 0..=MAX_LEN { +LL | for i in 0..=MAX_LEN { | ^^^^^^^^^^^ help: consider using an iterator | -92 | for <item> in vec.iter().take(MAX_LEN + 1) { +LL | for <item> in vec.iter().take(MAX_LEN + 1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:96:14 | -96 | for i in 5..10 { +LL | for i in 5..10 { | ^^^^^ help: consider using an iterator | -96 | for <item> in vec.iter().take(10).skip(5) { +LL | for <item> in vec.iter().take(10).skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:100:14 - | -100 | for i in 5..=10 { - | ^^^^^^ + --> $DIR/for_loop.rs:100:14 + | +LL | for i in 5..=10 { + | ^^^^^^ help: consider using an iterator - | -100 | for <item> in vec.iter().take(10 + 1).skip(5) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +LL | for <item> in vec.iter().take(10 + 1).skip(5) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:104:14 - | -104 | for i in 5..vec.len() { - | ^^^^^^^^^^^^ + --> $DIR/for_loop.rs:104:14 + | +LL | for i in 5..vec.len() { + | ^^^^^^^^^^^^ help: consider using an iterator - | -104 | for (i, <item>) in vec.iter().enumerate().skip(5) { - | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +LL | for (i, <item>) in vec.iter().enumerate().skip(5) { + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:108:14 - | -108 | for i in 5..10 { - | ^^^^^ + --> $DIR/for_loop.rs:108:14 + | +LL | for i in 5..10 { + | ^^^^^ help: consider using an iterator - | -108 | for (i, <item>) in vec.iter().enumerate().take(10).skip(5) { - | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +LL | for (i, <item>) 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 - | -112 | for i in 10..0 { - | ^^^^^ - | - = note: `-D clippy::reverse-range-loop` implied by `-D warnings` + --> $DIR/for_loop.rs:112:14 + | +LL | for i in 10..0 { + | ^^^^^ + | + = note: `-D clippy::reverse-range-loop` implied by `-D warnings` help: consider using the following if you are attempting to iterate over this range in reverse - | -112 | for i in (0..10).rev() { - | ^^^^^^^^^^^^^ + | +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 - | -116 | for i in 10..=0 { - | ^^^^^^ + --> $DIR/for_loop.rs:116:14 + | +LL | for i in 10..=0 { + | ^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse - | -116 | for i in (0...10).rev() { - | ^^^^^^^^^^^^^^ + | +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 - | -120 | for i in MAX_LEN..0 { - | ^^^^^^^^^^ + --> $DIR/for_loop.rs:120:14 + | +LL | for i in MAX_LEN..0 { + | ^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse - | -120 | for i in (0..MAX_LEN).rev() { - | ^^^^^^^^^^^^^^^^^^ + | +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 - | -124 | for i in 5..5 { - | ^^^^ + --> $DIR/for_loop.rs:124: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 - | -149 | for i in 10..5 + 4 { - | ^^^^^^^^^ + --> $DIR/for_loop.rs:149:14 + | +LL | for i in 10..5 + 4 { + | ^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse - | -149 | for i in (5 + 4..10).rev() { - | ^^^^^^^^^^^^^^^^^ + | +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 - | -153 | for i in (5 + 2)..(3 - 1) { - | ^^^^^^^^^^^^^^^^ + --> $DIR/for_loop.rs:153:14 + | +LL | for i in (5 + 2)..(3 - 1) { + | ^^^^^^^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse - | -153 | for i in ((3 - 1)..(5 + 2)).rev() { - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +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 - | -157 | for i in (5 + 2)..(8 - 1) { - | ^^^^^^^^^^^^^^^^ + --> $DIR/for_loop.rs:157: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 - | -179 | for _v in vec.iter() {} - | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` - | - = note: `-D clippy::explicit-iter-loop` implied by `-D warnings` + --> $DIR/for_loop.rs:179:15 + | +LL | for _v in vec.iter() {} + | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` + | + = 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 - | -181 | for _v in vec.iter_mut() {} - | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` + --> $DIR/for_loop.rs:181: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 - | -184 | for _v in out_vec.into_iter() {} - | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` - | - = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` + --> $DIR/for_loop.rs:184:15 + | +LL | for _v in out_vec.into_iter() {} + | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` + | + = 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 - | -187 | for _v in array.into_iter() {} - | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array` + --> $DIR/for_loop.rs:187: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 - | -192 | for _v in [1, 2, 3].iter() {} - | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` + --> $DIR/for_loop.rs:192: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 - | -196 | for _v in [0; 32].iter() {} - | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` + --> $DIR/for_loop.rs:196: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 - | -201 | for _v in ll.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&ll` + --> $DIR/for_loop.rs:201: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 - | -204 | for _v in vd.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&vd` + --> $DIR/for_loop.rs:204: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 - | -207 | for _v in bh.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&bh` + --> $DIR/for_loop.rs:207: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 - | -210 | for _v in hm.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&hm` + --> $DIR/for_loop.rs:210: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 - | -213 | for _v in bt.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&bt` + --> $DIR/for_loop.rs:213: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 - | -216 | for _v in hs.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&hs` + --> $DIR/for_loop.rs:216: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 - | -219 | for _v in bs.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&bs` + --> $DIR/for_loop.rs:219: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 - | -221 | for _v in vec.iter().next() {} - | ^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::iter-next-loop` implied by `-D warnings` + --> $DIR/for_loop.rs:221:15 + | +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 - | -228 | vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::unused-collect` implied by `-D warnings` + --> $DIR/for_loop.rs:228:5 + | +LL | vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::unused-collect` implied by `-D warnings` error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:337:19 - | -337 | for (_, v) in &m { - | ^^ - | - = note: `-D clippy::for-kv-map` implied by `-D warnings` + --> $DIR/for_loop.rs:337:19 + | +LL | for (_, v) in &m { + | ^^ + | + = note: `-D clippy::for-kv-map` implied by `-D warnings` help: use the corresponding method - | -337 | for v in m.values() { - | ^ ^^^^^^^^^^ + | +LL | for v in m.values() { + | ^ ^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:342:19 - | -342 | for (_, v) in &*m { - | ^^^ + --> $DIR/for_loop.rs:342:19 + | +LL | for (_, v) in &*m { + | ^^^ help: use the corresponding method - | -342 | for v in (*m).values() { - | ^ ^^^^^^^^^^^^^ + | +LL | for v in (*m).values() { + | ^ ^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:350:19 - | -350 | for (_, v) in &mut m { - | ^^^^^^ + --> $DIR/for_loop.rs:350:19 + | +LL | for (_, v) in &mut m { + | ^^^^^^ help: use the corresponding method - | -350 | for v in m.values_mut() { - | ^ ^^^^^^^^^^^^^^ + | +LL | for v in m.values_mut() { + | ^ ^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:355:19 - | -355 | for (_, v) in &mut *m { - | ^^^^^^^ + --> $DIR/for_loop.rs:355:19 + | +LL | for (_, v) in &mut *m { + | ^^^^^^^ help: use the corresponding method - | -355 | for v in (*m).values_mut() { - | ^ ^^^^^^^^^^^^^^^^^ + | +LL | for v in (*m).values_mut() { + | ^ ^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's keys - --> $DIR/for_loop.rs:361:24 - | -361 | for (k, _value) in rm { - | ^^ + --> $DIR/for_loop.rs:361:24 + | +LL | for (k, _value) in rm { + | ^^ help: use the corresponding method - | -361 | for k in rm.keys() { - | ^ ^^^^^^^^^ + | +LL | for k in rm.keys() { + | ^ ^^^^^^^^^ error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:414:14 - | -414 | for i in 0..src.len() { - | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` - | - = note: `-D clippy::manual-memcpy` implied by `-D warnings` + --> $DIR/for_loop.rs:414:14 + | +LL | for i in 0..src.len() { + | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` + | + = note: `-D clippy::manual-memcpy` implied by `-D warnings` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:419:14 - | -419 | for i in 0..src.len() { - | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[10..(src.len() + 10)].clone_from_slice(&src[..])` + --> $DIR/for_loop.rs:419: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:424:14 - | -424 | for i in 0..src.len() { - | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[10..])` + --> $DIR/for_loop.rs:424: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:429:14 - | -429 | 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)])` + --> $DIR/for_loop.rs:429: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:434:14 - | -434 | for i in 0..dst.len() { - | ^^^^^^^^^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..dst.len()])` + --> $DIR/for_loop.rs:434: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:447:14 - | -447 | for i in 10..256 { - | ^^^^^^^ + --> $DIR/for_loop.rs:447:14 + | +LL | for i in 10..256 { + | ^^^^^^^ help: try replacing the loop by - | -447 | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)]) -448 | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) { - | + | +LL | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)]) +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:459:14 - | -459 | 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)])` + --> $DIR/for_loop.rs:459: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:472:14 - | -472 | for i in 0..src_vec.len() { - | ^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst_vec[..src_vec.len()].clone_from_slice(&src_vec[..])` + --> $DIR/for_loop.rs:472: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:501:14 - | -501 | 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)])` + --> $DIR/for_loop.rs:501: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:505:14 - | -505 | for i in from..from + 3 { - | ^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + 3].clone_from_slice(&src[0..(from + 3 - from)])` + --> $DIR/for_loop.rs:505: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:512:14 - | -512 | for i in 0..src.len() { - | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` + --> $DIR/for_loop.rs:512:14 + | +LL | for i in 0..src.len() { + | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` error: aborting due to 51 previous errors diff --git a/tests/ui/for_loop_over_option_result.stderr b/tests/ui/for_loop_over_option_result.stderr index 13ad5fff846..f8a4212b253 100644 --- a/tests/ui/for_loop_over_option_result.stderr +++ b/tests/ui/for_loop_over_option_result.stderr @@ -1,7 +1,7 @@ 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 | -20 | for x in option { +LL | for x in option { | ^^^^^^ | = note: `-D clippy::for-loop-over-option` implied by `-D warnings` @@ -10,7 +10,7 @@ error: for loop over `option`, which is an `Option`. This is more readably writt 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 | -25 | for x in result { +LL | for x in result { | ^^^^^^ | = note: `-D clippy::for-loop-over-result` implied by `-D warnings` @@ -19,7 +19,7 @@ error: for loop over `result`, which is a `Result`. This is more readably writte 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 | -29 | for x in option.ok_or("x not found") { +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")` @@ -27,7 +27,7 @@ error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is 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 | -35 | for x in v.iter().next() { +LL | for x in v.iter().next() { | ^^^^^^^^^^^^^^^ | = note: #[deny(clippy::iter_next_loop)] on by default @@ -35,7 +35,7 @@ error: you are iterating over `Iterator::next()` which is an Option; this will c 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 | -40 | for x in v.iter().next().and(Some(0)) { +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))` @@ -43,7 +43,7 @@ error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This 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 | -44 | for x in v.iter().next().ok_or("x not found") { +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")` @@ -51,10 +51,10 @@ error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result` error: this loop never actually loops --> $DIR/for_loop_over_option_result.rs:56:5 | -56 | / while let Some(x) = option { -57 | | println!("{}", x); -58 | | break; -59 | | } +LL | / while let Some(x) = option { +LL | | println!("{}", x); +LL | | break; +LL | | } | |_____^ | = note: #[deny(clippy::never_loop)] on by default @@ -62,10 +62,10 @@ error: this loop never actually loops error: this loop never actually loops --> $DIR/for_loop_over_option_result.rs:62:5 | -62 | / while let Ok(x) = result { -63 | | println!("{}", x); -64 | | break; -65 | | } +LL | / while let Ok(x) = result { +LL | | println!("{}", x); +LL | | break; +LL | | } | |_____^ error: aborting due to 8 previous errors diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index 62933f31e18..871fc8fba3e 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -1,7 +1,7 @@ error: useless use of `format!` --> $DIR/format.rs:21:5 | -21 | format!("foo"); +LL | format!("foo"); | ^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` | = note: `-D clippy::useless-format` implied by `-D warnings` @@ -9,7 +9,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:23:5 | -23 | format!("{}", "foo"); +LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".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) @@ -17,7 +17,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:27:5 | -27 | format!("{:+}", "foo"); // warn when the format makes no difference +LL | format!("{:+}", "foo"); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".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) @@ -25,7 +25,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:28:5 | -28 | format!("{:<}", "foo"); // warn when the format makes no difference +LL | format!("{:<}", "foo"); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".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) @@ -33,7 +33,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:33:5 | -33 | format!("{}", arg); +LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.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) @@ -41,7 +41,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:37:5 | -37 | format!("{:+}", arg); // warn when the format makes no difference +LL | format!("{:+}", arg); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.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) @@ -49,7 +49,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:38:5 | -38 | format!("{:<}", arg); // warn when the format makes no difference +LL | format!("{:<}", arg); // warn when the format makes no difference | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.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) @@ -57,7 +57,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:65:5 | -65 | format!("{}", 42.to_string()); +LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `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) @@ -65,7 +65,7 @@ error: useless use of `format!` error: useless use of `format!` --> $DIR/format.rs:67:5 | -67 | format!("{}", x.display().to_string()); +LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `x.display().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) diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 3bea98acf2f..b74f778b129 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -16,7 +16,11 @@ fn foo() -> bool { true } fn main() { - // weird `else if` formatting: + // weird `else` formatting: + if foo() { + } { + } + if foo() { } if foo() { } @@ -43,6 +47,17 @@ fn main() { if foo() { } else + { + } + + if foo() { + } + else + { + } + + if foo() { + } else if foo() { // the span of the above error should continue here } @@ -55,6 +70,20 @@ fn main() { // those are ok: if foo() { } + { + } + + if foo() { + } else { + } + + if foo() { + } + else { + } + + if foo() { + } if foo() { } diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index 7399a0d4549..061540b9aa5 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,90 +1,119 @@ -error: this looks like an `else if` but the `else` is missing +error: this looks like an `else {..}` but the `else` is missing --> $DIR/formatting.rs:21:6 | -21 | } if foo() { +LL | } { | ^ | = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` + = 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 + | +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:28:10 + --> $DIR/formatting.rs:32:10 | -28 | } if foo() { +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:36:10 + --> $DIR/formatting.rs:40:10 | -36 | } if foo() { +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 + | +LL | } else + | ______^ +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 + | +LL | } + | ______^ +LL | | else +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:45:6 + --> $DIR/formatting.rs:60:6 | -45 | } else +LL | } else | ______^ -46 | | if foo() { // the span of the above error should continue here +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:50:6 + --> $DIR/formatting.rs:65:6 | -50 | } +LL | } | ______^ -51 | | else -52 | | if foo() { // the span of the above error should continue here +LL | | else +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:77:6 + --> $DIR/formatting.rs:106:6 | -77 | a =- 35; +LL | a =- 35; | ^^^^ | = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` = 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:78:6 + --> $DIR/formatting.rs:107:6 | -78 | a =* &191; +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:81:6 + --> $DIR/formatting.rs:110:6 | -81 | b =! false; +LL | b =! false; | ^^^^ | = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:90:19 + --> $DIR/formatting.rs:119:19 | -90 | -1, -2, -3 // <= no comma here +LL | -1, -2, -3 // <= no comma here | ^ | = note: `-D clippy::possible-missing-comma` implied by `-D warnings` = 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:94:19 + --> $DIR/formatting.rs:123:19 | -94 | -1, -2, -3 // <= no comma here +LL | -1, -2, -3 // <= no comma here | ^ | = note: to remove this lint, add a comma or write the expr in a single line -error: aborting due to 10 previous errors +error: aborting due to 13 previous errors diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 206d04d6a39..b23d09309bb 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -1,7 +1,7 @@ error: this function has too many arguments (8/7) --> $DIR/functions.rs:17:1 | -17 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} +LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::too-many-arguments` implied by `-D warnings` @@ -9,19 +9,19 @@ error: this function has too many arguments (8/7) error: this function has too many arguments (8/7) --> $DIR/functions.rs:34:5 | -34 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); +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 | -43 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} +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 | -52 | println!("{}", unsafe { *p }); +LL | println!("{}", unsafe { *p }); | ^ | = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` @@ -29,49 +29,49 @@ error: this public function dereferences a raw pointer but is not marked `unsafe error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:53:35 | -53 | println!("{:?}", unsafe { p.as_ref() }); +LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:54:33 | -54 | unsafe { std::ptr::read(p) }; +LL | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:65:30 | -65 | println!("{}", unsafe { *p }); +LL | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:66:31 | -66 | println!("{:?}", unsafe { p.as_ref() }); +LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:67:29 | -67 | unsafe { std::ptr::read(p) }; +LL | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:76:34 | -76 | println!("{}", unsafe { *p }); +LL | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:77:35 | -77 | println!("{:?}", unsafe { p.as_ref() }); +LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:78:33 | -78 | unsafe { std::ptr::read(p) }; +LL | unsafe { std::ptr::read(p) }; | ^ error: aborting due to 12 previous errors diff --git a/tests/ui/fxhash.stderr b/tests/ui/fxhash.stderr index a1e50401b46..14fc4a8090b 100644 --- a/tests/ui/fxhash.stderr +++ b/tests/ui/fxhash.stderr @@ -1,7 +1,7 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy --> $DIR/fxhash.rs:16:24 | -16 | use std::collections::{HashMap, HashSet}; +LL | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashMap` | = note: `-D clippy::default-hash-types` implied by `-D warnings` @@ -9,31 +9,31 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't nee error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy --> $DIR/fxhash.rs:16:33 | -16 | use std::collections::{HashMap, HashSet}; +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 | -19 | let _map: HashMap<String, String> = HashMap::default(); +LL | let _map: HashMap<String, String> = 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 | -19 | let _map: HashMap<String, String> = HashMap::default(); +LL | let _map: HashMap<String, String> = 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 | -20 | let _set: HashSet<String> = HashSet::default(); +LL | let _set: HashSet<String> = 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 | -20 | let _set: HashSet<String> = HashSet::default(); +LL | let _set: HashSet<String> = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: aborting due to 6 previous errors diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index 8b07e740a9a..1f45c26048a 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -1,7 +1,7 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:41:17 | -41 | let _ = boxed_slice.get(1).unwrap(); +LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]` | = note: `-D clippy::get-unwrap` implied by `-D warnings` @@ -9,67 +9,67 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more co error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:42:17 | -42 | let _ = some_slice.get(0).unwrap(); +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:43:17 | -43 | let _ = some_vec.get(0).unwrap(); +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:44:17 | -44 | let _ = some_vecdeque.get(0).unwrap(); +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:45:17 | -45 | let _ = some_hashmap.get(&1).unwrap(); +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:46:17 | -46 | let _ = some_btreemap.get(&1).unwrap(); +LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:52:10 | -52 | *boxed_slice.get_mut(0).unwrap() = 1; +LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut boxed_slice[0]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:53:10 | -53 | *some_slice.get_mut(0).unwrap() = 1; +LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_slice[0]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:54:10 | -54 | *some_vec.get_mut(0).unwrap() = 1; +LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vec[0]` error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:55:10 | -55 | *some_vecdeque.get_mut(0).unwrap() = 1; +LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vecdeque[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:64:17 | -64 | let _ = some_vec.get(0..1).unwrap().to_vec(); +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:65:17 | -65 | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); +LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` error: aborting due to 12 previous errors diff --git a/tests/ui/ice-2636.stderr b/tests/ui/ice-2636.stderr index a0806af5da9..a6b150f9b90 100644 --- a/tests/ui/ice-2636.stderr +++ b/tests/ui/ice-2636.stderr @@ -1,13 +1,13 @@ error: you don't need to add `&` to both the expression and the patterns --> $DIR/ice-2636.rs:21:9 | -21 | / match $foo { -22 | | $ ( & $t => $ord, -23 | | )* -24 | | }; +LL | / match $foo { +LL | | $ ( & $t => $ord, +LL | | )* +LL | | }; | |_________^ ... -30 | test_hash!(&a, A => 0, B => 1, C => 2); +LL | test_hash!(&a, A => 0, B => 1, C => 2); | --------------------------------------- in this macro invocation | = note: `-D clippy::match-ref-pats` implied by `-D warnings` diff --git a/tests/ui/identity_conversion.stderr b/tests/ui/identity_conversion.stderr index aab6bf7f218..4b0b958e285 100644 --- a/tests/ui/identity_conversion.stderr +++ b/tests/ui/identity_conversion.stderr @@ -1,67 +1,67 @@ error: identical conversion --> $DIR/identity_conversion.rs:13:13 | -13 | let _ = T::from(val); +LL | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: lint level defined here --> $DIR/identity_conversion.rs:10:9 | -10 | #![deny(clippy::identity_conversion)] +LL | #![deny(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identical conversion --> $DIR/identity_conversion.rs:14:5 | -14 | val.into() +LL | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: identical conversion --> $DIR/identity_conversion.rs:26:22 | -26 | let _: i32 = 0i32.into(); +LL | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: identical conversion --> $DIR/identity_conversion.rs:47:21 | -47 | let _: String = "foo".to_string().into(); +LL | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: identical conversion --> $DIR/identity_conversion.rs:48:21 | -48 | let _: String = From::from("foo".to_string()); +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 | -49 | let _ = String::from("foo".to_string()); +LL | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` error: identical conversion --> $DIR/identity_conversion.rs:50:13 | -50 | let _ = String::from(format!("A: {:04}", 123)); +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 | -51 | let _ = "".lines().into_iter(); +LL | let _ = "".lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` error: identical conversion --> $DIR/identity_conversion.rs:52:13 | -52 | let _ = vec![1, 2, 3].into_iter().into_iter(); +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 | -53 | let _: String = format!("Hello {}", "world").into(); +LL | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` error: aborting due to 10 previous errors diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 19846b5ecdf..8b42cfbf1ce 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,7 +1,7 @@ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:25:5 | -25 | x + 0; +LL | x + 0; | ^^^^^ | = note: `-D clippy::identity-op` implied by `-D warnings` @@ -9,43 +9,43 @@ error: the operation is ineffective. Consider reducing it to `x` error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:26:5 | -26 | x + (1 - 1); +LL | x + (1 - 1); | ^^^^^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:28:5 | -28 | 0 + x; +LL | 0 + x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:31:5 | -31 | x | (0); +LL | x | (0); | ^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:34:5 | -34 | x * 1; +LL | x * 1; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:35:5 | -35 | 1 * x; +LL | 1 * x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:41:5 | -41 | -1 & x; +LL | -1 & x; | ^^^^^^ error: the operation is ineffective. Consider reducing it to `u` --> $DIR/identity_op.rs:44:5 | -44 | u & 255; +LL | u & 255; | ^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index 0393e49a2ee..acdf543cc75 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,11 +1,11 @@ error: Unnecessary boolean `not` operation --> $DIR/if_not_else.rs:18:5 | -18 | / if !bla() { -19 | | println!("Bugs"); -20 | | } else { -21 | | println!("Bunny"); -22 | | } +LL | / if !bla() { +LL | | println!("Bugs"); +LL | | } else { +LL | | println!("Bunny"); +LL | | } | |_____^ | = note: `-D clippy::if-not-else` implied by `-D warnings` @@ -14,11 +14,11 @@ error: Unnecessary boolean `not` operation error: Unnecessary `!=` operation --> $DIR/if_not_else.rs:23:5 | -23 | / if 4 != 5 { -24 | | println!("Bugs"); -25 | | } else { -26 | | println!("Bunny"); -27 | | } +LL | / if 4 != 5 { +LL | | println!("Bugs"); +LL | | } else { +LL | | println!("Bunny"); +LL | | } | |_____^ | = help: change to `==` and swap the blocks of the if/else diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index adad754bffe..8bddd400f70 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,34 +1,34 @@ error: Multiple implementations of this structure --> $DIR/impl.rs:19:1 | -19 | / impl MyStruct { -20 | | fn second() {} -21 | | } +LL | / impl MyStruct { +LL | | fn second() {} +LL | | } | |_^ | = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` note: First implementation here --> $DIR/impl.rs:15:1 | -15 | / impl MyStruct { -16 | | fn first() {} -17 | | } +LL | / impl MyStruct { +LL | | fn first() {} +LL | | } | |_^ error: Multiple implementations of this structure --> $DIR/impl.rs:33:5 | -33 | / impl super::MyStruct { -34 | | fn third() {} -35 | | } +LL | / impl super::MyStruct { +LL | | fn third() {} +LL | | } | |_____^ | note: First implementation here --> $DIR/impl.rs:15:1 | -15 | / impl MyStruct { -16 | | fn first() {} -17 | | } +LL | / impl MyStruct { +LL | | fn first() {} +LL | | } | |_^ error: aborting due to 2 previous errors diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index 35306e77aec..0c61dbc4c64 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -1,136 +1,136 @@ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:20:35 | -20 | impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> { +LL | impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> { | ^^^^^^^^^^^^^ | = note: `-D clippy::implicit-hasher` implied by `-D warnings` help: consider adding a type parameter | -20 | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashMap<K, V, S> { +LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashMap<K, V, S> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -26 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:29:36 | -29 | impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) { +LL | impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) { | ^^^^^^^^^^^^^ help: consider adding a type parameter | -29 | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for (HashMap<K, V, S>,) { +LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for (HashMap<K, V, S>,) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -31 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) +LL | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:34:19 | -34 | impl Foo<i16> for HashMap<String, String> { +LL | impl Foo<i16> for HashMap<String, String> { | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | -34 | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashMap<String, String, S> { +LL | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashMap<String, String, S> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -36 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:51:32 | -51 | impl<T: Hash + Eq> Foo<i8> for HashSet<T> { +LL | impl<T: Hash + Eq> Foo<i8> for HashSet<T> { | ^^^^^^^^^^ help: consider adding a type parameter | -51 | impl<T: Hash + Eq, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashSet<T, S> { +LL | impl<T: Hash + Eq, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashSet<T, S> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ help: ...and use generic constructor | -53 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) +LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:56:19 | -56 | impl Foo<i16> for HashSet<String> { +LL | impl Foo<i16> for HashSet<String> { | ^^^^^^^^^^^^^^^ help: consider adding a type parameter | -56 | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashSet<String, S> { +LL | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashSet<String, S> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -58 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) +LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:73:23 | -73 | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} +LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} | ^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | -73 | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {} +LL | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:73:53 | -73 | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} +LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} | ^^^^^^^^^^^^ help: consider adding a type parameter | -73 | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {} +LL | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:77:43 | -77 | impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> { +LL | impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> { | ^^^^^^^^^^^^^ ... -89 | gen!(impl); +LL | gen!(impl); | ----------- in this macro invocation help: consider adding a type parameter | -77 | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<u8> for HashMap<K, V, S> { +LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<u8> for HashMap<K, V, S> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -79 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:85:33 | -85 | pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} +LL | pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} | ^^^^^^^^^^^^^^^^^ ... -90 | gen!(fn bar); +LL | gen!(fn bar); | ------------- in this macro invocation help: consider adding a type parameter | -85 | pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {} +LL | pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:85:63 | -85 | pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} +LL | pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {} | ^^^^^^^^^^^^ ... -90 | gen!(fn bar); +LL | gen!(fn bar); | ------------- in this macro invocation help: consider adding a type parameter | -85 | pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {} +LL | pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: aborting due to 10 previous errors diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs index 9fb30135231..46ead9bf0c5 100644 --- a/tests/ui/implicit_return.rs +++ b/tests/ui/implicit_return.rs @@ -56,8 +56,7 @@ fn test_loop_with_nests() -> bool { loop { if true { break true; - } - else { + } else { let _ = true; } } diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index b3562b67034..4c62a7d65c6 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -1,7 +1,7 @@ error: missing return statement --> $DIR/implicit_return.rs:17:5 | -17 | true +LL | true | ^^^^ help: add `return` as shown: `return true` | = note: `-D clippy::implicit-return` implied by `-D warnings` @@ -9,55 +9,55 @@ error: missing return statement error: missing return statement --> $DIR/implicit_return.rs:23:9 | -23 | true +LL | true | ^^^^ help: add `return` as shown: `return true` error: missing return statement --> $DIR/implicit_return.rs:25:9 | -25 | false +LL | false | ^^^^^ help: add `return` as shown: `return false` error: missing return statement --> $DIR/implicit_return.rs:33:17 | -33 | true => false, +LL | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing return statement --> $DIR/implicit_return.rs:34:20 | -34 | false => { true }, +LL | false => { true }, | ^^^^ help: add `return` as shown: `return true` error: missing return statement --> $DIR/implicit_return.rs:41:9 | -41 | break true; +LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement --> $DIR/implicit_return.rs:49:13 | -49 | break true; +LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement --> $DIR/implicit_return.rs:58:13 | -58 | break true; +LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:68:18 + --> $DIR/implicit_return.rs:67:18 | -68 | let _ = || { true }; +LL | let _ = || { true }; | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:69:16 + --> $DIR/implicit_return.rs:68:16 | -69 | let _ = || true; +LL | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: aborting due to 10 previous errors diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index 77e2f3bd41b..ba909b94480 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -1,7 +1,7 @@ error: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:22:16 | -22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` @@ -9,25 +9,25 @@ error: digits grouped inconsistently by underscores error: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:22:26 | -22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +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 | -22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +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 | -22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +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 | -22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +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: aborting due to 5 previous errors diff --git a/tests/ui/indexing_slicing.stderr b/tests/ui/indexing_slicing.stderr index c9a45bc4084..2e7bff3e0d5 100644 --- a/tests/ui/indexing_slicing.stderr +++ b/tests/ui/indexing_slicing.stderr @@ -1,7 +1,7 @@ error: index out of bounds: the len is 4 but the index is 4 --> $DIR/indexing_slicing.rs:25:5 | -25 | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +LL | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ | = note: #[deny(const_err)] on by default @@ -9,25 +9,25 @@ error: index out of bounds: the len is 4 but the index is 4 error: index out of bounds: the len is 4 but the index is 8 --> $DIR/indexing_slicing.rs:26:5 | -26 | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +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 | -56 | empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +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 | -87 | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +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 | -20 | x[index]; +LL | x[index]; | ^^^^^^^^ | = note: `-D clippy::indexing-slicing` implied by `-D warnings` @@ -36,7 +36,7 @@ error: indexing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:21:6 | -21 | &x[index..]; +LL | &x[index..]; | ^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead @@ -44,7 +44,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:22:6 | -22 | &x[..index]; +LL | &x[..index]; | ^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -52,7 +52,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:23:6 | -23 | &x[index_from..index_to]; +LL | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead @@ -60,7 +60,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:24:6 | -24 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -68,7 +68,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:24:6 | -24 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead @@ -76,7 +76,7 @@ error: slicing may panic. error: range is out of bounds --> $DIR/indexing_slicing.rs:27:11 | -27 | &x[..=4]; +LL | &x[..=4]; | ^ | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` @@ -84,13 +84,13 @@ error: range is out of bounds error: range is out of bounds --> $DIR/indexing_slicing.rs:28:11 | -28 | &x[1..5]; +LL | &x[1..5]; | ^ error: slicing may panic. --> $DIR/indexing_slicing.rs:29:6 | -29 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +LL | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -98,37 +98,37 @@ error: slicing may panic. error: range is out of bounds --> $DIR/indexing_slicing.rs:29:8 | -29 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +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 | -30 | &x[5..]; +LL | &x[5..]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:31:10 | -31 | &x[..5]; +LL | &x[..5]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:32:8 | -32 | &x[5..].iter().map(|x| 2 * x).collect::<Vec<i32>>(); +LL | &x[5..].iter().map(|x| 2 * x).collect::<Vec<i32>>(); | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:33:12 | -33 | &x[0..=4]; +LL | &x[0..=4]; | ^ error: slicing may panic. --> $DIR/indexing_slicing.rs:34:6 | -34 | &x[0..][..3]; +LL | &x[0..][..3]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -136,7 +136,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:35:6 | -35 | &x[1..][..5]; +LL | &x[1..][..5]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -144,7 +144,7 @@ error: slicing may panic. error: indexing may panic. --> $DIR/indexing_slicing.rs:48:5 | -48 | y[0]; +LL | y[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead @@ -152,7 +152,7 @@ error: indexing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:49:6 | -49 | &y[1..2]; +LL | &y[1..2]; | ^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead @@ -160,7 +160,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:50:6 | -50 | &y[0..=4]; +LL | &y[0..=4]; | ^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead @@ -168,7 +168,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:51:6 | -51 | &y[..=4]; +LL | &y[..=4]; | ^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -176,49 +176,49 @@ error: slicing may panic. error: range is out of bounds --> $DIR/indexing_slicing.rs:57:12 | -57 | &empty[1..5]; +LL | &empty[1..5]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:58:16 | -58 | &empty[0..=4]; +LL | &empty[0..=4]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:59:15 | -59 | &empty[..=4]; +LL | &empty[..=4]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:60:12 | -60 | &empty[1..]; +LL | &empty[1..]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:61:14 | -61 | &empty[..4]; +LL | &empty[..4]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:62:16 | -62 | &empty[0..=0]; +LL | &empty[0..=0]; | ^ error: range is out of bounds --> $DIR/indexing_slicing.rs:63:15 | -63 | &empty[..=0]; +LL | &empty[..=0]; | ^ error: indexing may panic. --> $DIR/indexing_slicing.rs:71:5 | -71 | v[0]; +LL | v[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead @@ -226,7 +226,7 @@ error: indexing may panic. error: indexing may panic. --> $DIR/indexing_slicing.rs:72:5 | -72 | v[10]; +LL | v[10]; | ^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead @@ -234,7 +234,7 @@ error: indexing may panic. error: indexing may panic. --> $DIR/indexing_slicing.rs:73:5 | -73 | v[1 << 3]; +LL | v[1 << 3]; | ^^^^^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead @@ -242,7 +242,7 @@ error: indexing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:74:6 | -74 | &v[10..100]; +LL | &v[10..100]; | ^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead @@ -250,7 +250,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:75:6 | -75 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -258,13 +258,13 @@ error: slicing may panic. error: range is out of bounds --> $DIR/indexing_slicing.rs:75:8 | -75 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^ error: slicing may panic. --> $DIR/indexing_slicing.rs:76:6 | -76 | &v[10..]; +LL | &v[10..]; | ^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead @@ -272,7 +272,7 @@ error: slicing may panic. error: slicing may panic. --> $DIR/indexing_slicing.rs:77:6 | -77 | &v[..100]; +LL | &v[..100]; | ^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead @@ -280,7 +280,7 @@ error: slicing may panic. error: indexing may panic. --> $DIR/indexing_slicing.rs:89:5 | -89 | v[N]; +LL | v[N]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead @@ -288,7 +288,7 @@ error: indexing may panic. error: indexing may panic. --> $DIR/indexing_slicing.rs:90:5 | -90 | v[M]; +LL | v[M]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead @@ -296,13 +296,13 @@ error: indexing may panic. error: range is out of bounds --> $DIR/indexing_slicing.rs:94:13 | -94 | &x[num..10]; // should trigger out of bounds error +LL | &x[num..10]; // should trigger out of bounds error | ^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:95:8 | -95 | &x[10..num]; // should trigger out of bounds error +LL | &x[10..num]; // should trigger out of bounds error | ^^ error: aborting due to 43 previous errors diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index 62588a2ad7c..976957d35d7 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,9 +1,9 @@ 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 | -25 | / let data = match wrapper { -26 | | SingleVariantEnum::Variant(i) => i, -27 | | }; +LL | / let data = match wrapper { +LL | | SingleVariantEnum::Variant(i) => i, +LL | | }; | |______^ help: try this: `let SingleVariantEnum::Variant(data) = wrapper;` | = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` @@ -11,17 +11,17 @@ error: you seem to be trying to use match to destructure a single infallible pat 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 | -46 | / let data = match wrapper { -47 | | TupleStruct(i) => i, -48 | | }; +LL | / let data = match wrapper { +LL | | TupleStruct(i) => i, +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 | -67 | / let data = match wrapper { -68 | | Ok(i) => i, -69 | | }; +LL | / let data = match wrapper { +LL | | Ok(i) => i, +LL | | }; | |______^ help: try this: `let Ok(data) = wrapper;` error: aborting due to 3 previous errors diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index 2c3b05aaff3..c64b3918db4 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -1,7 +1,7 @@ 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 | -19 | repeat(0_u8).collect::<Vec<_>>(); // infinite iter +LL | repeat(0_u8).collect::<Vec<_>>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-collect` implied by `-D warnings` @@ -9,100 +9,100 @@ error: you are collect()ing an iterator and throwing away the result. Consider u error: infinite iteration detected --> $DIR/infinite_iter.rs:19:5 | -19 | repeat(0_u8).collect::<Vec<_>>(); // infinite iter +LL | repeat(0_u8).collect::<Vec<_>>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/infinite_iter.rs:17:8 | -17 | #[deny(clippy::infinite_iter)] +LL | #[deny(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected --> $DIR/infinite_iter.rs:20:5 | -20 | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter +LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected --> $DIR/infinite_iter.rs:21:5 | -21 | (0..8_u64).chain(0..).max(); // infinite iter +LL | (0..8_u64).chain(0..).max(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected --> $DIR/infinite_iter.rs:26:5 | -26 | / (0..8_u32) -27 | | .rev() -28 | | .cycle() -29 | | .map(|x| x + 1_u32) -30 | | .for_each(|x| println!("{}", x)); // infinite iter +LL | / (0..8_u32) +LL | | .rev() +LL | | .cycle() +LL | | .map(|x| x + 1_u32) +LL | | .for_each(|x| println!("{}", x)); // infinite iter | |________________________________________^ error: infinite iteration detected --> $DIR/infinite_iter.rs:32:5 | -32 | (0_usize..).flat_map(|x| 0..x).product::<usize>(); // infinite iter +LL | (0_usize..).flat_map(|x| 0..x).product::<usize>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected --> $DIR/infinite_iter.rs:33:5 | -33 | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter +LL | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:40:5 | -40 | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter +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 | -38 | #[deny(clippy::maybe_infinite_iter)] +LL | #[deny(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:41:5 | -41 | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter +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 | -42 | / (1..) -43 | | .scan(0, |state, x| { -44 | | *state += x; -45 | | Some(*state) -46 | | }) -47 | | .min(); // maybe infinite iter +LL | / (1..) +LL | | .scan(0, |state, x| { +LL | | *state += x; +LL | | Some(*state) +LL | | }) +LL | | .min(); // maybe infinite iter | |______________^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:48:5 | -48 | (0..).find(|x| *x == 24); // maybe infinite iter +LL | (0..).find(|x| *x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:49:5 | -49 | (0..).position(|x| x == 24); // maybe infinite iter +LL | (0..).position(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:50:5 | -50 | (0..).any(|x| x == 24); // maybe infinite iter +LL | (0..).any(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:51:5 | -51 | (0..).all(|x| x == 24); // maybe infinite iter +LL | (0..).all(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index de7851519ec..79efb18a83e 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,7 +1,7 @@ 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 | -32 | while y < 10 { +LL | while y < 10 { | ^^^^^^ | = note: #[deny(clippy::while_immutable_condition)] on by default @@ -9,50 +9,50 @@ error: Variable in the condition are not mutated in the loop body. This either l 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 | -37 | while y < 10 && x < 3 { +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 | -44 | while !cond { +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:88:11 | -88 | while i < 3 { +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 | -93 | while i < 3 && j > 0 { +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 | -97 | while i < 3 { +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 - | -112 | while i < 3 { - | ^^^^^ + --> $DIR/infinite_loop.rs:112: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 - | -117 | while i < 3 { - | ^^^^^ + --> $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 - | -183 | while self.count < n { - | ^^^^^^^^^^^^^^ + --> $DIR/infinite_loop.rs:183:15 + | +LL | while self.count < n { + | ^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 0eaee7c7b25..3c2b086968e 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -1,9 +1,9 @@ error: use of `#[inline]` on trait method `default_inline` which has no body --> $DIR/inline_fn_without_body.rs:14:5 | -14 | #[inline] +LL | #[inline] | _____-^^^^^^^^ -15 | | fn default_inline(); +LL | | fn default_inline(); | |____- help: remove | = note: `-D clippy::inline-fn-without-body` implied by `-D warnings` @@ -11,17 +11,17 @@ error: use of `#[inline]` on trait method `default_inline` which has no body error: use of `#[inline]` on trait method `always_inline` which has no body --> $DIR/inline_fn_without_body.rs:17:5 | -17 | #[inline(always)] +LL | #[inline(always)] | _____-^^^^^^^^^^^^^^^^ -18 | | fn always_inline(); +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 | -20 | #[inline(never)] +LL | #[inline(never)] | _____-^^^^^^^^^^^^^^^ -21 | | fn never_inline(); +LL | | fn never_inline(); | |____- help: remove error: aborting due to 3 previous errors diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 4a81e911157..30bc2966619 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,43 +1,43 @@ error: Unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:16:5 | -16 | x >= y + 1; +LL | x >= y + 1; | ^^^^^^^^^^ | = note: `-D clippy::int-plus-one` implied by `-D warnings` help: change `>= y + 1` to `> y` as shown | -16 | x > y; +LL | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:17:5 | -17 | y + 1 <= x; +LL | y + 1 <= x; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -17 | y < x; +LL | y < x; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:19:5 | -19 | x - 1 >= y; +LL | x - 1 >= y; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -19 | x > y; +LL | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:20:5 | -20 | y <= x - 1; +LL | y <= x - 1; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -20 | y < x; +LL | y < x; | ^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index f6d6fe35d7f..e7f2a21d7a4 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,25 +1,25 @@ error: this .into_iter() call is equivalent to .iter() and will not move the array --> $DIR/into_iter_on_ref.rs:11:24 | -11 | for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter() +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 | -2 | #![deny(clippy::into_iter_on_array)] +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 | -13 | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the Vec --> $DIR/into_iter_on_ref.rs:15:30 | -15 | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` | = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` @@ -27,151 +27,151 @@ error: this .into_iter() call is equivalent to .iter() and will not move the Vec error: this .into_iter() call is equivalent to .iter() and will not move the slice --> $DIR/into_iter_on_ref.rs:16:46 | -16 | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() +LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the slice --> $DIR/into_iter_on_ref.rs:17:41 | -17 | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the slice --> $DIR/into_iter_on_ref.rs:18:44 | -18 | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array --> $DIR/into_iter_on_ref.rs:20:32 | -20 | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array --> $DIR/into_iter_on_ref.rs:21:36 | -21 | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the array --> $DIR/into_iter_on_ref.rs:22:40 | -22 | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() +LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Option --> $DIR/into_iter_on_ref.rs:24:24 | -24 | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter() +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 | -25 | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Result --> $DIR/into_iter_on_ref.rs:26:32 | -26 | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the Result --> $DIR/into_iter_on_ref.rs:27:37 | -27 | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Vec --> $DIR/into_iter_on_ref.rs:28:34 | -28 | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the Vec --> $DIR/into_iter_on_ref.rs:29:38 | -29 | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the BTreeMap --> $DIR/into_iter_on_ref.rs:30:44 | -30 | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the BTreeMap --> $DIR/into_iter_on_ref.rs:31:48 | -31 | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the VecDeque --> $DIR/into_iter_on_ref.rs:32:39 | -32 | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the VecDeque --> $DIR/into_iter_on_ref.rs:33:43 | -33 | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the LinkedList --> $DIR/into_iter_on_ref.rs:34:41 | -34 | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the LinkedList --> $DIR/into_iter_on_ref.rs:35:45 | -35 | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the HashMap --> $DIR/into_iter_on_ref.rs:36:43 | -36 | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the HashMap --> $DIR/into_iter_on_ref.rs:37:47 | -37 | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut() | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the BTreeSet --> $DIR/into_iter_on_ref.rs:39:39 | -39 | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the BinaryHeap --> $DIR/into_iter_on_ref.rs:40:41 | -40 | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the HashSet --> $DIR/into_iter_on_ref.rs:41:38 | -41 | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the Path --> $DIR/into_iter_on_ref.rs:42:43 | -42 | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter() +LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the PathBuf --> $DIR/into_iter_on_ref.rs:43:47 | -43 | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter() | ^^^^^^^^^ help: call directly: `iter` error: aborting due to 28 previous errors diff --git a/tests/ui/invalid_ref.stderr b/tests/ui/invalid_ref.stderr index a5142596aeb..f4386362099 100644 --- a/tests/ui/invalid_ref.stderr +++ b/tests/ui/invalid_ref.stderr @@ -1,7 +1,7 @@ error: reference to zeroed memory --> $DIR/invalid_ref.rs:33:24 | -33 | let ref_zero: &T = std::mem::zeroed(); // warning +LL | let ref_zero: &T = std::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(clippy::invalid_ref)] on by default @@ -10,7 +10,7 @@ error: reference to zeroed memory error: reference to zeroed memory --> $DIR/invalid_ref.rs:37:24 | -37 | let ref_zero: &T = core::mem::zeroed(); // warning +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 @@ -18,7 +18,7 @@ error: reference to zeroed memory error: reference to zeroed memory --> $DIR/invalid_ref.rs:41:24 | -41 | let ref_zero: &T = std::intrinsics::init(); // warning +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 @@ -26,7 +26,7 @@ error: reference to zeroed memory error: reference to uninitialized memory --> $DIR/invalid_ref.rs:45:26 | -45 | let ref_uninit: &T = std::mem::uninitialized(); // warning +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 @@ -34,7 +34,7 @@ error: reference to uninitialized memory error: reference to uninitialized memory --> $DIR/invalid_ref.rs:49:26 | -49 | let ref_uninit: &T = core::mem::uninitialized(); // warning +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 @@ -42,7 +42,7 @@ error: reference to uninitialized memory error: reference to uninitialized memory --> $DIR/invalid_ref.rs:53:26 | -53 | let ref_uninit: &T = std::intrinsics::uninit(); // warning +LL | let ref_uninit: &T = std::intrinsics::uninit(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index 2ac4a48b862..4bf92088337 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,7 +1,7 @@ error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:30:5 | -30 | (u8 as u32) > 300; +LL | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` @@ -9,157 +9,157 @@ error: because of the numeric bounds on `u8` prior to casting, this expression i error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:31:5 | -31 | (u8 as i32) > 300; +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 | -32 | (u8 as u32) == 300; +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 | -33 | (u8 as i32) == 300; +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 | -34 | 300 < (u8 as u32); +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 | -35 | 300 < (u8 as i32); +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 | -36 | 300 == (u8 as u32); +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 | -37 | 300 == (u8 as i32); +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 | -39 | (u8 as u32) <= 300; +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 | -40 | (u8 as i32) <= 300; +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 | -41 | (u8 as u32) != 300; +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 | -42 | (u8 as i32) != 300; +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 | -43 | 300 >= (u8 as u32); +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 | -44 | 300 >= (u8 as i32); +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 | -45 | 300 != (u8 as u32); +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 | -46 | 300 != (u8 as i32); +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 | -49 | (u8 as i32) < 0; +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 | -50 | -5 != (u8 as i32); +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 | -52 | (u8 as i32) >= 0; +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 | -53 | -5 == (u8 as i32); +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 | -56 | 1337 == (u8 as i32); +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 | -57 | 1337 == (u8 as u32); +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 | -59 | 1337 != (u8 as i32); +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 | -60 | 1337 != (u8 as u32); +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 | -74 | (u8 as i32) > -1; +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 | -75 | (u8 as i32) < -1; +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 | -91 | -5 >= (u8 as i32); +LL | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: aborting due to 27 previous errors diff --git a/tests/ui/issue-3145.stderr b/tests/ui/issue-3145.stderr index 6f9f88a8d67..c7a995c61d6 100644 --- a/tests/ui/issue-3145.stderr +++ b/tests/ui/issue-3145.stderr @@ -1,7 +1,7 @@ error: expected token: `,` --> $DIR/issue-3145.rs:11:19 | -11 | println!("{}" a); //~ERROR expected token: `,` +LL | println!("{}" a); //~ERROR expected token: `,` | ^ error: aborting due to previous error diff --git a/tests/ui/issue_2356.stderr b/tests/ui/issue_2356.stderr index 28b67cbc9fa..37599900312 100644 --- a/tests/ui/issue_2356.stderr +++ b/tests/ui/issue_2356.stderr @@ -1,13 +1,13 @@ error: this loop could be written as a `for` loop --> $DIR/issue_2356.rs:24:29 | -24 | while let Some(e) = it.next() { +LL | while let Some(e) = it.next() { | ^^^^^^^^^ help: try: `for e in it { .. }` | note: lint level defined here --> $DIR/issue_2356.rs:10:9 | -10 | #![deny(clippy::while_let_on_iterator)] +LL | #![deny(clippy::while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index c988fca3827..3024431244c 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -1,9 +1,9 @@ error: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:21:5 | -21 | / fn foo() { -22 | | println!("foo"); -23 | | } +LL | / fn foo() { +LL | | println!("foo"); +LL | | } | |_____^ | = note: `-D clippy::items-after-statements` implied by `-D warnings` @@ -11,9 +11,9 @@ error: adding items after statements is confusing, since items exist from the st error: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:28:5 | -28 | / fn foo() { -29 | | println!("foo"); -30 | | } +LL | / fn foo() { +LL | | println!("foo"); +LL | | } | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index 47587f5423a..3f88aefda33 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -1,7 +1,7 @@ error: digit groups should be smaller --> $DIR/large_digit_groups.rs:24:9 | -24 | 0b1_10110_i64, +LL | 0b1_10110_i64, | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::large-digit-groups` implied by `-D warnings` @@ -9,31 +9,31 @@ error: digit groups should be smaller error: digit groups should be smaller --> $DIR/large_digit_groups.rs:25:9 | -25 | 0x1_23456_78901_usize, +LL | 0x1_23456_78901_usize, | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:26:9 | -26 | 1_23456_f32, +LL | 1_23456_f32, | ^^^^^^^^^^^ help: consider: `123_456_f32` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:27:9 | -27 | 1_23456.12_f32, +LL | 1_23456.12_f32, | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:28:9 | -28 | 1_23456.12345_f32, +LL | 1_23456.12345_f32, | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f32` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:29:9 | -29 | 1_23456.12345_6_f32, +LL | 1_23456.12345_6_f32, | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f32` error: aborting due to 6 previous errors diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index c9c46ced5e2..839d16bd9a2 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -1,69 +1,69 @@ error: large size difference between variants --> $DIR/large_enum_variant.rs:16:5 | -16 | B([i32; 8000]), +LL | B([i32; 8000]), | ^^^^^^^^^^^^^^ | = note: `-D clippy::large-enum-variant` implied by `-D warnings` help: consider boxing the large fields to reduce the total size of the enum | -16 | B(Box<[i32; 8000]>), +LL | B(Box<[i32; 8000]>), | ^^^^^^^^^^^^^^^^ error: large size difference between variants --> $DIR/large_enum_variant.rs:27:5 | -27 | C(T, [i32; 8000]), +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 | -27 | C(T, [i32; 8000]), +LL | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ error: large size difference between variants --> $DIR/large_enum_variant.rs:40:5 | -40 | ContainingLargeEnum(LargeEnum), +LL | ContainingLargeEnum(LargeEnum), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | -40 | ContainingLargeEnum(Box<LargeEnum>), +LL | ContainingLargeEnum(Box<LargeEnum>), | ^^^^^^^^^^^^^^ error: large size difference between variants --> $DIR/large_enum_variant.rs:43:5 | -43 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), +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 | -43 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), +LL | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants --> $DIR/large_enum_variant.rs:50:5 | -50 | StructLikeLarge { x: [i32; 8000], y: i32 }, +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 | -50 | StructLikeLarge { x: [i32; 8000], y: i32 }, +LL | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants --> $DIR/large_enum_variant.rs:55:5 | -55 | StructLikeLarge2 { x: [i32; 8000] }, +LL | StructLikeLarge2 { x: [i32; 8000] }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | -55 | StructLikeLarge2 { x: Box<[i32; 8000]> }, +LL | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index bc5cd0e595b..f5f19e128b7 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,11 +1,11 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` method --> $DIR/len_zero.rs:15:1 | -15 | / impl PubOne { -16 | | pub fn len(self: &Self) -> isize { -17 | | 1 -18 | | } -19 | | } +LL | / impl PubOne { +LL | | pub fn len(self: &Self) -> isize { +LL | | 1 +LL | | } +LL | | } | |_^ | = note: `-D clippy::len-without-is-empty` implied by `-D warnings` @@ -13,128 +13,128 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` m error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method --> $DIR/len_zero.rs:64:1 | -64 | / pub trait PubTraitsToo { -65 | | fn len(self: &Self) -> isize; -66 | | } +LL | / pub trait PubTraitsToo { +LL | | fn len(self: &Self) -> isize; +LL | | } | |_^ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method - --> $DIR/len_zero.rs:98:1 - | -98 | / impl HasIsEmpty { -99 | | pub fn len(self: &Self) -> isize { -100 | | 1 -101 | | } -... | -105 | | } -106 | | } - | |_^ + --> $DIR/len_zero.rs:98:1 + | +LL | / impl HasIsEmpty { +LL | | pub fn len(self: &Self) -> isize { +LL | | 1 +LL | | } +... | +LL | | } +LL | | } + | |_^ error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:127:1 - | -127 | / impl HasWrongIsEmpty { -128 | | pub fn len(self: &Self) -> isize { -129 | | 1 -130 | | } -... | -134 | | } -135 | | } - | |_^ + --> $DIR/len_zero.rs:127:1 + | +LL | / impl HasWrongIsEmpty { +LL | | pub fn len(self: &Self) -> isize { +LL | | 1 +LL | | } +... | +LL | | } +LL | | } + | |_^ error: length comparison to zero - --> $DIR/len_zero.rs:148:8 - | -148 | if x.len() == 0 { - | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` - | - = note: `-D clippy::len-zero` implied by `-D warnings` + --> $DIR/len_zero.rs:148:8 + | +LL | if x.len() == 0 { + | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` + | + = note: `-D clippy::len-zero` implied by `-D warnings` error: length comparison to zero - --> $DIR/len_zero.rs:152:8 - | -152 | if "".len() == 0 {} - | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` + --> $DIR/len_zero.rs:152: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 - | -167 | if has_is_empty.len() == 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` + --> $DIR/len_zero.rs:167: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 - | -170 | if has_is_empty.len() != 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` + --> $DIR/len_zero.rs:170: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 - | -173 | if has_is_empty.len() > 0 { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` + --> $DIR/len_zero.rs:173: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 - | -176 | if has_is_empty.len() < 1 { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` + --> $DIR/len_zero.rs:176: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 - | -179 | if has_is_empty.len() >= 1 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` + --> $DIR/len_zero.rs:179: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 - | -190 | if 0 == has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` + --> $DIR/len_zero.rs:190: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 - | -193 | if 0 != has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` + --> $DIR/len_zero.rs:193: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 - | -196 | if 0 < has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` + --> $DIR/len_zero.rs:196: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 - | -199 | if 1 <= has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` + --> $DIR/len_zero.rs:199: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 - | -202 | if 1 > has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` + --> $DIR/len_zero.rs:202: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 - | -216 | if with_is_empty.len() == 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` + --> $DIR/len_zero.rs:216: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 - | -229 | if b.len() != 0 {} - | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!b.is_empty()` + --> $DIR/len_zero.rs:229: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 - | -235 | / pub trait DependsOnFoo: Foo { -236 | | fn len(&mut self) -> usize; -237 | | } - | |_^ + --> $DIR/len_zero.rs:235:1 + | +LL | / pub trait DependsOnFoo: Foo { +LL | | fn len(&mut self) -> usize; +LL | | } + | |_^ error: aborting due to 19 previous errors diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 91acf6dcb30..7883a713c05 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,10 +1,10 @@ error: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:72:5 | -72 | / let mut foo = 0; -73 | | if f() { -74 | | foo = 42; -75 | | } +LL | / let mut foo = 0; +LL | | if f() { +LL | | foo = 42; +LL | | } | |_____^ help: it is more idiomatic to write: `let <mut> foo = if f() { 42 } else { 0 };` | = note: `-D clippy::useless-let-if-seq` implied by `-D warnings` @@ -13,13 +13,13 @@ error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:77:5 | -77 | / let mut bar = 0; -78 | | if f() { -79 | | f(); -80 | | bar = 42; -81 | | } else { -82 | | f(); -83 | | } +LL | / let mut bar = 0; +LL | | if f() { +LL | | f(); +LL | | bar = 42; +LL | | } else { +LL | | f(); +LL | | } | |_____^ help: it is more idiomatic to write: `let <mut> bar = if f() { ..; 42 } else { ..; 0 };` | = note: you might not need `mut` at all @@ -27,24 +27,24 @@ error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:85:5 | -85 | / let quz; -86 | | if f() { -87 | | quz = 42; -88 | | } else { -89 | | quz = 0; -90 | | } +LL | / let quz; +LL | | if f() { +LL | | quz = 42; +LL | | } else { +LL | | quz = 0; +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 - | -114 | / let mut baz = 0; -115 | | if f() { -116 | | baz = 42; -117 | | } - | |_____^ help: it is more idiomatic to write: `let <mut> baz = if f() { 42 } else { 0 };` - | - = note: you might not need `mut` at all + --> $DIR/let_if_seq.rs:114:5 + | +LL | / let mut baz = 0; +LL | | if f() { +LL | | baz = 42; +LL | | } + | |_____^ help: it is more idiomatic to write: `let <mut> baz = if f() { 42 } else { 0 };` + | + = note: you might not need `mut` at all error: aborting due to 4 previous errors diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index 894c15c2d6d..c53d5cfb886 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -1,26 +1,26 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. --> $DIR/let_return.rs:16:5 | -16 | x +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 | -15 | let x = 5; +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 | -22 | x +LL | x | ^ | note: this expression can be directly returned --> $DIR/let_return.rs:21:17 | -21 | let x = 5; +LL | let x = 5; | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index a8771dd5f47..8929844180a 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,7 +1,7 @@ error: this let-binding has unit value. Consider omitting `let _x =` --> $DIR/let_unit.rs:20:5 | -20 | let _x = println!("x"); +LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::let-unit-value` implied by `-D warnings` @@ -9,7 +9,7 @@ error: this let-binding has unit value. Consider omitting `let _x =` error: this let-binding has unit value. Consider omitting `let _a =` --> $DIR/let_unit.rs:24:9 | -24 | let _a = (); +LL | let _a = (); | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index 5bddf5aa746..abd11907b6d 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -1,7 +1,7 @@ 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 | -13 | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} +LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::needless-lifetimes` implied by `-D warnings` @@ -9,114 +9,114 @@ error: explicit lifetimes given in parameter types where they could be elided (o 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 | -15 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} +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 | -23 | / fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { -24 | | x -25 | | } +LL | / fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { +LL | | x +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 | -47 | / fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { -48 | | Ok(x) -49 | | } +LL | / fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { +LL | | Ok(x) +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 | -52 | / fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> -53 | | where -54 | | T: Copy, -55 | | { -56 | | Ok(x) -57 | | } +LL | / fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> +LL | | where +LL | | T: Copy, +LL | | { +LL | | Ok(x) +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 | -63 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} +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 | -84 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> -85 | | where -86 | | for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>, -87 | | { -88 | | unreachable!() -89 | | } +LL | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> +LL | | where +LL | | for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>, +LL | | { +LL | | unreachable!() +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 - | -117 | / fn self_and_out<'s>(&'s self) -> &'s u8 { -118 | | &self.x -119 | | } - | |_____^ + --> $DIR/lifetimes.rs:117:5 + | +LL | / fn self_and_out<'s>(&'s self) -> &'s u8 { +LL | | &self.x +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 - | -125 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/lifetimes.rs:125: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 - | -141 | / fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { -142 | | unimplemented!() -143 | | } - | |_^ + --> $DIR/lifetimes.rs:141:1 + | +LL | / fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { +LL | | unimplemented!() +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 - | -171 | / fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { -172 | | unimplemented!() -173 | | } - | |_^ + --> $DIR/lifetimes.rs:171:1 + | +LL | / fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { +LL | | unimplemented!() +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 - | -177 | / fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { -178 | | unimplemented!() -179 | | } - | |_^ + --> $DIR/lifetimes.rs:177:1 + | +LL | / fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { +LL | | unimplemented!() +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 - | -196 | / fn named_input_elided_output<'a>(_arg: &'a str) -> &str { -197 | | unimplemented!() -198 | | } - | |_^ + --> $DIR/lifetimes.rs:196:1 + | +LL | / fn named_input_elided_output<'a>(_arg: &'a str) -> &str { +LL | | unimplemented!() +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 - | -204 | / fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { -205 | | unimplemented!() -206 | | } - | |_^ + --> $DIR/lifetimes.rs:204:1 + | +LL | / fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { +LL | | unimplemented!() +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 - | -241 | / fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { -242 | | unimplemented!() -243 | | } - | |_^ + --> $DIR/lifetimes.rs:241:1 + | +LL | / fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { +LL | | unimplemented!() +LL | | } + | |_^ error: aborting due to 15 previous errors diff --git a/tests/ui/lint_without_lint_pass.stderr b/tests/ui/lint_without_lint_pass.stderr index d0d65df21f0..9d0b0d62789 100644 --- a/tests/ui/lint_without_lint_pass.stderr +++ b/tests/ui/lint_without_lint_pass.stderr @@ -1,17 +1,17 @@ error: the lint `TEST_LINT` is not added to any `LintPass` --> $DIR/lint_without_lint_pass.rs:11:1 | -11 | / declare_clippy_lint! { -12 | | pub TEST_LINT, -13 | | correctness, -14 | | "" -15 | | } +LL | / declare_clippy_lint! { +LL | | pub TEST_LINT, +LL | | correctness, +LL | | "" +LL | | } | |_^ | note: lint level defined here --> $DIR/lint_without_lint_pass.rs:1:9 | -1 | #![deny(clippy::internal)] +LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ = note: #[deny(clippy::lint_without_lint_pass)] implied by #[deny(clippy::internal)] = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index a9d49ff394e..6ceb25fd612 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -1,7 +1,7 @@ error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:22:17 | -22 | let fail1 = 0xabCD; +LL | let fail1 = 0xabCD; | ^^^^^^ | = note: `-D clippy::mixed-case-hex-literals` implied by `-D warnings` @@ -9,19 +9,19 @@ error: inconsistent casing in hexadecimal literal error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:23:17 | -23 | let fail2 = 0xabCD_u32; +LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:24:17 | -24 | let fail2 = 0xabCD_isize; +LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:25:27 | -25 | let fail_multi_zero = 000_123usize; +LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ | = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` @@ -29,67 +29,67 @@ error: integer type suffix should be separated by an underscore error: this is a decimal constant --> $DIR/literals.rs:25:27 | -25 | let fail_multi_zero = 000_123usize; +LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ | = note: `-D clippy::zero-prefixed-literal` implied by `-D warnings` help: if you mean to use a decimal constant, remove the `0` to remove confusion | -25 | let fail_multi_zero = 123usize; +LL | let fail_multi_zero = 123usize; | ^^^^^^^^ help: if you mean to use an octal constant, use `0o` | -25 | let fail_multi_zero = 0o123usize; +LL | let fail_multi_zero = 0o123usize; | ^^^^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:30:17 | -30 | let fail3 = 1234i32; +LL | let fail3 = 1234i32; | ^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:31:17 | -31 | let fail4 = 1234u32; +LL | let fail4 = 1234u32; | ^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:32:17 | -32 | let fail5 = 1234isize; +LL | let fail5 = 1234isize; | ^^^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:33:17 | -33 | let fail6 = 1234usize; +LL | let fail6 = 1234usize; | ^^^^^^^^^ error: float type suffix should be separated by an underscore --> $DIR/literals.rs:34:17 | -34 | let fail7 = 1.5f32; +LL | let fail7 = 1.5f32; | ^^^^^^ error: this is a decimal constant --> $DIR/literals.rs:38:17 | -38 | let fail8 = 0123; +LL | let fail8 = 0123; | ^^^^ help: if you mean to use a decimal constant, remove the `0` to remove confusion | -38 | let fail8 = 123; +LL | let fail8 = 123; | ^^^ help: if you mean to use an octal constant, use `0o` | -38 | let fail8 = 0o123; +LL | let fail8 = 0o123; | ^^^^^ error: long literal lacking separators --> $DIR/literals.rs:49:17 | -49 | let fail9 = 0xabcdef; +LL | let fail9 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` @@ -97,25 +97,25 @@ error: long literal lacking separators error: long literal lacking separators --> $DIR/literals.rs:50:18 | -50 | let fail10 = 0xBAFEBAFE; +LL | let fail10 = 0xBAFEBAFE; | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` error: long literal lacking separators --> $DIR/literals.rs:51:18 | -51 | let fail11 = 0xabcdeff; +LL | let fail11 = 0xabcdeff; | ^^^^^^^^^ help: consider: `0x0abc_deff` error: long literal lacking separators --> $DIR/literals.rs:52:18 | -52 | let fail12 = 0xabcabcabcabcabcabc; +LL | let fail12 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` error: digit groups should be smaller --> $DIR/literals.rs:53:18 | -53 | let fail13 = 0x1_23456_78901_usize; +LL | let fail13 = 0x1_23456_78901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` | = note: `-D clippy::large-digit-groups` implied by `-D warnings` @@ -123,7 +123,7 @@ error: digit groups should be smaller error: mistyped literal suffix --> $DIR/literals.rs:55:18 | -55 | let fail14 = 2_32; +LL | let fail14 = 2_32; | ^^^^ help: did you mean to write: `2_i32` | = note: #[deny(clippy::mistyped_literal_suffixes)] on by default @@ -131,25 +131,25 @@ error: mistyped literal suffix error: mistyped literal suffix --> $DIR/literals.rs:56:18 | -56 | let fail15 = 4_64; +LL | let fail15 = 4_64; | ^^^^ help: did you mean to write: `4_i64` error: mistyped literal suffix --> $DIR/literals.rs:57:18 | -57 | let fail16 = 7_8; +LL | let fail16 = 7_8; | ^^^ help: did you mean to write: `7_i8` error: mistyped literal suffix --> $DIR/literals.rs:58:18 | -58 | let fail17 = 23_16; +LL | let fail17 = 23_16; | ^^^^^ help: did you mean to write: `23_i16` error: digits grouped inconsistently by underscores --> $DIR/literals.rs:60:18 | -60 | let fail19 = 12_3456_21; +LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` @@ -157,61 +157,61 @@ error: digits grouped inconsistently by underscores error: mistyped literal suffix --> $DIR/literals.rs:61:18 | -61 | let fail20 = 2__8; +LL | let fail20 = 2__8; | ^^^^ help: did you mean to write: `2_i8` error: mistyped literal suffix --> $DIR/literals.rs:62:18 | -62 | let fail21 = 4___16; +LL | let fail21 = 4___16; | ^^^^^^ help: did you mean to write: `4_i16` error: digits grouped inconsistently by underscores --> $DIR/literals.rs:63:18 | -63 | let fail22 = 3__4___23; +LL | let fail22 = 3__4___23; | ^^^^^^^^^ help: consider: `3_423` error: digits grouped inconsistently by underscores --> $DIR/literals.rs:64:18 | -64 | let fail23 = 3__16___23; +LL | let fail23 = 3__16___23; | ^^^^^^^^^^ help: consider: `31_623` error: mistyped literal suffix --> $DIR/literals.rs:66:18 | -66 | let fail24 = 12.34_64; +LL | let fail24 = 12.34_64; | ^^^^^^^^ help: did you mean to write: `12.34_f64` error: mistyped literal suffix --> $DIR/literals.rs:67:18 | -67 | let fail25 = 1E2_32; +LL | let fail25 = 1E2_32; | ^^^^^^ help: did you mean to write: `1E2_f32` error: mistyped literal suffix --> $DIR/literals.rs:68:18 | -68 | let fail26 = 43E7_64; +LL | let fail26 = 43E7_64; | ^^^^^^^ help: did you mean to write: `43E7_f64` error: mistyped literal suffix --> $DIR/literals.rs:69:18 | -69 | let fail27 = 243E17_32; +LL | let fail27 = 243E17_32; | ^^^^^^^^^ help: did you mean to write: `243E17_f32` error: mistyped literal suffix --> $DIR/literals.rs:70:18 | -70 | let fail28 = 241251235E723_64; +LL | let fail28 = 241251235E723_64; | ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64` error: mistyped literal suffix --> $DIR/literals.rs:71:18 | -71 | let fail29 = 42279.911_32; +LL | let fail29 = 42279.911_32; | ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32` error: aborting due to 31 previous errors diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 603819de16e..6253ae2150c 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,7 +1,7 @@ error: You are using an explicit closure for cloning elements --> $DIR/map_clone.rs:14:22 | -14 | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect(); +LL | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![5_i8; 6].iter().cloned()` | = note: `-D clippy::map-clone` implied by `-D warnings` @@ -9,13 +9,13 @@ error: You are using an explicit closure for cloning elements error: You are using an explicit closure for cloning elements --> $DIR/map_clone.rs:15:26 | -15 | let _: Vec<String> = vec![String::new()].iter().map(|x| x.clone()).collect(); +LL | let _: Vec<String> = 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 | -16 | let _: Vec<u32> = vec![42, 43].iter().map(|&x| x).collect(); +LL | let _: Vec<u32> = 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 diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index 488797173f6..931ef9b6248 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -1,7 +1,7 @@ error: called `map(..).flatten()` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` --> $DIR/map_flatten.rs:14:21 | -14 | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); +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)` | = note: `-D clippy::map-flatten` implied by `-D warnings` diff --git a/tests/ui/map_unit_fn.rs b/tests/ui/map_unit_fn.rs new file mode 100644 index 00000000000..1d203a147ba --- /dev/null +++ b/tests/ui/map_unit_fn.rs @@ -0,0 +1,20 @@ +// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +struct Mappable {} + +impl Mappable { + pub fn map(&self) {} +} + +fn main() { + let m = Mappable {}; + m.map(); +} diff --git a/tests/ui/map_unit_fn.stderr b/tests/ui/map_unit_fn.stderr deleted file mode 100644 index c4ee0ce9238..00000000000 --- a/tests/ui/map_unit_fn.stderr +++ /dev/null @@ -1,210 +0,0 @@ -error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/map_unit_fn.rs:33:5 - | -33 | x.field.map(do_nothing); - | ^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` - | - = note: `-D option-map-unit-fn` implied by `-D warnings` - -error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/map_unit_fn.rs:35:5 - | -35 | 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/map_unit_fn.rs:37:5 - | -37 | 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/map_unit_fn.rs:43:5 - | -43 | 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/map_unit_fn.rs:45:5 - | -45 | 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/map_unit_fn.rs:48:5 - | -48 | 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/map_unit_fn.rs:50:5 - | -50 | 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/map_unit_fn.rs:52:5 - | -52 | 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/map_unit_fn.rs:54:5 - | -54 | 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/map_unit_fn.rs:57:5 - | -57 | 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/map_unit_fn.rs:59:5 - | -59 | 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/map_unit_fn.rs:61:5 - | -61 | 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/map_unit_fn.rs:63:5 - | -63 | 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/map_unit_fn.rs:68:5 - | -68 | 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/map_unit_fn.rs:70:5 - | -70 | 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/map_unit_fn.rs:72:5 - | -72 | 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/map_unit_fn.rs:75:5 - | -75 | 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/map_unit_fn.rs:78:5 - | -78 | 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/map_unit_fn.rs:80:5 - | -80 | 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/map_unit_fn.rs:84:5 - | -84 | x.field.map(|value| { - | _____^ - | |_____| - | || -85 | || do_nothing(value); -86 | || do_nothing(value) -87 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` - | |_______| - | - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/map_unit_fn.rs:88:5 - | -88 | 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/map_unit_fn.rs:91:5 - | -91 | 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/map_unit_fn.rs:92:5 - | -92 | "12".parse::<i32>().ok().map(diverge); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(_) = "12".parse::<i32>().ok() { diverge(...) }` - -error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/map_unit_fn.rs:93:5 - | -93 | 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/map_unit_fn.rs:97:5 - | -97 | y.map(do_nothing); - | ^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(_y) = y { do_nothing(...) }` - -error: aborting due to 25 previous errors - diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index a073f995498..78711c4ba4b 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -1,7 +1,7 @@ error: this boolean expression can be simplified --> $DIR/match_bool.rs:38:11 | -38 | match test && test { +LL | match test && test { | ^^^^^^^^^^^^ help: try: `test` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` @@ -9,10 +9,10 @@ error: this boolean expression can be simplified error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:13:5 | -13 | / match test { -14 | | true => 0, -15 | | false => 42, -16 | | }; +LL | / match test { +LL | | true => 0, +LL | | false => 42, +LL | | }; | |_____^ help: consider using an if/else expression: `if test { 0 } else { 42 }` | = note: `-D clippy::match-bool` implied by `-D warnings` @@ -20,67 +20,67 @@ error: you seem to be trying to match on a boolean expression error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:19:5 | -19 | / match option == 1 { -20 | | true => 1, -21 | | false => 0, -22 | | }; +LL | / match option == 1 { +LL | | true => 1, +LL | | false => 0, +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 | -24 | / match test { -25 | | true => (), -26 | | false => { -27 | | println!("Noooo!"); -28 | | }, -29 | | }; +LL | / match test { +LL | | true => (), +LL | | false => { +LL | | println!("Noooo!"); +LL | | }, +LL | | }; | |_____^ help: consider using an if/else expression | -24 | if !test { -25 | println!("Noooo!"); -26 | }; +LL | if !test { +LL | println!("Noooo!"); +LL | }; | error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:31:5 | -31 | / match test { -32 | | false => { -33 | | println!("Noooo!"); -34 | | }, -35 | | _ => (), -36 | | }; +LL | / match test { +LL | | false => { +LL | | println!("Noooo!"); +LL | | }, +LL | | _ => (), +LL | | }; | |_____^ help: consider using an if/else expression | -31 | if !test { -32 | println!("Noooo!"); -33 | }; +LL | if !test { +LL | println!("Noooo!"); +LL | }; | error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:38:5 | -38 | / match test && test { -39 | | false => { -40 | | println!("Noooo!"); -41 | | }, -42 | | _ => (), -43 | | }; +LL | / match test && test { +LL | | false => { +LL | | println!("Noooo!"); +LL | | }, +LL | | _ => (), +LL | | }; | |_____^ help: consider using an if/else expression | -38 | if !(test && test) { -39 | println!("Noooo!"); -40 | }; +LL | if !(test && test) { +LL | println!("Noooo!"); +LL | }; | error: equal expressions as operands to `&&` --> $DIR/match_bool.rs:38:11 | -38 | match test && test { +LL | match test && test { | ^^^^^^^^^^^^ | = note: #[deny(clippy::eq_op)] on by default @@ -88,21 +88,21 @@ error: equal expressions as operands to `&&` error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:45:5 | -45 | / match test { -46 | | false => { -47 | | println!("Noooo!"); -48 | | }, +LL | / match test { +LL | | false => { +LL | | println!("Noooo!"); +LL | | }, ... | -51 | | }, -52 | | }; +LL | | }, +LL | | }; | |_____^ help: consider using an if/else expression | -45 | if test { -46 | println!("Yes!"); -47 | } else { -48 | println!("Noooo!"); -49 | }; +LL | if test { +LL | println!("Yes!"); +LL | } else { +LL | println!("Noooo!"); +LL | }; | error: aborting due to 8 previous errors diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index ef8fc08f95b..3e978df842e 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -1,62 +1,62 @@ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:20:9 | -20 | 0...10 => println!("0 ... 10"), +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 | -21 | 0...11 => println!("0 ... 11"), +LL | 0...11 => println!("0 ... 11"), | ^^^^^^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:26:9 | -26 | 0...5 => println!("0 ... 5"), +LL | 0...5 => println!("0 ... 5"), | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:28:9 | -28 | FOO...11 => println!("0 ... 11"), +LL | FOO...11 => println!("0 ... 11"), | ^^^^^^^^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:34:9 | -34 | 0...5 => println!("0 ... 5"), +LL | 0...5 => println!("0 ... 5"), | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:33:9 | -33 | 2 => println!("2"), +LL | 2 => println!("2"), | ^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:40:9 | -40 | 0...2 => println!("0 ... 2"), +LL | 0...2 => println!("0 ... 2"), | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:39:9 | -39 | 2 => println!("2"), +LL | 2 => println!("2"), | ^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:63:9 | -63 | 0..11 => println!("0 .. 11"), +LL | 0..11 => println!("0 .. 11"), | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:64:9 | -64 | 0...11 => println!("0 ... 11"), +LL | 0...11 => println!("0 ... 11"), | ^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 3ed70168c6e..06ba6224855 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -1,77 +1,77 @@ error: you don't need to add `&` to all patterns --> $DIR/matches.rs:20:9 | -20 | / match v { -21 | | &Some(v) => println!("{:?}", v), -22 | | &None => println!("none"), -23 | | } +LL | / match v { +LL | | &Some(v) => println!("{:?}", v), +LL | | &None => println!("none"), +LL | | } | |_________^ | = note: `-D clippy::match-ref-pats` implied by `-D warnings` help: instead of prefixing all patterns with `&`, you can dereference the expression | -20 | match *v { -21 | Some(v) => println!("{:?}", v), -22 | None => println!("none"), +LL | match *v { +LL | Some(v) => println!("{:?}", v), +LL | None => println!("none"), | error: you don't need to add `&` to all patterns --> $DIR/matches.rs:31:5 | -31 | / match tup { -32 | | &(v, 1) => println!("{}", v), -33 | | _ => println!("none"), -34 | | } +LL | / match tup { +LL | | &(v, 1) => println!("{}", v), +LL | | _ => println!("none"), +LL | | } | |_____^ help: instead of prefixing all patterns with `&`, you can dereference the expression | -31 | match *tup { -32 | (v, 1) => println!("{}", v), +LL | match *tup { +LL | (v, 1) => println!("{}", v), | error: you don't need to add `&` to both the expression and the patterns --> $DIR/matches.rs:37:5 | -37 | / match &w { -38 | | &Some(v) => println!("{:?}", v), -39 | | &None => println!("none"), -40 | | } +LL | / match &w { +LL | | &Some(v) => println!("{:?}", v), +LL | | &None => println!("none"), +LL | | } | |_____^ help: try | -37 | match w { -38 | Some(v) => println!("{:?}", v), -39 | None => println!("none"), +LL | match w { +LL | Some(v) => println!("{:?}", v), +LL | None => println!("none"), | error: you don't need to add `&` to all patterns --> $DIR/matches.rs:48:5 | -48 | / if let &None = a { -49 | | println!("none"); -50 | | } +LL | / if let &None = a { +LL | | println!("none"); +LL | | } | |_____^ help: instead of prefixing all patterns with `&`, you can dereference the expression | -48 | if let None = *a { +LL | if let None = *a { | ^^^^ ^^ error: you don't need to add `&` to both the expression and the patterns --> $DIR/matches.rs:53:5 | -53 | / if let &None = &b { -54 | | println!("none"); -55 | | } +LL | / if let &None = &b { +LL | | println!("none"); +LL | | } | |_____^ help: try | -53 | if let None = b { +LL | if let None = b { | ^^^^ ^ error: Err(_) will match all errors, maybe not a good idea --> $DIR/matches.rs:64:9 | -64 | Err(_) => panic!("err"), +LL | Err(_) => panic!("err"), | ^^^^^^ | = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` @@ -80,26 +80,26 @@ error: Err(_) will match all errors, maybe not a good idea error: this `match` has identical arm bodies --> $DIR/matches.rs:63:18 | -63 | Ok(_) => println!("ok"), +LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this --> $DIR/matches.rs:62:18 | -62 | Ok(3) => println!("ok"), +LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` --> $DIR/matches.rs:62:18 | -62 | Ok(3) => println!("ok"), +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 | -70 | Err(_) => panic!(), +LL | Err(_) => panic!(), | ^^^^^^ | = note: to remove this warning, match each error separately or use unreachable macro @@ -107,25 +107,25 @@ error: Err(_) will match all errors, maybe not a good idea error: this `match` has identical arm bodies --> $DIR/matches.rs:69:18 | -69 | Ok(_) => println!("ok"), +LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this --> $DIR/matches.rs:68:18 | -68 | Ok(3) => println!("ok"), +LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` --> $DIR/matches.rs:68:18 | -68 | Ok(3) => println!("ok"), +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 | -76 | Err(_) => { +LL | Err(_) => { | ^^^^^^ | = note: to remove this warning, match each error separately or use unreachable macro @@ -133,150 +133,150 @@ error: Err(_) will match all errors, maybe not a good idea error: this `match` has identical arm bodies --> $DIR/matches.rs:75:18 | -75 | Ok(_) => println!("ok"), +LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this --> $DIR/matches.rs:74:18 | -74 | Ok(3) => println!("ok"), +LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` --> $DIR/matches.rs:74:18 | -74 | Ok(3) => println!("ok"), +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 | -84 | Ok(_) => println!("ok"), +LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this --> $DIR/matches.rs:83:18 | -83 | Ok(3) => println!("ok"), +LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` --> $DIR/matches.rs:83:18 | -83 | Ok(3) => println!("ok"), +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 | -91 | Ok(_) => println!("ok"), +LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this --> $DIR/matches.rs:90:18 | -90 | Ok(3) => println!("ok"), +LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` --> $DIR/matches.rs:90:18 | -90 | Ok(3) => println!("ok"), +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 | -97 | Ok(_) => println!("ok"), +LL | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this --> $DIR/matches.rs:96:18 | -96 | Ok(3) => println!("ok"), +LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` --> $DIR/matches.rs:96:18 | -96 | Ok(3) => println!("ok"), +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 - | -103 | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | + --> $DIR/matches.rs:103:18 + | +LL | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | note: same as this - --> $DIR/matches.rs:102:18 - | -102 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ + --> $DIR/matches.rs:102:18 + | +LL | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:102:18 - | -102 | 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) + --> $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 - | -126 | (Ok(_), Some(x)) => println!("ok {}", x), - | ^^^^^^^^^^^^^^^^^^^^ - | + --> $DIR/matches.rs:126:29 + | +LL | (Ok(_), Some(x)) => println!("ok {}", x), + | ^^^^^^^^^^^^^^^^^^^^ + | note: same as this - --> $DIR/matches.rs:125:29 - | -125 | (Ok(x), Some(_)) => println!("ok {}", x), - | ^^^^^^^^^^^^^^^^^^^^ + --> $DIR/matches.rs:125:29 + | +LL | (Ok(x), Some(_)) => println!("ok {}", x), + | ^^^^^^^^^^^^^^^^^^^^ note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))` - --> $DIR/matches.rs:125:29 - | -125 | (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) + --> $DIR/matches.rs:125: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 - | -141 | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | + --> $DIR/matches.rs:141:18 + | +LL | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | note: same as this - --> $DIR/matches.rs:140:18 - | -140 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ + --> $DIR/matches.rs:140:18 + | +LL | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:140:18 - | -140 | 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) + --> $DIR/matches.rs:140: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 - | -150 | let borrowed: Option<&()> = match owned { - | _________________________________^ -151 | | None => None, -152 | | Some(ref v) => Some(v), -153 | | }; - | |_____^ help: try this: `owned.as_ref()` - | - = note: `-D clippy::match-as-ref` implied by `-D warnings` + --> $DIR/matches.rs:150:33 + | +LL | let borrowed: Option<&()> = match owned { + | _________________________________^ +LL | | None => None, +LL | | Some(ref v) => Some(v), +LL | | }; + | |_____^ help: try this: `owned.as_ref()` + | + = note: `-D clippy::match-as-ref` implied by `-D warnings` error: use as_mut() instead - --> $DIR/matches.rs:156:39 - | -156 | let borrow_mut: Option<&mut ()> = match mut_owned { - | _______________________________________^ -157 | | None => None, -158 | | Some(ref mut v) => Some(v), -159 | | }; - | |_____^ help: try this: `mut_owned.as_mut()` + --> $DIR/matches.rs:156:39 + | +LL | let borrow_mut: Option<&mut ()> = match mut_owned { + | _______________________________________^ +LL | | None => None, +LL | | Some(ref mut v) => Some(v), +LL | | }; + | |_____^ help: try this: `mut_owned.as_mut()` error: aborting due to 19 previous errors diff --git a/tests/ui/mem_discriminant.stderr b/tests/ui/mem_discriminant.stderr index a00f7ab30e1..c445b96a90f 100644 --- a/tests/ui/mem_discriminant.stderr +++ b/tests/ui/mem_discriminant.stderr @@ -1,19 +1,19 @@ error: calling `mem::discriminant` on non-enum type `&str` --> $DIR/mem_discriminant.rs:23:5 | -23 | mem::discriminant(&"hello"); +LL | mem::discriminant(&"hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/mem_discriminant.rs:10:9 | -10 | #![deny(clippy::mem_discriminant_non_enum)] +LL | #![deny(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:24:5 | -24 | mem::discriminant(&&Some(2)); +LL | mem::discriminant(&&Some(2)); | ^^^^^^^^^^^^^^^^^^---------^ | | | help: try dereferencing: `&Some(2)` @@ -21,7 +21,7 @@ error: calling `mem::discriminant` on non-enum type `&std::option::Option<i32>` error: calling `mem::discriminant` on non-enum type `&std::option::Option<u8>` --> $DIR/mem_discriminant.rs:25:5 | -25 | mem::discriminant(&&None::<u8>); +LL | mem::discriminant(&&None::<u8>); | ^^^^^^^^^^^^^^^^^^------------^ | | | help: try dereferencing: `&None::<u8>` @@ -29,7 +29,7 @@ error: calling `mem::discriminant` on non-enum type `&std::option::Option<u8>` error: calling `mem::discriminant` on non-enum type `&Foo` --> $DIR/mem_discriminant.rs:26:5 | -26 | mem::discriminant(&&Foo::One(5)); +LL | mem::discriminant(&&Foo::One(5)); | ^^^^^^^^^^^^^^^^^^-------------^ | | | help: try dereferencing: `&Foo::One(5)` @@ -37,7 +37,7 @@ error: calling `mem::discriminant` on non-enum type `&Foo` error: calling `mem::discriminant` on non-enum type `&Foo` --> $DIR/mem_discriminant.rs:27:5 | -27 | mem::discriminant(&&Foo::Two(5)); +LL | mem::discriminant(&&Foo::Two(5)); | ^^^^^^^^^^^^^^^^^^-------------^ | | | help: try dereferencing: `&Foo::Two(5)` @@ -45,13 +45,13 @@ error: calling `mem::discriminant` on non-enum type `&Foo` error: calling `mem::discriminant` on non-enum type `A` --> $DIR/mem_discriminant.rs:28:5 | -28 | mem::discriminant(&A(Foo::One(0))); +LL | mem::discriminant(&A(Foo::One(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:32:5 | -32 | mem::discriminant(&ro); +LL | mem::discriminant(&ro); | ^^^^^^^^^^^^^^^^^^---^ | | | help: try dereferencing: `ro` @@ -59,7 +59,7 @@ error: calling `mem::discriminant` on non-enum type `&std::option::Option<i32>` error: calling `mem::discriminant` on non-enum type `&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:33:5 | -33 | mem::discriminant(rro); +LL | mem::discriminant(rro); | ^^^^^^^^^^^^^^^^^^---^ | | | help: try dereferencing: `*rro` @@ -67,7 +67,7 @@ error: calling `mem::discriminant` on non-enum type `&std::option::Option<i32>` error: calling `mem::discriminant` on non-enum type `&&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:34:5 | -34 | mem::discriminant(&rro); +LL | mem::discriminant(&rro); | ^^^^^^^^^^^^^^^^^^----^ | | | help: try dereferencing: `*rro` @@ -75,10 +75,10 @@ error: calling `mem::discriminant` on non-enum type `&&std::option::Option<i32>` error: calling `mem::discriminant` on non-enum type `&&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:38:13 | -38 | mem::discriminant($param) +LL | mem::discriminant($param) | ^^^^^^^^^^^^^^^^^^^^^^^^^ ... -42 | mem_discriminant_but_in_a_macro!(&rro); +LL | mem_discriminant_but_in_a_macro!(&rro); | --------------------------------------- | | | | | help: try dereferencing: `*rro` @@ -87,7 +87,7 @@ error: calling `mem::discriminant` on non-enum type `&&std::option::Option<i32>` error: calling `mem::discriminant` on non-enum type `&&&&&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:45:5 | -45 | mem::discriminant(&rrrrro); +LL | mem::discriminant(&rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ | | | help: try dereferencing: `****rrrrro` @@ -95,7 +95,7 @@ error: calling `mem::discriminant` on non-enum type `&&&&&std::option::Option<i3 error: calling `mem::discriminant` on non-enum type `&&&std::option::Option<i32>` --> $DIR/mem_discriminant.rs:46:5 | -46 | mem::discriminant(*rrrrro); +LL | mem::discriminant(*rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ | | | help: try dereferencing: `****rrrrro` diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 479cd4934ab..292437d0019 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -1,7 +1,7 @@ error: usage of mem::forget on Drop type --> $DIR/mem_forget.rs:23:5 | -23 | memstuff::forget(six); +LL | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::mem-forget` implied by `-D warnings` @@ -9,13 +9,13 @@ error: usage of mem::forget on Drop type error: usage of mem::forget on Drop type --> $DIR/mem_forget.rs:26:5 | -26 | std::mem::forget(seven); +LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of mem::forget on Drop type --> $DIR/mem_forget.rs:29:5 | -29 | forgetSomething(eight); +LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index 06d8f5f74c0..9092fa2ea14 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -1,7 +1,7 @@ error: replacing an `Option` with `None` --> $DIR/mem_replace.rs:16:13 | -16 | let _ = mem::replace(&mut an_option, None); +LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` | = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings` @@ -9,7 +9,7 @@ error: replacing an `Option` with `None` error: replacing an `Option` with `None` --> $DIR/mem_replace.rs:18:13 | -18 | let _ = mem::replace(an_option, None); +LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: aborting due to 2 previous errors diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 950c49003b6..4f445c924d2 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -1,7 +1,7 @@ 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:38:5 | -38 | pub fn add(self, other: T) -> T { self } +LL | pub fn add(self, other: T) -> T { self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::should-implement-trait` implied by `-D warnings` @@ -9,7 +9,7 @@ error: defining a method called `add` on this type; consider implementing the `s error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name --> $DIR/methods.rs:49:17 | -49 | fn into_u16(&self) -> u16 { 0 } +LL | fn into_u16(&self) -> u16 { 0 } | ^^^^^ | = note: `-D clippy::wrong-self-convention` implied by `-D warnings` @@ -17,389 +17,389 @@ error: methods called `into_*` usually take self by value; consider choosing a l error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name --> $DIR/methods.rs:51:21 | -51 | fn to_something(self) -> u32 { 0 } +LL | fn to_something(self) -> u32 { 0 } | ^^^^ error: methods called `new` usually take no self; consider choosing a less ambiguous name --> $DIR/methods.rs:53:12 | -53 | fn new(self) -> Self { unimplemented!(); } +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:121:13 - | -121 | let _ = opt.map(|x| x + 1) - | _____________^ -122 | | -123 | | .unwrap_or(0); // should lint even though this call is on a separate line - | |____________________________^ - | - = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings` - = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)` + --> $DIR/methods.rs:121:13 + | +LL | let _ = opt.map(|x| x + 1) + | _____________^ +LL | | +LL | | .unwrap_or(0); // should lint even though this call is on a separate line + | |____________________________^ + | + = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings` + = 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:125:13 - | -125 | let _ = opt.map(|x| { - | _____________^ -126 | | x + 1 -127 | | } -128 | | ).unwrap_or(0); - | |____________________________^ + --> $DIR/methods.rs:125:13 + | +LL | let _ = opt.map(|x| { + | _____________^ +LL | | x + 1 +LL | | } +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:129:13 - | -129 | let _ = opt.map(|x| x + 1) - | _____________^ -130 | | .unwrap_or({ -131 | | 0 -132 | | }); - | |__________________^ + --> $DIR/methods.rs:129:13 + | +LL | let _ = opt.map(|x| x + 1) + | _____________^ +LL | | .unwrap_or({ +LL | | 0 +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:134:13 - | -134 | 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))` + --> $DIR/methods.rs:134:13 + | +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:136:13 - | -136 | let _ = opt.map(|x| { - | _____________^ -137 | | Some(x + 1) -138 | | } -139 | | ).unwrap_or(None); - | |_____________________^ + --> $DIR/methods.rs:136:13 + | +LL | let _ = opt.map(|x| { + | _____________^ +LL | | Some(x + 1) +LL | | } +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:140:13 - | -140 | let _ = opt - | _____________^ -141 | | .map(|x| Some(x + 1)) -142 | | .unwrap_or(None); - | |________________________^ - | - = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))` + --> $DIR/methods.rs:140:13 + | +LL | let _ = opt + | _____________^ +LL | | .map(|x| Some(x + 1)) +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:148:13 - | -148 | let _ = opt.map(|x| x + 1) - | _____________^ -149 | | -150 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line - | |____________________________________^ - | - = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings` - = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)` + --> $DIR/methods.rs:148:13 + | +LL | let _ = opt.map(|x| x + 1) + | _____________^ +LL | | +LL | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line + | |____________________________________^ + | + = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings` + = 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:152:13 - | -152 | let _ = opt.map(|x| { - | _____________^ -153 | | x + 1 -154 | | } -155 | | ).unwrap_or_else(|| 0); - | |____________________________________^ + --> $DIR/methods.rs:152:13 + | +LL | let _ = opt.map(|x| { + | _____________^ +LL | | x + 1 +LL | | } +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:156:13 - | -156 | let _ = opt.map(|x| x + 1) - | _____________^ -157 | | .unwrap_or_else(|| -158 | | 0 -159 | | ); - | |_________________^ + --> $DIR/methods.rs:156:13 + | +LL | let _ = opt.map(|x| x + 1) + | _____________^ +LL | | .unwrap_or_else(|| +LL | | 0 +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:165:13 - | -165 | let _ = opt.map_or(None, |x| Some(x + 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))` - | - = note: `-D clippy::option-map-or-none` implied by `-D warnings` + --> $DIR/methods.rs:165:13 + | +LL | let _ = opt.map_or(None, |x| Some(x + 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|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:167:13 - | -167 | let _ = opt.map_or(None, |x| { - | _____________^ -168 | | Some(x + 1) -169 | | } -170 | | ); - | |_________________^ + --> $DIR/methods.rs:167:13 + | +LL | let _ = opt.map_or(None, |x| { + | _____________^ +LL | | Some(x + 1) +LL | | } +LL | | ); + | |_________________^ help: try using and_then instead - | -167 | let _ = opt.and_then(|x| { -168 | Some(x + 1) -169 | }); - | + | +LL | let _ = opt.and_then(|x| { +LL | Some(x + 1) +LL | }); + | 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/methods.rs:180:13 - | -180 | let _ = res.map(|x| x + 1) - | _____________^ -181 | | -182 | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line - | |_____________________________________^ - | - = note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings` - = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)` + --> $DIR/methods.rs:180:13 + | +LL | let _ = res.map(|x| x + 1) + | _____________^ +LL | | +LL | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line + | |_____________________________________^ + | + = note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings` + = 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/methods.rs:184:13 - | -184 | let _ = res.map(|x| { - | _____________^ -185 | | x + 1 -186 | | } -187 | | ).unwrap_or_else(|e| 0); - | |_____________________________________^ + --> $DIR/methods.rs:184:13 + | +LL | let _ = res.map(|x| { + | _____________^ +LL | | x + 1 +LL | | } +LL | | ).unwrap_or_else(|e| 0); + | |_____________________________________^ 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/methods.rs:188:13 - | -188 | let _ = res.map(|x| x + 1) - | _____________^ -189 | | .unwrap_or_else(|e| -190 | | 0 -191 | | ); - | |_________________^ + --> $DIR/methods.rs:188:13 + | +LL | let _ = res.map(|x| x + 1) + | _____________^ +LL | | .unwrap_or_else(|e| +LL | | 0 +LL | | ); + | |_________________^ error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. - --> $DIR/methods.rs:251:13 - | -251 | let _ = v.iter().filter(|&x| *x < 0).next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::filter-next` implied by `-D warnings` - = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)` + --> $DIR/methods.rs:251:13 + | +LL | let _ = v.iter().filter(|&x| *x < 0).next(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::filter-next` implied by `-D warnings` + = 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:254:13 - | -254 | let _ = v.iter().filter(|&x| { - | _____________^ -255 | | *x < 0 -256 | | } -257 | | ).next(); - | |___________________________^ + --> $DIR/methods.rs:254:13 + | +LL | let _ = v.iter().filter(|&x| { + | _____________^ +LL | | *x < 0 +LL | | } +LL | | ).next(); + | |___________________________^ error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:269:13 - | -269 | let _ = v.iter().find(|&x| *x < 0).is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::search-is-some` implied by `-D warnings` - = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)` + --> $DIR/methods.rs:269:13 + | +LL | let _ = v.iter().find(|&x| *x < 0).is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::search-is-some` implied by `-D warnings` + = 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:272:13 - | -272 | let _ = v.iter().find(|&x| { - | _____________^ -273 | | *x < 0 -274 | | } -275 | | ).is_some(); - | |______________________________^ + --> $DIR/methods.rs:272:13 + | +LL | let _ = v.iter().find(|&x| { + | _____________^ +LL | | *x < 0 +LL | | } +LL | | ).is_some(); + | |______________________________^ error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:278:13 - | -278 | let _ = v.iter().position(|&x| x < 0).is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)` + --> $DIR/methods.rs:278:13 + | +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:281:13 - | -281 | let _ = v.iter().position(|&x| { - | _____________^ -282 | | x < 0 -283 | | } -284 | | ).is_some(); - | |______________________________^ + --> $DIR/methods.rs:281:13 + | +LL | let _ = v.iter().position(|&x| { + | _____________^ +LL | | x < 0 +LL | | } +LL | | ).is_some(); + | |______________________________^ error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:287:13 - | -287 | let _ = v.iter().rposition(|&x| x < 0).is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)` + --> $DIR/methods.rs:287:13 + | +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:290:13 - | -290 | let _ = v.iter().rposition(|&x| { - | _____________^ -291 | | x < 0 -292 | | } -293 | | ).is_some(); - | |______________________________^ + --> $DIR/methods.rs:290:13 + | +LL | let _ = v.iter().rposition(|&x| { + | _____________^ +LL | | x < 0 +LL | | } +LL | | ).is_some(); + | |______________________________^ error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:325:22 - | -325 | with_constructor.unwrap_or(make()); - | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)` - | - = note: `-D clippy::or-fun-call` implied by `-D warnings` + --> $DIR/methods.rs:325:22 + | +LL | with_constructor.unwrap_or(make()); + | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(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:328:5 - | -328 | with_new.unwrap_or(Vec::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()` + --> $DIR/methods.rs:328: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:331:21 - | -331 | with_const_args.unwrap_or(Vec::with_capacity(12)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))` + --> $DIR/methods.rs:331: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:334:14 - | -334 | with_err.unwrap_or(make()); - | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())` + --> $DIR/methods.rs:334: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:337:19 - | -337 | with_err_args.unwrap_or(Vec::with_capacity(12)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))` + --> $DIR/methods.rs:337: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:340:5 - | -340 | with_default_trait.unwrap_or(Default::default()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()` + --> $DIR/methods.rs:340: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:343:5 - | -343 | with_default_type.unwrap_or(u64::default()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()` + --> $DIR/methods.rs:343: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:346:14 - | -346 | with_vec.unwrap_or(vec![]); - | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])` + --> $DIR/methods.rs:346: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:351:21 - | -351 | without_default.unwrap_or(Foo::new()); - | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)` + --> $DIR/methods.rs:351: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:354:19 - | -354 | map.entry(42).or_insert(String::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` + --> $DIR/methods.rs:354: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:357:21 - | -357 | btree.entry(42).or_insert(String::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` + --> $DIR/methods.rs:357: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:360:21 - | -360 | let _ = stringy.unwrap_or("".to_owned()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())` + --> $DIR/methods.rs:360: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:371:23 - | -371 | let bad_vec = some_vec.iter().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::iter-nth` implied by `-D warnings` + --> $DIR/methods.rs:371:23 + | +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:372:26 - | -372 | let bad_slice = &some_vec[..].iter().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:372: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:373:31 - | -373 | let bad_boxed_slice = boxed_slice.iter().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:373: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:374:29 - | -374 | let bad_vec_deque = some_vec_deque.iter().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:374: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:379:23 - | -379 | let bad_vec = some_vec.iter_mut().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:379: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:382:26 - | -382 | let bad_slice = &some_vec[..].iter_mut().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:382: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:385:29 - | -385 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:385:29 + | +LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/methods.rs:397:13 - | -397 | let _ = some_vec.iter().skip(42).next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::iter-skip-next` implied by `-D warnings` + --> $DIR/methods.rs:397:13 + | +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/methods.rs:398:13 - | -398 | let _ = some_vec.iter().cycle().skip(42).next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:398: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/methods.rs:399:13 - | -399 | let _ = (1..10).skip(10).next(); - | ^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:399: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/methods.rs:400:14 - | -400 | let _ = &some_vec[..].iter().skip(3).next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/methods.rs:400:14 + | +LL | let _ = &some_vec[..].iter().skip(3).next(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:409:13 - | -409 | let _ = opt.unwrap(); - | ^^^^^^^^^^^^ - | - = note: `-D clippy::option-unwrap-used` implied by `-D warnings` + --> $DIR/methods.rs:409:13 + | +LL | let _ = opt.unwrap(); + | ^^^^^^^^^^^^ + | + = note: `-D clippy::option-unwrap-used` implied by `-D warnings` error: aborting due to 50 previous errors diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index 74a93e350de..a6ad34f02b8 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,7 +1,7 @@ error: this min/max combination leads to constant result --> $DIR/min_max.rs:21:5 | -21 | min(1, max(3, x)); +LL | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::min-max` implied by `-D warnings` @@ -9,37 +9,37 @@ error: this min/max combination leads to constant result error: this min/max combination leads to constant result --> $DIR/min_max.rs:22:5 | -22 | min(max(3, x), 1); +LL | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result --> $DIR/min_max.rs:23:5 | -23 | max(min(x, 1), 3); +LL | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result --> $DIR/min_max.rs:24:5 | -24 | max(3, min(x, 1)); +LL | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result --> $DIR/min_max.rs:26:5 | -26 | my_max(3, my_min(x, 1)); +LL | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result --> $DIR/min_max.rs:38:5 | -38 | min("Apple", max("Zoo", s)); +LL | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result --> $DIR/min_max.rs:39:5 | -39 | max(min(s, "Apple"), "Zoo"); +LL | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index b50305ab9ee..35c12786284 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -1,7 +1,7 @@ error: missing documentation for a type alias --> $DIR/missing-doc.rs:32:1 | -32 | type Typedef = String; +LL | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` @@ -9,250 +9,250 @@ error: missing documentation for a type alias error: missing documentation for a type alias --> $DIR/missing-doc.rs:33:1 | -33 | pub type PubTypedef = String; +LL | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct --> $DIR/missing-doc.rs:35:1 | -35 | / struct Foo { -36 | | a: isize, -37 | | b: isize, -38 | | } +LL | / struct Foo { +LL | | a: isize, +LL | | b: isize, +LL | | } | |_^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:36:5 | -36 | a: isize, +LL | a: isize, | ^^^^^^^^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:37:5 | -37 | b: isize, +LL | b: isize, | ^^^^^^^^ error: missing documentation for a struct --> $DIR/missing-doc.rs:40:1 | -40 | / pub struct PubFoo { -41 | | pub a: isize, -42 | | b: isize, -43 | | } +LL | / pub struct PubFoo { +LL | | pub a: isize, +LL | | b: isize, +LL | | } | |_^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:41:5 | -41 | pub a: isize, +LL | pub a: isize, | ^^^^^^^^^^^^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:42:5 | -42 | b: isize, +LL | b: isize, | ^^^^^^^^ error: missing documentation for a module --> $DIR/missing-doc.rs:51:1 | -51 | mod module_no_dox {} +LL | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module --> $DIR/missing-doc.rs:52:1 | -52 | pub mod pub_module_no_dox {} +LL | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:56:1 | -56 | pub fn foo2() {} +LL | pub fn foo2() {} | ^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:57:1 | -57 | fn foo3() {} +LL | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for a trait --> $DIR/missing-doc.rs:75:1 | -75 | / pub trait C { -76 | | fn foo(&self); -77 | | fn foo_with_impl(&self) {} -78 | | } +LL | / pub trait C { +LL | | fn foo(&self); +LL | | fn foo_with_impl(&self) {} +LL | | } | |_^ error: missing documentation for a trait method --> $DIR/missing-doc.rs:76:5 | -76 | fn foo(&self); +LL | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a trait method --> $DIR/missing-doc.rs:77:5 | -77 | fn foo_with_impl(&self) {} +LL | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type --> $DIR/missing-doc.rs:87:5 | -87 | type AssociatedType; +LL | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type --> $DIR/missing-doc.rs:88:5 | -88 | type AssociatedTypeDef = Self; +LL | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a method --> $DIR/missing-doc.rs:99:5 | -99 | pub fn foo() {} +LL | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:100:5 - | -100 | fn bar() {} - | ^^^^^^^^^^^ + --> $DIR/missing-doc.rs:100:5 + | +LL | fn bar() {} + | ^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:104:5 - | -104 | pub fn foo() {} - | ^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:104:5 + | +LL | pub fn foo() {} + | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:107:5 - | -107 | fn foo2() {} - | ^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:107:5 + | +LL | fn foo2() {} + | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:134:1 - | -134 | / enum Baz { -135 | | BazA { a: isize, b: isize }, -136 | | BarB, -137 | | } - | |_^ + --> $DIR/missing-doc.rs:134:1 + | +LL | / enum Baz { +LL | | BazA { a: isize, b: isize }, +LL | | BarB, +LL | | } + | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:135:5 - | -135 | BazA { a: isize, b: isize }, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:135:5 + | +LL | BazA { a: isize, b: isize }, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:135:12 - | -135 | BazA { a: isize, b: isize }, - | ^^^^^^^^ + --> $DIR/missing-doc.rs:135:12 + | +LL | BazA { a: isize, b: isize }, + | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:135:22 - | -135 | BazA { a: isize, b: isize }, - | ^^^^^^^^ + --> $DIR/missing-doc.rs:135:22 + | +LL | BazA { a: isize, b: isize }, + | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:136:5 - | -136 | BarB, - | ^^^^ + --> $DIR/missing-doc.rs:136:5 + | +LL | BarB, + | ^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:139:1 - | -139 | / pub enum PubBaz { -140 | | PubBazA { a: isize }, -141 | | } - | |_^ + --> $DIR/missing-doc.rs:139:1 + | +LL | / pub enum PubBaz { +LL | | PubBazA { a: isize }, +LL | | } + | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:140:5 - | -140 | PubBazA { a: isize }, - | ^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:140:5 + | +LL | PubBazA { a: isize }, + | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:140:15 - | -140 | PubBazA { a: isize }, - | ^^^^^^^^ + --> $DIR/missing-doc.rs:140:15 + | +LL | PubBazA { a: isize }, + | ^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:160:1 - | -160 | const FOO: u32 = 0; - | ^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:160:1 + | +LL | const FOO: u32 = 0; + | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:167:1 - | -167 | pub const FOO4: u32 = 0; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:167:1 + | +LL | pub const FOO4: u32 = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:169:1 - | -169 | static BAR: u32 = 0; - | ^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:169:1 + | +LL | static BAR: u32 = 0; + | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:176:1 - | -176 | pub static BAR4: u32 = 0; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:176:1 + | +LL | pub static BAR4: u32 = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:178:1 - | -178 | / mod internal_impl { -179 | | /// dox -180 | | pub fn documented() {} -181 | | pub fn undocumented1() {} -... | -190 | | } -191 | | } - | |_^ + --> $DIR/missing-doc.rs:178:1 + | +LL | / mod internal_impl { +LL | | /// dox +LL | | pub fn documented() {} +LL | | pub fn undocumented1() {} +... | +LL | | } +LL | | } + | |_^ error: missing documentation for a function - --> $DIR/missing-doc.rs:181:5 - | -181 | pub fn undocumented1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:181:5 + | +LL | pub fn undocumented1() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:182:5 - | -182 | pub fn undocumented2() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:182:5 + | +LL | pub fn undocumented2() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:183:5 - | -183 | fn undocumented3() {} - | ^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:183:5 + | +LL | fn undocumented3() {} + | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:188:9 - | -188 | pub fn also_undocumented1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:188:9 + | +LL | pub fn also_undocumented1() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:189:9 - | -189 | fn also_undocumented2() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:189:9 + | +LL | fn also_undocumented2() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 39 previous errors diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index 132285a1eaa..efe9a3b1399 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,7 +1,7 @@ error: missing `#[inline]` for a function --> $DIR/missing_inline.rs:40:1 | -40 | pub fn pub_foo() {} // missing #[inline] +LL | pub fn pub_foo() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` @@ -9,31 +9,31 @@ error: missing `#[inline]` for a function error: missing `#[inline]` for a default trait method --> $DIR/missing_inline.rs:56:5 | -56 | fn PubBar_b() {} // missing #[inline] +LL | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:70:5 | -70 | fn PubBar_a() {} // missing #[inline] +LL | fn PubBar_a() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:71:5 | -71 | fn PubBar_b() {} // missing #[inline] +LL | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:72:5 | -72 | fn PubBar_c() {} // missing #[inline] +LL | fn PubBar_c() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:82:5 | -82 | pub fn PubFooImpl() {} // missing #[inline] +LL | pub fn PubFooImpl() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index bf891aa4578..f4d4692e259 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,9 +1,9 @@ error: module has the same name as its containing module --> $DIR/module_inception.rs:14:9 | -14 | / mod bar { -15 | | mod foo {} -16 | | } +LL | / mod bar { +LL | | mod foo {} +LL | | } | |_________^ | = note: `-D clippy::module-inception` implied by `-D warnings` @@ -11,9 +11,9 @@ error: module has the same name as its containing module error: module has the same name as its containing module --> $DIR/module_inception.rs:19:5 | -19 | / mod foo { -20 | | mod bar {} -21 | | } +LL | / mod foo { +LL | | mod bar {} +LL | | } | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/stutter.rs b/tests/ui/module_name_repetitions.rs index 922487d671d..4db4f56de46 100644 --- a/tests/ui/stutter.rs +++ b/tests/ui/module_name_repetitions.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![warn(clippy::stutter)] +#![warn(clippy::module_name_repetitions)] #![allow(dead_code)] mod foo { diff --git a/tests/ui/stutter.stderr b/tests/ui/module_name_repetitions.stderr index 8c2d1d43281..866156e3b74 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/module_name_repetitions.stderr @@ -1,33 +1,33 @@ error: item name starts with its containing module's name - --> $DIR/stutter.rs:15:5 + --> $DIR/module_name_repetitions.rs:15:5 | -15 | pub fn foo_bar() {} +LL | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::stutter` implied by `-D warnings` + = note: `-D clippy::module-name-repetitions` implied by `-D warnings` error: item name ends with its containing module's name - --> $DIR/stutter.rs:16:5 + --> $DIR/module_name_repetitions.rs:16:5 | -16 | pub fn bar_foo() {} +LL | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:17:5 + --> $DIR/module_name_repetitions.rs:17:5 | -17 | pub struct FooCake {} +LL | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name - --> $DIR/stutter.rs:18:5 + --> $DIR/module_name_repetitions.rs:18:5 | -18 | pub enum CakeFoo {} +LL | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:19:5 + --> $DIR/module_name_repetitions.rs:19:5 | -19 | pub struct Foo7Bar; +LL | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index e4d20c5c63c..36f06c74077 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -1,7 +1,7 @@ error: any number modulo 1 will be 0 --> $DIR/modulo_one.rs:14:5 | -14 | 10 % 1; +LL | 10 % 1; | ^^^^^^ | = note: `-D clippy::modulo-one` implied by `-D warnings` diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index db0f05a7fa7..544d1aa5f14 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -1,62 +1,62 @@ error: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:16:39 | -16 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { +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 | -16 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { +LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ error: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:22:25 | -22 | fn ouch(x: &Foo) -> &mut Foo; +LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^^^^^ | note: immutable borrow here --> $DIR/mut_from_ref.rs:22:16 | -22 | fn ouch(x: &Foo) -> &mut Foo; +LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:31:21 | -31 | fn fail(x: &u32) -> &mut u16 { +LL | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here --> $DIR/mut_from_ref.rs:31:12 | -31 | fn fail(x: &u32) -> &mut u16 { +LL | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:35:50 | -35 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { +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 | -35 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { +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 | -39 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { +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 | -39 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { +LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index 626a309a6a9..ed926637563 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,7 +1,7 @@ error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:13:11 | -13 | fn fun(x: &mut &mut u32) -> bool { +LL | fn fun(x: &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ | = note: `-D clippy::mut-mut` implied by `-D warnings` @@ -9,52 +9,52 @@ error: generally you want to avoid `&mut &mut _` if possible error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:29:17 | -29 | let mut x = &mut &mut 1u32; +LL | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:23:9 | -23 | &mut $p +LL | &mut $p | ^^^^^^^ ... -44 | let mut z = mut_ptr!(&mut 3u32); +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 | -31 | let mut y = &mut x; +LL | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:35:32 | -35 | let y: &mut &mut u32 = &mut &mut 2; +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 | -35 | let y: &mut &mut u32 = &mut &mut 2; +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 | -40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; +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 | -40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; +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 | -40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; +LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index 87537d77f44..ce3ae6cb2a5 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -1,7 +1,7 @@ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged --> $DIR/mut_range_bound.rs:25:9 | -25 | m = 5; +LL | m = 5; | ^^^^^ | = note: `-D clippy::mut-range-bound` implied by `-D warnings` @@ -9,25 +9,25 @@ error: attempt to mutate range bound within loop; note that the range of the loo error: attempt to mutate range bound within loop; note that the range of the loop is unchanged --> $DIR/mut_range_bound.rs:32:9 | -32 | m *= 2; +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 | -40 | m = 5; +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 | -41 | n = 7; +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 | -55 | let n = &mut m; // warning +LL | let n = &mut m; // warning | ^ error: aborting due to 5 previous errors diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 1664c1dffed..1fe31e26f6e 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,7 +1,7 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference --> $DIR/mut_reference.rs:26:34 | -26 | takes_an_immutable_reference(&mut 42); +LL | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` @@ -9,13 +9,13 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable error: The function/method `as_ptr` doesn't need a mutable reference --> $DIR/mut_reference.rs:28:12 | -28 | as_ptr(&mut 42); +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 | -32 | my_struct.takes_an_immutable_reference(&mut 42); +LL | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index d6f4f03c323..77a05ca13f4 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,7 +1,7 @@ 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 | -15 | Mutex::new(true); +LL | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-atomic` implied by `-D warnings` @@ -9,31 +9,31 @@ error: Consider using an AtomicBool instead of a Mutex here. If you just want th 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 | -16 | Mutex::new(5usize); +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 | -17 | Mutex::new(9isize); +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 | -19 | Mutex::new(&x as *const u32); +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 | -20 | Mutex::new(&mut x as *mut u32); +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 | -21 | Mutex::new(0u32); +LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-integer` implied by `-D warnings` @@ -41,7 +41,7 @@ error: Consider using an AtomicUsize instead of a Mutex here. If you just want t 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 | -22 | Mutex::new(0i32); +LL | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index df2f80ffd11..a0c4ae9561d 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -1,11 +1,11 @@ error: this if-then-else expression will always return true --> $DIR/needless_bool.rs:40:5 | -40 | / if x { -41 | | true -42 | | } else { -43 | | true -44 | | }; +LL | / if x { +LL | | true +LL | | } else { +LL | | true +LL | | }; | |_____^ | = note: `-D clippy::needless-bool` implied by `-D warnings` @@ -13,128 +13,128 @@ error: this if-then-else expression will always return true error: this if-then-else expression will always return false --> $DIR/needless_bool.rs:45:5 | -45 | / if x { -46 | | false -47 | | } else { -48 | | false -49 | | }; +LL | / if x { +LL | | false +LL | | } else { +LL | | false +LL | | }; | |_____^ error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:50:5 | -50 | / if x { -51 | | true -52 | | } else { -53 | | false -54 | | }; +LL | / if x { +LL | | true +LL | | } else { +LL | | false +LL | | }; | |_____^ help: you can reduce it to: `x` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:55:5 | -55 | / if x { -56 | | false -57 | | } else { -58 | | true -59 | | }; +LL | / if x { +LL | | false +LL | | } else { +LL | | true +LL | | }; | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:60:5 | -60 | / if x && y { -61 | | false -62 | | } else { -63 | | true -64 | | }; +LL | / if x && y { +LL | | false +LL | | } else { +LL | | true +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 | -83 | / if x { -84 | | return true; -85 | | } else { -86 | | return true; -87 | | }; +LL | / if x { +LL | | return true; +LL | | } else { +LL | | return true; +LL | | }; | |_____^ error: this if-then-else expression will always return false --> $DIR/needless_bool.rs:92:5 | -92 | / if x { -93 | | return false; -94 | | } else { -95 | | return false; -96 | | }; +LL | / if x { +LL | | return false; +LL | | } else { +LL | | return false; +LL | | }; | |_____^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:101:5 - | -101 | / if x { -102 | | return true; -103 | | } else { -104 | | return false; -105 | | }; - | |_____^ help: you can reduce it to: `return x` + --> $DIR/needless_bool.rs:101:5 + | +LL | / if x { +LL | | return true; +LL | | } else { +LL | | return false; +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 - | -110 | / if x && y { -111 | | return true; -112 | | } else { -113 | | return false; -114 | | }; - | |_____^ help: you can reduce it to: `return x && y` + --> $DIR/needless_bool.rs:110:5 + | +LL | / if x && y { +LL | | return true; +LL | | } else { +LL | | return false; +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 - | -119 | / if x { -120 | | return false; -121 | | } else { -122 | | return true; -123 | | }; - | |_____^ help: you can reduce it to: `return !x` + --> $DIR/needless_bool.rs:119:5 + | +LL | / if x { +LL | | return false; +LL | | } else { +LL | | return true; +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 - | -128 | / if x && y { -129 | | return false; -130 | | } else { -131 | | return true; -132 | | }; - | |_____^ help: you can reduce it to: `return !(x && y)` + --> $DIR/needless_bool.rs:128:5 + | +LL | / if x && y { +LL | | return false; +LL | | } else { +LL | | return true; +LL | | }; + | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:136:8 - | -136 | if x == true {}; - | ^^^^^^^^^ help: try simplifying it as shown: `x` - | - = note: `-D clippy::bool-comparison` implied by `-D warnings` + --> $DIR/needless_bool.rs:136:8 + | +LL | if x == true {}; + | ^^^^^^^^^ help: try simplifying it as shown: `x` + | + = 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 - | -140 | if x == false {}; - | ^^^^^^^^^^ help: try simplifying it as shown: `!x` + --> $DIR/needless_bool.rs:140: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 - | -150 | if x == true {}; - | ^^^^^^^^^ help: try simplifying it as shown: `x` + --> $DIR/needless_bool.rs:150: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 - | -151 | if x == false {}; - | ^^^^^^^^^^ help: try simplifying it as shown: `!x` + --> $DIR/needless_bool.rs:151:8 + | +LL | if x == false {}; + | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: aborting due to 15 previous errors diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index 42deedfa869..ace40665c0c 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,7 +1,7 @@ error: this expression borrows a reference that is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:22:15 | -22 | let c = x(&&a); +LL | let c = x(&&a); | ^^^ help: change this to: `&a` | = note: `-D clippy::needless-borrow` implied by `-D warnings` @@ -9,19 +9,19 @@ error: this expression borrows a reference that is immediately dereferenced by t error: this pattern creates a reference to a reference --> $DIR/needless_borrow.rs:29:17 | -29 | if let Some(ref cake) = Some(&5) {} +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 | -36 | 46 => &&a, +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 | -58 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` @@ -29,13 +29,13 @@ error: this pattern takes a reference on something that is being de-referenced error: this pattern takes a reference on something that is being de-referenced --> $DIR/needless_borrow.rs:59:30 | -59 | let _ = v.iter().filter(|&ref a| a.is_empty()); +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 | -59 | let _ = v.iter().filter(|&ref a| a.is_empty()); +LL | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ help: change this to: `a` error: aborting due to 6 previous errors diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index 5ec7b9e4f3e..b7ea9499f38 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -1,7 +1,7 @@ error: this pattern takes a reference on something that is being de-referenced --> $DIR/needless_borrowed_ref.rs:14:34 | -14 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` @@ -9,19 +9,19 @@ error: this pattern takes a reference on something that is being de-referenced error: this pattern takes a reference on something that is being de-referenced --> $DIR/needless_borrowed_ref.rs:19:17 | -19 | if let Some(&ref v) = thingy { +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 | -48 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' +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 | -48 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' +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: aborting due to 4 previous errors diff --git a/tests/ui/needless_collect.stderr b/tests/ui/needless_collect.stderr index 39b3aa5470b..c4cb187c34e 100644 --- a/tests/ui/needless_collect.stderr +++ b/tests/ui/needless_collect.stderr @@ -1,7 +1,7 @@ error: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:16:28 | -16 | let len = sample.iter().collect::<Vec<_>>().len(); +LL | let len = sample.iter().collect::<Vec<_>>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` | = note: `-D clippy::needless-collect` implied by `-D warnings` @@ -9,19 +9,19 @@ error: avoid using `collect()` when not needed error: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:17:21 | -17 | if sample.iter().collect::<Vec<_>>().is_empty() { +LL | if sample.iter().collect::<Vec<_>>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.next().is_none()` error: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:20:27 | -20 | sample.iter().cloned().collect::<Vec<_>>().contains(&1); +LL | sample.iter().cloned().collect::<Vec<_>>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.any(|&x| x == 1)` error: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:21:34 | -21 | sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len(); +LL | sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` error: aborting due to 4 previous errors diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 06f63ee496e..60c853c18ad 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -2,10 +2,10 @@ error: This else block is redundant. --> $DIR/needless_continue.rs:36:16 | -36 | } else { +LL | } else { | ________________^ -37 | | continue; -38 | | } +LL | | continue; +LL | | } | |_________^ | = note: `-D clippy::needless-continue` implied by `-D warnings` @@ -39,12 +39,12 @@ error: There is no need for an explicit `else` block for this `if` expression --> $DIR/needless_continue.rs:51:9 | -51 | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { -52 | | continue; -53 | | } else { -54 | | println!("Blabber"); -55 | | println!("Jabber"); -56 | | } +LL | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { +LL | | continue; +LL | | } else { +LL | | println!("Blabber"); +LL | | println!("Jabber"); +LL | | } | |_________^ | = help: Consider dropping the else clause, and moving out the code in the else block, like so: diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index e11aa73db2a..d9ce5909172 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,7 +1,7 @@ error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:24:23 | -24 | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> { +LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> { | ^^^^^^ help: consider changing the type to: `&[T]` | = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` @@ -9,192 +9,192 @@ error: this argument is passed by value, but not consumed in the function body error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:38:11 | -38 | fn bar(x: String, y: Wrapper) { +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 | -38 | fn bar(x: String, y: Wrapper) { +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 | -44 | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, V>(t: T, u: U, v: V) { +LL | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, 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 | -56 | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) { +LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -56 | fn test_match(x: &Option<Option<String>>, y: Option<Option<String>>) { -57 | match *x { +LL | fn test_match(x: &Option<Option<String>>, y: Option<Option<String>>) { +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 | -69 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +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 | -69 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead | -69 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { -70 | let Wrapper(s) = z; // moved -71 | let Wrapper(ref t) = *y; // not moved -72 | let Wrapper(_) = *y; // still not moved +LL | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { +LL | let Wrapper(s) = z; // moved +LL | let Wrapper(ref t) = *y; // not moved +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 | -85 | fn test_blanket_ref<T: Foo, S: Serialize>(_foo: T, _serializable: S) {} +LL | fn test_blanket_ref<T: Foo, S: Serialize>(_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 | -87 | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { +LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { | ^^^^^^ 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 | -87 | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { +LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { | ^^^^^^ help: consider changing the type to | -87 | fn issue_2114(s: String, t: &str, u: Vec<i32>, v: Vec<i32>) { +LL | fn issue_2114(s: String, t: &str, u: Vec<i32>, v: Vec<i32>) { | ^^^^ help: change `t.clone()` to | -89 | let _ = t.to_string(); +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 | -87 | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { +LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec<i32>` error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:87:53 | -87 | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { +LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) { | ^^^^^^^^ help: consider changing the type to | -87 | fn issue_2114(s: String, t: String, u: Vec<i32>, v: &[i32]) { +LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: &[i32]) { | ^^^^^^ help: change `v.clone()` to | -91 | let _ = v.to_owned(); +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 - | -100 | s: String, - | ^^^^^^ help: consider changing the type to: `&str` + --> $DIR/needless_pass_by_value.rs:100: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 - | -101 | t: String, - | ^^^^^^ help: consider taking a reference instead: `&String` + --> $DIR/needless_pass_by_value.rs:101: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 - | -110 | fn baz(&self, _u: U, _s: Self) {} - | ^ help: consider taking a reference instead: `&U` + --> $DIR/needless_pass_by_value.rs:110: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 - | -110 | fn baz(&self, _u: U, _s: Self) {} - | ^^^^ help: consider taking a reference instead: `&Self` + --> $DIR/needless_pass_by_value.rs:110: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 - | -132 | fn bar_copy(x: u32, y: CopyWrapper) { - | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` - | + --> $DIR/needless_pass_by_value.rs:132: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 - | -130 | struct CopyWrapper(u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/needless_pass_by_value.rs:130: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 - | -138 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { - | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` - | + --> $DIR/needless_pass_by_value.rs:138: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 - | -130 | struct CopyWrapper(u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/needless_pass_by_value.rs:130: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 - | -138 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { - | ^^^^^^^^^^^ - | + --> $DIR/needless_pass_by_value.rs:138: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 - | -130 | struct CopyWrapper(u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/needless_pass_by_value.rs:130:1 + | +LL | struct CopyWrapper(u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead - | -138 | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { -139 | let CopyWrapper(s) = z; // moved -140 | let CopyWrapper(ref t) = *y; // not moved -141 | 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 - | -138 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { - | ^^^^^^^^^^^ - | + | +LL | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { +LL | let CopyWrapper(s) = z; // moved +LL | let CopyWrapper(ref t) = *y; // not moved +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 + | +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 - | -130 | struct CopyWrapper(u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/needless_pass_by_value.rs:130:1 + | +LL | struct CopyWrapper(u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead - | -138 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { -139 | let CopyWrapper(s) = *z; // moved - | + | +LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { +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 - | -150 | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {} - | ^ help: consider taking a reference instead: `&S` + --> $DIR/needless_pass_by_value.rs:150: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 - | -155 | fn more_fun(_item: impl Club<'static, i32>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` + --> $DIR/needless_pass_by_value.rs:155:20 + | +LL | fn more_fun(_item: impl Club<'static, i32>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` error: aborting due to 22 previous errors diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index 03a469dfa72..73b1d9841eb 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -1,83 +1,83 @@ error: the loop variable `i` is only used to index `ns`. --> $DIR/needless_range_loop.rs:17:14 | -17 | for i in 3..10 { +LL | for i in 3..10 { | ^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | -17 | for <item> in ns.iter().take(10).skip(3) { +LL | for <item> 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 | -38 | for i in 0..ms.len() { +LL | for i in 0..ms.len() { | ^^^^^^^^^^^ help: consider using an iterator | -38 | for <item> in &mut ms { +LL | for <item> in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `ms`. --> $DIR/needless_range_loop.rs:44:14 | -44 | for i in 0..ms.len() { +LL | for i in 0..ms.len() { | ^^^^^^^^^^^ help: consider using an iterator | -44 | for <item> in &mut ms { +LL | for <item> in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/needless_range_loop.rs:68:14 | -68 | for i in x..x + 4 { +LL | for i in x..x + 4 { | ^^^^^^^^ help: consider using an iterator | -68 | for <item> in vec.iter_mut().skip(x).take(4) { +LL | for <item> 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 | -75 | for i in x..=x + 4 { +LL | for i in x..=x + 4 { | ^^^^^^^^^ help: consider using an iterator | -75 | for <item> in vec.iter_mut().skip(x).take(4 + 1) { +LL | for <item> 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 | -81 | for i in 0..3 { +LL | for i in 0..3 { | ^^^^ help: consider using an iterator | -81 | for <item> in &arr { +LL | for <item> in &arr { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `arr`. --> $DIR/needless_range_loop.rs:85:14 | -85 | for i in 0..2 { +LL | for i in 0..2 { | ^^^^ help: consider using an iterator | -85 | for <item> in arr.iter().take(2) { +LL | for <item> in arr.iter().take(2) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. --> $DIR/needless_range_loop.rs:89:14 | -89 | for i in 1..3 { +LL | for i in 1..3 { | ^^^^ help: consider using an iterator | -89 | for <item> in arr.iter().skip(1) { +LL | for <item> in arr.iter().skip(1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 07d29c19be3..bf1083862ed 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -1,7 +1,7 @@ error: unneeded return statement --> $DIR/needless_return.rs:17:5 | -17 | return true; +LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` | = note: `-D clippy::needless-return` implied by `-D warnings` @@ -9,43 +9,43 @@ error: unneeded return statement error: unneeded return statement --> $DIR/needless_return.rs:21:5 | -21 | return true; +LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:26:9 | -26 | return true; +LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:28:9 | -28 | return false; +LL | return false; | ^^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement --> $DIR/needless_return.rs:34:17 | -34 | true => return false, +LL | true => return false, | ^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement --> $DIR/needless_return.rs:36:13 | -36 | return true; +LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:43:9 | -43 | return true; +LL | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:45:16 | -45 | let _ = || return true; +LL | let _ = || return true; | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: aborting due to 8 previous errors diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index d5cd0e7889a..6c4ea68771b 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,7 +1,7 @@ error: struct update has no effect, all the fields in the struct have already been specified --> $DIR/needless_update.rs:22:23 | -22 | S { a: 1, b: 1, ..base }; +LL | S { a: 1, b: 1, ..base }; | ^^^^ | = note: `-D clippy::needless-update` implied by `-D warnings` diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index ee0f9af6f95..f1df2b1d98a 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,7 +1,7 @@ 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 | -24 | let _not_less = !(a_value < another_value); +LL | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` @@ -9,19 +9,19 @@ error: The use of negated comparison operators on partially ordered types produc 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 | -27 | let _not_less_or_equal = !(a_value <= another_value); +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 | -30 | let _not_greater = !(a_value > another_value); +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 | -33 | let _not_greater_or_equal = !(a_value >= another_value); +LL | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 5e5d1afaafe..4c6d8e8d5dd 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -1,7 +1,7 @@ error: Negation by multiplying with -1 --> $DIR/neg_multiply.rs:36:5 | -36 | x * -1; +LL | x * -1; | ^^^^^^ | = note: `-D clippy::neg-multiply` implied by `-D warnings` @@ -9,7 +9,7 @@ error: Negation by multiplying with -1 error: Negation by multiplying with -1 --> $DIR/neg_multiply.rs:38:5 | -38 | -1 * x; +LL | -1 * x; | ^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 6ef26234d9d..95b1a04e783 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,13 +1,13 @@ error: this loop never actually loops --> $DIR/never_loop.rs:19:5 | -19 | / loop { -20 | | // clippy::never_loop -21 | | x += 1; -22 | | if x == 1 { +LL | / loop { +LL | | // clippy::never_loop +LL | | x += 1; +LL | | if x == 1 { ... | -25 | | break; -26 | | } +LL | | break; +LL | | } | |_____^ | = note: #[deny(clippy::never_loop)] on by default @@ -15,86 +15,86 @@ error: this loop never actually loops error: this loop never actually loops --> $DIR/never_loop.rs:41:5 | -41 | / loop { -42 | | // never loops -43 | | x += 1; -44 | | break; -45 | | } +LL | / loop { +LL | | // never loops +LL | | x += 1; +LL | | break; +LL | | } | |_____^ error: this loop never actually loops --> $DIR/never_loop.rs:61:5 | -61 | / loop { -62 | | // never loops -63 | | while i == 0 { -64 | | // never loops +LL | / loop { +LL | | // never loops +LL | | while i == 0 { +LL | | // never loops ... | -67 | | return; -68 | | } +LL | | return; +LL | | } | |_____^ error: this loop never actually loops --> $DIR/never_loop.rs:63:9 | -63 | / while i == 0 { -64 | | // never loops -65 | | break; -66 | | } +LL | / while i == 0 { +LL | | // never loops +LL | | break; +LL | | } | |_________^ error: this loop never actually loops --> $DIR/never_loop.rs:75:9 | -75 | / loop { -76 | | // never loops -77 | | if x == 5 { -78 | | break; -79 | | } -80 | | continue 'outer; -81 | | } +LL | / loop { +LL | | // never loops +LL | | if x == 5 { +LL | | break; +LL | | } +LL | | continue 'outer; +LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:111:5 - | -111 | / while let Some(y) = x { -112 | | // never loops -113 | | return; -114 | | } - | |_____^ + --> $DIR/never_loop.rs:111:5 + | +LL | / while let Some(y) = x { +LL | | // never loops +LL | | return; +LL | | } + | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:118:5 - | -118 | / for x in 0..10 { -119 | | // never loops -120 | | match x { -121 | | 1 => break, -122 | | _ => return, -123 | | } -124 | | } - | |_____^ + --> $DIR/never_loop.rs:118:5 + | +LL | / for x in 0..10 { +LL | | // never loops +LL | | match x { +LL | | 1 => break, +LL | | _ => return, +LL | | } +LL | | } + | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:166:5 - | -166 | / 'outer: while a { -167 | | // never loops -168 | | while a { -169 | | if a { -... | -174 | | break 'outer; -175 | | } - | |_____^ + --> $DIR/never_loop.rs:166:5 + | +LL | / 'outer: while a { +LL | | // never loops +LL | | while a { +LL | | if a { +... | +LL | | break 'outer; +LL | | } + | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:181:9 - | -181 | / while false { -182 | | break 'label; -183 | | } - | |_________^ + --> $DIR/never_loop.rs:181:9 + | +LL | / while false { +LL | | break 'label; +LL | | } + | |_________^ error: aborting due to 9 previous errors diff --git a/tests/ui/new_ret_no_self.stderr b/tests/ui/new_ret_no_self.stderr index e5911b3d72e..dd5a24bcbe7 100644 --- a/tests/ui/new_ret_no_self.stderr +++ b/tests/ui/new_ret_no_self.stderr @@ -1,9 +1,9 @@ error: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:49:5 | -49 | / pub fn new(_: String) -> impl R<Item = u32> { -50 | | S3 -51 | | } +LL | / pub fn new(_: String) -> impl R<Item = u32> { +LL | | S3 +LL | | } | |_____^ | = note: `-D clippy::new-ret-no-self` implied by `-D warnings` @@ -11,42 +11,42 @@ error: methods called `new` usually return `Self` error: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:81:5 | -81 | / pub fn new() -> u32 { -82 | | unimplemented!(); -83 | | } +LL | / pub fn new() -> u32 { +LL | | unimplemented!(); +LL | | } | |_____^ error: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:90:5 | -90 | / pub fn new(_: String) -> u32 { -91 | | unimplemented!(); -92 | | } +LL | / pub fn new(_: String) -> u32 { +LL | | unimplemented!(); +LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:126:5 - | -126 | / pub fn new() -> (u32, u32) { -127 | | unimplemented!(); -128 | | } - | |_____^ + --> $DIR/new_ret_no_self.rs:126:5 + | +LL | / pub fn new() -> (u32, u32) { +LL | | unimplemented!(); +LL | | } + | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:153:5 - | -153 | / pub fn new() -> *mut V { -154 | | unimplemented!(); -155 | | } - | |_____^ + --> $DIR/new_ret_no_self.rs:153:5 + | +LL | / pub fn new() -> *mut V { +LL | | unimplemented!(); +LL | | } + | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:171:5 - | -171 | / pub fn new() -> Option<u32> { -172 | | unimplemented!(); -173 | | } - | |_____^ + --> $DIR/new_ret_no_self.rs:171:5 + | +LL | / pub fn new() -> Option<u32> { +LL | | unimplemented!(); +LL | | } + | |_____^ error: aborting due to 6 previous errors diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index 2e715a6f8ba..efb8904dc97 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -143,14 +143,18 @@ pub struct Allow(Foo); impl Allow { #[allow(clippy::new_without_default)] - pub fn new() -> Self { unimplemented!() } + pub fn new() -> Self { + unimplemented!() + } } pub struct AllowDerive; impl AllowDerive { #[allow(clippy::new_without_default_derive)] - pub fn new() -> Self { unimplemented!() } + pub fn new() -> Self { + unimplemented!() + } } fn main() {} diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index b37c1e14424..1b35b72a82e 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,45 +1,45 @@ error: you should consider deriving a `Default` implementation for `Foo` --> $DIR/new_without_default.rs:17:5 | -17 | / pub fn new() -> Foo { -18 | | Foo -19 | | } +LL | / pub fn new() -> Foo { +LL | | Foo +LL | | } | |_____^ | = note: `-D clippy::new-without-default-derive` implied by `-D warnings` help: try this | -14 | #[derive(Default)] +LL | #[derive(Default)] | error: you should consider deriving a `Default` implementation for `Bar` --> $DIR/new_without_default.rs:25:5 | -25 | / pub fn new() -> Self { -26 | | Bar -27 | | } +LL | / pub fn new() -> Self { +LL | | Bar +LL | | } | |_____^ help: try this | -22 | #[derive(Default)] +LL | #[derive(Default)] | error: you should consider adding a `Default` implementation for `LtKo<'c>` --> $DIR/new_without_default.rs:89:5 | -89 | / pub fn new() -> LtKo<'c> { -90 | | unimplemented!() -91 | | } +LL | / pub fn new() -> LtKo<'c> { +LL | | unimplemented!() +LL | | } | |_____^ | = note: `-D clippy::new-without-default` implied by `-D warnings` help: try this | -88 | impl Default for LtKo<'c> { -89 | fn default() -> Self { -90 | Self::new() -91 | } -92 | } +LL | impl Default for LtKo<'c> { +LL | fn default() -> Self { +LL | Self::new() +LL | } +LL | } | error: aborting due to 3 previous errors diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index e8a88307c97..cc3b069f0b5 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,7 +1,7 @@ error: statement with no effect --> $DIR/no_effect.rs:74:5 | -74 | 0; +LL | 0; | ^^ | = note: `-D clippy::no-effect` implied by `-D warnings` @@ -9,146 +9,146 @@ error: statement with no effect error: statement with no effect --> $DIR/no_effect.rs:75:5 | -75 | s2; +LL | s2; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:76:5 | -76 | Unit; +LL | Unit; | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:77:5 | -77 | Tuple(0); +LL | Tuple(0); | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:78:5 | -78 | Struct { field: 0 }; +LL | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:79:5 | -79 | Struct { ..s }; +LL | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:80:5 | -80 | Union { a: 0 }; +LL | Union { a: 0 }; | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:81:5 | -81 | Enum::Tuple(0); +LL | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:82:5 | -82 | Enum::Struct { field: 0 }; +LL | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:83:5 | -83 | 5 + 6; +LL | 5 + 6; | ^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:84:5 | -84 | *&42; +LL | *&42; | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:85:5 | -85 | &6; +LL | &6; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:86:5 | -86 | (5, 6, 7); +LL | (5, 6, 7); | ^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:87:5 | -87 | box 42; +LL | box 42; | ^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:88:5 | -88 | ..; +LL | ..; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:89:5 | -89 | 5..; +LL | 5..; | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:90:5 | -90 | ..5; +LL | ..5; | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:91:5 | -91 | 5..6; +LL | 5..6; | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:93:5 | -93 | [42, 55]; +LL | [42, 55]; | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:94:5 | -94 | [42, 55][1]; +LL | [42, 55][1]; | ^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:95:5 | -95 | (42, 55).1; +LL | (42, 55).1; | ^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:96:5 | -96 | [42; 55]; +LL | [42; 55]; | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:97:5 | -97 | [42; 55][13]; +LL | [42; 55][13]; | ^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:99:5 | -99 | || x += 5; +LL | || x += 5; | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:101:5 - | -101 | FooString { s: s }; - | ^^^^^^^^^^^^^^^^^^^ + --> $DIR/no_effect.rs:101:5 + | +LL | FooString { s: s }; + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 25 previous errors diff --git a/tests/ui/non_copy_const.stderr b/tests/ui/non_copy_const.stderr index 6d65f4dca50..6b592b681c9 100644 --- a/tests/ui/non_copy_const.stderr +++ b/tests/ui/non_copy_const.stderr @@ -1,7 +1,7 @@ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:19:1 | -19 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable +LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` @@ -11,7 +11,7 @@ error: a const item should never be interior mutable error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:20:1 | -20 | const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable +LL | const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` @@ -19,7 +19,7 @@ error: a const item should never be interior mutable error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:21:1 | -21 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7); +LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` @@ -27,249 +27,249 @@ error: a const item should never be interior mutable error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:26:9 | -26 | const $name: $ty = $e; +LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ ... -29 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable +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 | -50 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable +LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:54:5 | -54 | const INPUT: T; +LL | const INPUT: T; | ^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` --> $DIR/non_copy_const.rs:54:18 | -54 | const INPUT: T; +LL | const INPUT: T; | ^ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:57:5 | -57 | const ASSOC: Self::NonCopyType; +LL | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `<Self as Trait<T>>::NonCopyType` to be `Copy` --> $DIR/non_copy_const.rs:57:18 | -57 | const ASSOC: Self::NonCopyType; +LL | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:61:5 | -61 | const AN_INPUT: T = Self::INPUT; +LL | const AN_INPUT: T = Self::INPUT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` --> $DIR/non_copy_const.rs:61:21 | -61 | const AN_INPUT: T = Self::INPUT; +LL | const AN_INPUT: T = Self::INPUT; | ^ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:26:9 | -26 | const $name: $ty = $e; +LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ ... -64 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable +LL | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable | ----------------------------------------------- in this macro invocation error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:70:5 | -70 | const SELF_2: Self; +LL | const SELF_2: Self; | ^^^^^^^^^^^^^^^^^^^ | help: consider requiring `Self` to be `Copy` --> $DIR/non_copy_const.rs:70:19 | -70 | const SELF_2: Self; +LL | const SELF_2: Self; | ^^^^ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:91:5 | -91 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable +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 | -94 | const U_SELF: U = U::SELF_2; +LL | const U_SELF: U = U::SELF_2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `U` to be `Copy` --> $DIR/non_copy_const.rs:94:19 | -94 | const U_SELF: U = U::SELF_2; +LL | const U_SELF: U = U::SELF_2; | ^ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:97:5 | -97 | const T_ASSOC: T::NonCopyType = T::ASSOC; +LL | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `<T as Trait<u32>>::NonCopyType` to be `Copy` --> $DIR/non_copy_const.rs:97:20 | -97 | const T_ASSOC: T::NonCopyType = T::ASSOC; +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 - | -104 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability - | ^^^^^^ - | - = note: #[deny(clippy::borrow_interior_mutable_const)] on by default - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:104:5 + | +LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability + | ^^^^^^ + | + = note: #[deny(clippy::borrow_interior_mutable_const)] on by default + = 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 - | -105 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability - | ^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:105:16 + | +LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ 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:107:5 - | -107 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability - | ^^^^^^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:107:5 + | +LL | ATOMIC_USIZE_INIT.store(2, 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:108:16 - | -108 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability - | ^^^^^^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:108:16 + | +LL | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 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:111:22 - | -111 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability - | ^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:111:22 + | +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 - | -112 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability - | ^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:112:25 + | +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 - | -113 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability - | ^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:113:27 + | +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 - | -114 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability - | ^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:114:26 + | +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 - | -125 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:125:14 + | +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 - | -126 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:126:14 + | +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 - | -127 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:127:19 + | +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 - | -128 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:128:14 + | +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 - | -129 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:129:13 + | +LL | let _ = ATOMIC_TUPLE.0[0].load(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:135:13 - | -135 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:135:13 + | +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 - | -140 | CELL.set(2); //~ ERROR interior mutability - | ^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:140:5 + | +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 - | -141 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability - | ^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:141:16 + | +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 - | -154 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability - | ^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:154:5 + | +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 - | -155 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability - | ^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here + --> $DIR/non_copy_const.rs:155:16 + | +LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability + | ^^^^^^^^^^^ + | + = help: assign this const to a local or static variable, and use the variable here error: aborting due to 31 previous errors diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 568ae721588..8729db18dff 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,171 +1,171 @@ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:24:9 | -24 | let bpple: i32; +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 | -22 | let apple: i32; +LL | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `b_pple` --> $DIR/non_expressive_names.rs:24:9 | -24 | let bpple: i32; +LL | let bpple: i32; | ^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:26:9 | -26 | let cpple: i32; +LL | let cpple: i32; | ^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:22:9 | -22 | let apple: i32; +LL | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `c_pple` --> $DIR/non_expressive_names.rs:26:9 | -26 | let cpple: i32; +LL | let cpple: i32; | ^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:50:9 | -50 | let bluby: i32; +LL | let bluby: i32; | ^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:49:9 | -49 | let blubx: i32; +LL | let blubx: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `blub_y` --> $DIR/non_expressive_names.rs:50:9 | -50 | let bluby: i32; +LL | let bluby: i32; | ^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:54:9 | -54 | let coke: i32; +LL | let coke: i32; | ^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:52:9 | -52 | let cake: i32; +LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:72:9 | -72 | let xyzeabc: i32; +LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:70:9 | -70 | let xyz1abc: i32; +LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:76:9 | -76 | let parsee: i32; +LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:74:9 | -74 | let parser: i32; +LL | let parser: i32; | ^^^^^^ help: separate the discriminating character by an underscore like: `parse_e` --> $DIR/non_expressive_names.rs:76:9 | -76 | let parsee: i32; +LL | let parsee: i32; | ^^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:90:16 | -90 | bpple: sprang, +LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:89:16 | -89 | apple: spring, +LL | apple: spring, | ^^^^^^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:125:17 - | -125 | let e: i32; - | ^ - | - = note: `-D clippy::many-single-char-names` implied by `-D warnings` + --> $DIR/non_expressive_names.rs:125:17 + | +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 - | -128 | let e: i32; - | ^ + --> $DIR/non_expressive_names.rs:128:17 + | +LL | let e: i32; + | ^ error: 6th binding whose name is just one char - --> $DIR/non_expressive_names.rs:129:17 - | -129 | let f: i32; - | ^ + --> $DIR/non_expressive_names.rs:129:17 + | +LL | let f: i32; + | ^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:133:13 - | -133 | e => panic!(), - | ^ + --> $DIR/non_expressive_names.rs:133:13 + | +LL | e => panic!(), + | ^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:143:9 - | -143 | let _1 = 1; //~ERROR Consider a more descriptive name - | ^^ - | - = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` + --> $DIR/non_expressive_names.rs:143:9 + | +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 - | -144 | let ____1 = 1; //~ERROR Consider a more descriptive name - | ^^^^^ + --> $DIR/non_expressive_names.rs:144: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 - | -145 | let __1___2 = 12; //~ERROR Consider a more descriptive name - | ^^^^^^^ + --> $DIR/non_expressive_names.rs:145: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 - | -165 | let _1 = 1; - | ^^ + --> $DIR/non_expressive_names.rs:165:13 + | +LL | let _1 = 1; + | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:166:13 - | -166 | let ____1 = 1; - | ^^^^^ + --> $DIR/non_expressive_names.rs:166:13 + | +LL | let ____1 = 1; + | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:167:13 - | -167 | let __1___2 = 12; - | ^^^^^^^ + --> $DIR/non_expressive_names.rs:167:13 + | +LL | let __1___2 = 12; + | ^^^^^^^ error: aborting due to 17 previous errors diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index be013cba459..4ccca10a463 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -1,7 +1,7 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/ok_expect.rs:23:5 | -23 | res.ok().expect("disaster!"); +LL | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::ok-expect` implied by `-D warnings` @@ -9,25 +9,25 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/ok_expect.rs:29:5 | -29 | res3.ok().expect("whoof"); +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 | -31 | res4.ok().expect("argh"); +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 | -33 | res5.ok().expect("oops"); +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 | -35 | res6.ok().expect("meh"); +LL | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index 5dd8ea37f6f..4567493a7c2 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -1,11 +1,11 @@ error: Matching on `Some` with `ok()` is redundant --> $DIR/ok_if_let.rs:13:5 | -13 | / if let Some(y) = x.parse().ok() { -14 | | y -15 | | } else { -16 | | 0 -17 | | } +LL | / if let Some(y) = x.parse().ok() { +LL | | y +LL | | } else { +LL | | 0 +LL | | } | |_____^ | = note: `-D clippy::if-let-some-result` implied by `-D warnings` diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index abe7348622f..956e2ee754c 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -1,19 +1,19 @@ error: needlessly taken reference of both operands --> $DIR/op_ref.rs:19:15 | -19 | let foo = &5 - &6; +LL | let foo = &5 - &6; | ^^^^^^^ | = note: `-D clippy::op-ref` implied by `-D warnings` help: use the values directly | -19 | let foo = 5 - 6; +LL | let foo = 5 - 6; | ^ ^ error: taken reference of right operand --> $DIR/op_ref.rs:27:8 | -27 | if b < &a { +LL | if b < &a { | ^^^^-- | | | help: use the right value directly: `a` diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 10691d65a29..55c0429800b 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,7 +1,7 @@ error: file opened with "truncate" and "read" --> $DIR/open_options.rs:15:5 | -15 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); +LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` @@ -9,37 +9,37 @@ error: file opened with "truncate" and "read" error: file opened with "append" and "truncate" --> $DIR/open_options.rs:16:5 | -16 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); +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 | -18 | OpenOptions::new().read(true).read(false).open("foo.txt"); +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 | -19 | OpenOptions::new().create(true).create(false).open("foo.txt"); +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 | -20 | OpenOptions::new().write(true).write(false).open("foo.txt"); +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 | -21 | OpenOptions::new().append(true).append(false).open("foo.txt"); +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 | -22 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); +LL | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 5df5ae7d918..18ddcec5edd 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Option value where `f` is a unit function --> $DIR/option_map_unit_fn.rs:41:5 | -41 | x.field.map(do_nothing); +LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` @@ -11,7 +11,7 @@ error: called `map(f)` on an Option value where `f` is a unit function error: called `map(f)` on an Option value where `f` is a unit function --> $DIR/option_map_unit_fn.rs:43:5 | -43 | x.field.map(do_nothing); +LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` @@ -19,7 +19,7 @@ error: called `map(f)` on an Option value where `f` is a unit function error: called `map(f)` on an Option value where `f` is a unit function --> $DIR/option_map_unit_fn.rs:45:5 | -45 | x.field.map(diverge); +LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { diverge(...) }` @@ -27,7 +27,7 @@ error: called `map(f)` on an Option value where `f` is a unit function error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:51:5 | -51 | x.field.map(|value| x.do_option_nothing(value + captured)); +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) }` @@ -35,7 +35,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:53:5 | -53 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); +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); }` @@ -43,7 +43,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:56:5 | -56 | x.field.map(|value| do_nothing(value + captured)); +LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` @@ -51,7 +51,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:58:5 | -58 | x.field.map(|value| { do_nothing(value + captured) }); +LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` @@ -59,7 +59,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:60:5 | -60 | x.field.map(|value| { do_nothing(value + captured); }); +LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` @@ -67,7 +67,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:62:5 | -62 | x.field.map(|value| { { do_nothing(value + captured); } }); +LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` @@ -75,7 +75,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:65:5 | -65 | x.field.map(|value| diverge(value + captured)); +LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` @@ -83,7 +83,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:67:5 | -67 | x.field.map(|value| { diverge(value + captured) }); +LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` @@ -91,7 +91,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:69:5 | -69 | x.field.map(|value| { diverge(value + captured); }); +LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` @@ -99,7 +99,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:71:5 | -71 | x.field.map(|value| { { diverge(value + captured); } }); +LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` @@ -107,7 +107,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:76:5 | -76 | x.field.map(|value| { let y = plus_one(value + captured); }); +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); }` @@ -115,7 +115,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:78:5 | -78 | x.field.map(|value| { plus_one(value + captured); }); +LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` @@ -123,7 +123,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:80:5 | -80 | x.field.map(|value| { { plus_one(value + captured); } }); +LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` @@ -131,7 +131,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:83:5 | -83 | x.field.map(|ref value| { do_nothing(value + captured) }); +LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` @@ -139,7 +139,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:86:5 | -86 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); +LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { ... }` @@ -147,7 +147,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:88:5 | -88 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); +LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { ... }` @@ -155,13 +155,13 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:92:5 | -92 | x.field.map(|value| { +LL | x.field.map(|value| { | _____^ | |_____| | || -93 | || do_nothing(value); -94 | || do_nothing(value) -95 | || }); +LL | || do_nothing(value); +LL | || do_nothing(value) +LL | || }); | ||______^- help: try this: `if let Some(value) = x.field { ... }` | |_______| | @@ -169,7 +169,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:96:5 | -96 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); +LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { ... }` @@ -177,34 +177,34 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit function --> $DIR/option_map_unit_fn.rs:99:5 | -99 | Some(42).map(diverge); +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 - | -100 | "12".parse::<i32>().ok().map(diverge); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(_) = "12".parse::<i32>().ok() { diverge(...) }` + --> $DIR/option_map_unit_fn.rs:100:5 + | +LL | "12".parse::<i32>().ok().map(diverge); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(_) = "12".parse::<i32>().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:101:5 - | -101 | Some(plus_one(1)).map(do_nothing); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }` + --> $DIR/option_map_unit_fn.rs:101:5 + | +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 - | -105 | y.map(do_nothing); - | ^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(_y) = y { do_nothing(...) }` + --> $DIR/option_map_unit_fn.rs:105:5 + | +LL | y.map(do_nothing); + | ^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(_y) = y { do_nothing(...) }` error: aborting due to 25 previous errors diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 0689a10231b..992f14c825f 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,7 +1,7 @@ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:10:13 | -10 | fn input(_: Option<Option<u8>>) {} +LL | fn input(_: Option<Option<u8>>) {} | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::option-option` implied by `-D warnings` @@ -9,49 +9,49 @@ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enu error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:12:16 | -12 | fn output() -> Option<Option<u8>> { +LL | fn output() -> Option<Option<u8>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:16:27 | -16 | fn output_nested() -> Vec<Option<Option<u8>>> { +LL | fn output_nested() -> Vec<Option<Option<u8>>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:21:30 | -21 | fn output_nested_nested() -> Option<Option<Option<u8>>> { +LL | fn output_nested_nested() -> Option<Option<Option<u8>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:26:8 | -26 | x: Option<Option<u8>>, +LL | x: Option<Option<u8>>, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:30:23 | -30 | fn struct_fn() -> Option<Option<u8>> { +LL | fn struct_fn() -> Option<Option<u8>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:36:22 | -36 | fn trait_fn() -> Option<Option<u8>>; +LL | fn trait_fn() -> Option<Option<u8>>; | ^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:40:11 | -40 | Tuple(Option<Option<u8>>), +LL | Tuple(Option<Option<u8>>), | ^^^^^^^^^^^^^^^^^^ error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:41:17 | -41 | Struct { x: Option<Option<u8>> }, +LL | Struct { x: Option<Option<u8>> }, | ^^^^^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index 1c15eeaf67b..078a1a5941c 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,7 +1,7 @@ error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:17:8 | -17 | if a + b < a {} +LL | if a + b < a {} | ^^^^^^^^^ | = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` @@ -9,43 +9,43 @@ error: You are trying to use classic C overflow conditions that will fail in Rus error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:18:8 | -18 | if a > a + b {} +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 | -19 | if a + b < b {} +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 | -20 | if b > a + b {} +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 | -21 | if a - b > b {} +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 | -22 | if b < a - b {} +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 | -23 | if a - b > a {} +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 | -24 | if a < a - b {} +LL | if a < a - b {} | ^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/panic_unimplemented.stderr b/tests/ui/panic_unimplemented.stderr index e357050b739..7bc83a287c1 100644 --- a/tests/ui/panic_unimplemented.stderr +++ b/tests/ui/panic_unimplemented.stderr @@ -1,7 +1,7 @@ error: you probably are missing some parameter in your format string --> $DIR/panic_unimplemented.rs:14:16 | -14 | panic!("{}"); +LL | panic!("{}"); | ^^^^ | = note: `-D clippy::panic-params` implied by `-D warnings` @@ -9,25 +9,25 @@ error: you probably are missing some parameter in your format string error: you probably are missing some parameter in your format string --> $DIR/panic_unimplemented.rs:16:16 | -16 | panic!("{:?}"); +LL | panic!("{:?}"); | ^^^^^^ error: you probably are missing some parameter in your format string --> $DIR/panic_unimplemented.rs:18:23 | -18 | assert!(true, "here be missing values: {}"); +LL | assert!(true, "here be missing values: {}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you probably are missing some parameter in your format string --> $DIR/panic_unimplemented.rs:21:12 | -21 | panic!("{{{this}}}"); +LL | panic!("{{{this}}}"); | ^^^^^^^^^^^^ error: `unimplemented` should not be present in production code --> $DIR/panic_unimplemented.rs:64:5 | -64 | unimplemented!(); +LL | unimplemented!(); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unimplemented` implied by `-D warnings` diff --git a/tests/ui/partialeq_ne_impl.rs b/tests/ui/partialeq_ne_impl.rs index fabeee24b30..e1e0413fcea 100644 --- a/tests/ui/partialeq_ne_impl.rs +++ b/tests/ui/partialeq_ne_impl.rs @@ -23,9 +23,13 @@ impl PartialEq for Foo { struct Bar; impl PartialEq for Bar { - fn eq(&self, _: &Bar) -> bool { true } + fn eq(&self, _: &Bar) -> bool { + true + } #[allow(clippy::partialeq_ne_impl)] - fn ne(&self, _: &Bar) -> bool { false } + fn ne(&self, _: &Bar) -> bool { + false + } } fn main() {} diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index d429fba5db0..ac040acc306 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -1,9 +1,9 @@ error: re-implementing `PartialEq::ne` is unnecessary --> $DIR/partialeq_ne_impl.rs:18:5 | -18 | / fn ne(&self, _: &Foo) -> bool { -19 | | false -20 | | } +LL | / fn ne(&self, _: &Foo) -> bool { +LL | | false +LL | | } | |_____^ | = note: `-D clippy::partialeq-ne-impl` implied by `-D warnings` diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index b97709d2ae9..74e8b9ae776 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -1,7 +1,7 @@ error: the `y @ _` pattern can be written as just `y` --> $DIR/patterns.rs:17:9 | -17 | y @ _ => (), +LL | y @ _ => (), | ^^^^^ | = note: `-D clippy::redundant-pattern` implied by `-D warnings` diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 8601f828ef3..2d917b3cbdb 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,7 +1,7 @@ error: operator precedence can trip the unwary --> $DIR/precedence.rs:24:5 | -24 | 1 << 2 + 3; +LL | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` | = note: `-D clippy::precedence` implied by `-D warnings` @@ -9,49 +9,49 @@ error: operator precedence can trip the unwary error: operator precedence can trip the unwary --> $DIR/precedence.rs:25:5 | -25 | 1 + 2 << 3; +LL | 1 + 2 << 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` error: operator precedence can trip the unwary --> $DIR/precedence.rs:26:5 | -26 | 4 >> 1 + 1; +LL | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:27:5 | -27 | 1 + 3 >> 2; +LL | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` error: operator precedence can trip the unwary --> $DIR/precedence.rs:28:5 | -28 | 1 ^ 1 - 1; +LL | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:29:5 | -29 | 3 | 2 - 1; +LL | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:30:5 | -30 | 3 & 5 - 2; +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 | -31 | -1i32.abs(); +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 | -32 | -1f32.abs(); +LL | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` error: aborting due to 9 previous errors diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 199f76568f0..9635011b906 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -1,7 +1,7 @@ error: use of `Debug`-based formatting --> $DIR/print.rs:20:19 | -20 | write!(f, "{:?}", 43.1415) +LL | write!(f, "{:?}", 43.1415) | ^^^^^^ | = note: `-D clippy::use-debug` implied by `-D warnings` @@ -9,13 +9,13 @@ error: use of `Debug`-based formatting error: use of `Debug`-based formatting --> $DIR/print.rs:27:19 | -27 | write!(f, "{:?}", 42.718) +LL | write!(f, "{:?}", 42.718) | ^^^^^^ error: use of `println!` --> $DIR/print.rs:32:5 | -32 | println!("Hello"); +LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-stdout` implied by `-D warnings` @@ -23,37 +23,37 @@ error: use of `println!` error: use of `print!` --> $DIR/print.rs:33:5 | -33 | print!("Hello"); +LL | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` --> $DIR/print.rs:35:5 | -35 | print!("Hello {}", "World"); +LL | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` --> $DIR/print.rs:37:5 | -37 | print!("Hello {:?}", "World"); +LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting --> $DIR/print.rs:37:12 | -37 | print!("Hello {:?}", "World"); +LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^ error: use of `print!` --> $DIR/print.rs:39:5 | -39 | print!("Hello {:#?}", "#orld"); +LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting --> $DIR/print.rs:39:12 | -39 | print!("Hello {:#?}", "#orld"); +LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index cba5cc19eac..be55795d1ac 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,7 +1,7 @@ error: literal with an empty format string --> $DIR/print_literal.rs:31:71 | -31 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); +LL | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D clippy::print-literal` implied by `-D warnings` @@ -9,79 +9,79 @@ error: literal with an empty format string error: literal with an empty format string --> $DIR/print_literal.rs:32:24 | -32 | print!("Hello {}", "world"); +LL | print!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:33:36 | -33 | println!("Hello {} {}", world, "world"); +LL | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:34:26 | -34 | println!("Hello {}", "world"); +LL | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:35:30 | -35 | println!("10 / 4 is {}", 2.5); +LL | println!("10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string --> $DIR/print_literal.rs:36:28 | -36 | println!("2 + 1 = {}", 3); +LL | println!("2 + 1 = {}", 3); | ^ error: literal with an empty format string --> $DIR/print_literal.rs:41:25 | -41 | println!("{0} {1}", "hello", "world"); +LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:41:34 | -41 | println!("{0} {1}", "hello", "world"); +LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:42:25 | -42 | println!("{1} {0}", "hello", "world"); +LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:42:34 | -42 | println!("{1} {0}", "hello", "world"); +LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:45:35 | -45 | println!("{foo} {bar}", foo = "hello", bar = "world"); +LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:45:50 | -45 | println!("{foo} {bar}", foo = "hello", bar = "world"); +LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:46:35 | -46 | println!("{bar} {foo}", foo = "hello", bar = "world"); +LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/print_literal.rs:46:50 | -46 | println!("{bar} {foo}", foo = "hello", bar = "world"); +LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 639a4271110..2d76e447145 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,7 +1,7 @@ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:14:5 | -14 | print!("Hello/n"); +LL | print!("Hello/n"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-with-newline` implied by `-D warnings` @@ -9,19 +9,19 @@ error: using `print!()` with a format string that ends in a single newline, cons error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:15:5 | -15 | print!("Hello {}/n", "world"); +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 | -16 | print!("Hello {} {}/n", "world", "#2"); +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 | -17 | print!("{}/n", 1265); +LL | print!("{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index 9a08150d627..89447040a33 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -1,7 +1,7 @@ error: using `println!("")` --> $DIR/println_empty_string.rs:12:5 | -12 | println!(""); +LL | println!(""); | ^^^^^^^^^^^^ help: replace it with: `println!()` | = note: `-D clippy::println-empty-string` implied by `-D warnings` @@ -9,7 +9,7 @@ error: using `println!("")` error: using `println!("")` --> $DIR/println_empty_string.rs:15:14 | -15 | _ => println!(""), +LL | _ => println!(""), | ^^^^^^^^^^^^ help: replace it with: `println!()` error: aborting due to 2 previous errors diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index c9e8292795f..af5003c9b95 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,7 +1,7 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. --> $DIR/ptr_arg.rs:15:14 | -15 | fn do_vec(x: &Vec<i64>) { +LL | fn do_vec(x: &Vec<i64>) { | ^^^^^^^^^ help: change this to: `&[i64]` | = note: `-D clippy::ptr-arg` implied by `-D warnings` @@ -9,77 +9,77 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and canno error: writing `&String` instead of `&str` involves a new object where a slice will do. --> $DIR/ptr_arg.rs:24:14 | -24 | fn do_str(x: &String) { +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 | -37 | fn do_vec(x: &Vec<i64>); +LL | fn do_vec(x: &Vec<i64>); | ^^^^^^^^^ 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 | -50 | fn cloned(x: &Vec<u8>) -> Vec<u8> { +LL | fn cloned(x: &Vec<u8>) -> Vec<u8> { | ^^^^^^^^ help: change this to | -50 | fn cloned(x: &[u8]) -> Vec<u8> { +LL | fn cloned(x: &[u8]) -> Vec<u8> { | ^^^^^ help: change `x.clone()` to | -51 | let e = x.to_owned(); +LL | let e = x.to_owned(); | ^^^^^^^^^^^^ help: change `x.clone()` to | -56 | x.to_owned() +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 | -59 | fn str_cloned(x: &String) -> String { +LL | fn str_cloned(x: &String) -> String { | ^^^^^^^ help: change this to | -59 | fn str_cloned(x: &str) -> String { +LL | fn str_cloned(x: &str) -> String { | ^^^^ help: change `x.clone()` to | -60 | let a = x.to_string(); +LL | let a = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -61 | let b = x.to_string(); +LL | let b = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -64 | x.to_string() +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 | -67 | fn false_positive_capacity(x: &Vec<u8>, y: &String) { +LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) { | ^^^^^^^ help: change this to | -67 | fn false_positive_capacity(x: &Vec<u8>, y: &str) { +LL | fn false_positive_capacity(x: &Vec<u8>, y: &str) { | ^^^^ help: change `y.clone()` to | -69 | let b = y.to_string(); +LL | let b = y.to_string(); | ^^^^^^^^^^^^^ help: change `y.as_str()` to | -70 | let c = y; +LL | let c = y; | ^ error: using a reference to `Cow` is not recommended. --> $DIR/ptr_arg.rs:81:25 | -81 | fn test_cow_with_ref(c: &Cow<[i32]>) {} +LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` error: aborting due to 7 previous errors diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index c9bd4d79460..d1795f439b2 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -1,7 +1,7 @@ error: use of `offset` with a `usize` casted to an `isize` --> $DIR/ptr_offset_with_cast.rs:19:9 | -19 | ptr.offset(offset_usize as isize); +LL | ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` | = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` @@ -9,7 +9,7 @@ error: use of `offset` with a `usize` casted to an `isize` error: use of `wrapping_offset` with a `usize` casted to an `isize` --> $DIR/ptr_offset_with_cast.rs:23:9 | -23 | ptr.wrapping_offset(offset_usize as isize); +LL | ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` error: aborting due to 2 previous errors diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index f55a83d43c8..a0b87813770 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -1,9 +1,9 @@ error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:11:5 | -11 | / if a.is_none() { -12 | | return None; -13 | | } +LL | / if a.is_none() { +LL | | return None; +LL | | } | |_____^ help: replace_it_with: `a?;` | = note: `-D clippy::question-mark` implied by `-D warnings` @@ -11,52 +11,52 @@ error: this block may be rewritten with the `?` operator error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:56:9 | -56 | / if (self.opt).is_none() { -57 | | return None; -58 | | } +LL | / if (self.opt).is_none() { +LL | | return None; +LL | | } | |_________^ help: replace_it_with: `(self.opt)?;` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:60:9 | -60 | / if self.opt.is_none() { -61 | | return None -62 | | } +LL | / if self.opt.is_none() { +LL | | return None +LL | | } | |_________^ help: replace_it_with: `self.opt?;` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:64:17 | -64 | let _ = if self.opt.is_none() { +LL | let _ = if self.opt.is_none() { | _________________^ -65 | | return None; -66 | | } else { -67 | | self.opt -68 | | }; +LL | | return None; +LL | | } else { +LL | | self.opt +LL | | }; | |_________^ help: replace_it_with: `Some(self.opt?)` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:81:9 | -81 | / if self.opt.is_none() { -82 | | return None; -83 | | } +LL | / if self.opt.is_none() { +LL | | return None; +LL | | } | |_________^ help: replace_it_with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:89:9 | -89 | / if self.opt.is_none() { -90 | | return None; -91 | | } +LL | / if self.opt.is_none() { +LL | | return None; +LL | | } | |_________^ help: replace_it_with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:97:9 | -97 | / if self.opt.is_none() { -98 | | return None; -99 | | } +LL | / if self.opt.is_none() { +LL | | return None; +LL | | } | |_________^ help: replace_it_with: `self.opt.as_ref()?;` error: aborting due to 7 previous errors diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 7b3c5ebc3e1..b9a0a10c207 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,7 +1,7 @@ error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:17:13 | -17 | let _ = (0..1).step_by(0); +LL | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` @@ -9,25 +9,25 @@ error: Iterator::step_by(0) will panic at runtime error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:21:13 | -21 | let _ = (1..).step_by(0); +LL | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:22:13 | -22 | let _ = (1..=2).step_by(0); +LL | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:25:13 | -25 | let _ = x.step_by(0); +LL | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: It is more idiomatic to use v1.iter().enumerate() --> $DIR/range.rs:33:14 | -33 | let _x = v1.iter().zip(0..v1.len()); +LL | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::range-zip-with-len` implied by `-D warnings` @@ -35,7 +35,7 @@ error: It is more idiomatic to use v1.iter().enumerate() error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:37:13 | -37 | let _ = v1.iter().step_by(2 / 3); +LL | let _ = v1.iter().step_by(2 / 3); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index dc49420ecb9..b1c93933ccc 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,7 +1,7 @@ error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:19:14 | -19 | for _ in 0..3 + 1 {} +LL | for _ in 0..3 + 1 {} | ^^^^^^^^ help: use: `0..=3` | = note: `-D clippy::range-plus-one` implied by `-D warnings` @@ -9,25 +9,25 @@ error: an inclusive range would be more readable error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:22:14 | -22 | for _ in 0..1 + 5 {} +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 | -25 | for _ in 1..1 + 1 {} +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 | -31 | for _ in 0..(1 + f()) {} +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 | -35 | let _ = ..=11 - 1; +LL | let _ = ..=11 - 1; | ^^^^^^^^^ help: use: `..11` | = note: `-D clippy::range-minus-one` implied by `-D warnings` @@ -35,19 +35,19 @@ error: an exclusive range would be more readable error: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:36:13 | -36 | let _ = ..=(11 - 1); +LL | let _ = ..=(11 - 1); | ^^^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:37:13 | -37 | let _ = (1..11 + 1); +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 | -38 | let _ = (f() + 1)..(f() + 1); +LL | let _ = (f() + 1)..(f() + 1); | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` error: aborting due to 8 previous errors diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index 07cba0181fd..aef6b9b3d2f 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -1,122 +1,122 @@ error: redundant clone --> $DIR/redundant_clone.rs:16:41 | -16 | let _ = ["lorem", "ipsum"].join(" ").to_string(); +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 | -16 | let _ = ["lorem", "ipsum"].join(" ").to_string(); +LL | let _ = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone --> $DIR/redundant_clone.rs:19:14 | -19 | let _ = s.clone(); +LL | let _ = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:19:13 | -19 | let _ = s.clone(); +LL | let _ = s.clone(); | ^ error: redundant clone --> $DIR/redundant_clone.rs:22:14 | -22 | let _ = s.to_string(); +LL | let _ = s.to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:22:13 | -22 | let _ = s.to_string(); +LL | let _ = s.to_string(); | ^ error: redundant clone --> $DIR/redundant_clone.rs:25:14 | -25 | let _ = s.to_owned(); +LL | let _ = s.to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:25:13 | -25 | let _ = s.to_owned(); +LL | let _ = s.to_owned(); | ^ error: redundant clone --> $DIR/redundant_clone.rs:27:41 | -27 | let _ = Path::new("/a/b/").join("c").to_owned(); +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 | -27 | let _ = Path::new("/a/b/").join("c").to_owned(); +LL | let _ = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone --> $DIR/redundant_clone.rs:29:41 | -29 | let _ = Path::new("/a/b/").join("c").to_path_buf(); +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 | -29 | let _ = Path::new("/a/b/").join("c").to_path_buf(); +LL | let _ = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone --> $DIR/redundant_clone.rs:31:28 | -31 | let _ = OsString::new().to_owned(); +LL | let _ = OsString::new().to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:31:13 | -31 | let _ = OsString::new().to_owned(); +LL | let _ = OsString::new().to_owned(); | ^^^^^^^^^^^^^^^ error: redundant clone --> $DIR/redundant_clone.rs:33:28 | -33 | let _ = OsString::new().to_os_string(); +LL | let _ = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:33:13 | -33 | let _ = OsString::new().to_os_string(); +LL | let _ = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ error: redundant clone --> $DIR/redundant_clone.rs:40:18 | -40 | let _ = tup.0.clone(); +LL | let _ = tup.0.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:40:13 | -40 | let _ = tup.0.clone(); +LL | let _ = tup.0.clone(); | ^^^^^ error: redundant clone --> $DIR/redundant_clone.rs:50:22 | -50 | (a.clone(), a.clone()) +LL | (a.clone(), a.clone()) | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> $DIR/redundant_clone.rs:50:21 | -50 | (a.clone(), a.clone()) +LL | (a.clone(), a.clone()) | ^ error: aborting due to 10 previous errors diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 0d49f1a4066..6a41a07bd95 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -1,7 +1,7 @@ error: Closure called just once immediately after it was declared --> $DIR/redundant_closure_call.rs:21:5 | -21 | i = closure(); +LL | i = closure(); | ^^^^^^^^^^^^^ | = note: `-D clippy::redundant-closure-call` implied by `-D warnings` @@ -9,25 +9,25 @@ error: Closure called just once immediately after it was declared error: Closure called just once immediately after it was declared --> $DIR/redundant_closure_call.rs:24:5 | -24 | i = closure(3); +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 | -13 | let a = (|| 42)(); +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 | -16 | let mut k = (|m| m + 1)(i); +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 | -18 | k = (|a, b| a * b)(1, 5); +LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index 3d727ee6e6a..60569372e5d 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -70,8 +70,7 @@ fn main() { } fn issue_3476() { - fn foo<T>() { - } + fn foo<T>() {} struct S { foo: fn(), diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 7febaa61b71..5675f8beb7a 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,7 +1,7 @@ error: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:43:9 | -43 | gender: gender, +LL | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` | = note: `-D clippy::redundant-field-names` implied by `-D warnings` @@ -9,37 +9,37 @@ error: redundant field names in struct initialization error: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:44:9 | -44 | age: age, +LL | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:65:25 | -65 | let _ = RangeFrom { start: start }; +LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:66:23 | -66 | let _ = RangeTo { end: end }; +LL | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:67:21 | -67 | let _ = Range { start: start, end: end }; +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 | -67 | let _ = Range { start: start, end: end }; +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 | -69 | let _ = RangeToInclusive { end: end }; +LL | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: aborting due to 7 previous errors diff --git a/tests/ui/redundant_pattern_matching.stderr b/tests/ui/redundant_pattern_matching.stderr index 2d2aa88d76d..0511fbc7e09 100644 --- a/tests/ui/redundant_pattern_matching.stderr +++ b/tests/ui/redundant_pattern_matching.stderr @@ -1,7 +1,7 @@ error: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching.rs:14:12 | -14 | if let Ok(_) = Ok::<i32, i32>(42) {} +LL | if let Ok(_) = Ok::<i32, i32>(42) {} | -------^^^^^------------------------ help: try this: `if Ok::<i32, i32>(42).is_ok()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` @@ -9,73 +9,73 @@ error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching.rs:16:12 | -16 | if let Err(_) = Err::<i32, i32>(42) {} +LL | if let Err(_) = Err::<i32, i32>(42) {} | -------^^^^^^------------------------- help: try this: `if Err::<i32, i32>(42).is_err()` error: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching.rs:18:12 | -18 | if let None = None::<()> {} +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 | -20 | if let Some(_) = Some(42) {} +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 | -34 | / match Ok::<i32, i32>(42) { -35 | | Ok(_) => true, -36 | | Err(_) => false, -37 | | }; +LL | / match Ok::<i32, i32>(42) { +LL | | Ok(_) => true, +LL | | Err(_) => false, +LL | | }; | |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()` error: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching.rs:39:5 | -39 | / match Ok::<i32, i32>(42) { -40 | | Ok(_) => false, -41 | | Err(_) => true, -42 | | }; +LL | / match Ok::<i32, i32>(42) { +LL | | Ok(_) => false, +LL | | Err(_) => true, +LL | | }; | |_____^ help: try this: `Ok::<i32, i32>(42).is_err()` error: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching.rs:44:5 | -44 | / match Err::<i32, i32>(42) { -45 | | Ok(_) => false, -46 | | Err(_) => true, -47 | | }; +LL | / match Err::<i32, i32>(42) { +LL | | Ok(_) => false, +LL | | Err(_) => true, +LL | | }; | |_____^ help: try this: `Err::<i32, i32>(42).is_err()` error: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching.rs:49:5 | -49 | / match Err::<i32, i32>(42) { -50 | | Ok(_) => true, -51 | | Err(_) => false, -52 | | }; +LL | / match Err::<i32, i32>(42) { +LL | | Ok(_) => true, +LL | | Err(_) => false, +LL | | }; | |_____^ help: try this: `Err::<i32, i32>(42).is_ok()` error: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching.rs:54:5 | -54 | / match Some(42) { -55 | | Some(_) => true, -56 | | None => false, -57 | | }; +LL | / match Some(42) { +LL | | Some(_) => true, +LL | | None => false, +LL | | }; | |_____^ help: try this: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching.rs:59:5 | -59 | / match None::<()> { -60 | | Some(_) => false, -61 | | None => true, -62 | | }; +LL | / match None::<()> { +LL | | Some(_) => false, +LL | | None => true, +LL | | }; | |_____^ help: try this: `None::<()>.is_none()` error: aborting due to 10 previous errors diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 7665e0d1932..eaaacc7bcbe 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -1,7 +1,7 @@ error: immediately dereferencing a reference --> $DIR/reference.rs:25:13 | -25 | let b = *&a; +LL | let b = *&a; | ^^^ help: try this: `a` | = note: `-D clippy::deref-addrof` implied by `-D warnings` @@ -9,61 +9,61 @@ error: immediately dereferencing a reference error: immediately dereferencing a reference --> $DIR/reference.rs:27:13 | -27 | let b = *&get_number(); +LL | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try this: `get_number()` error: immediately dereferencing a reference --> $DIR/reference.rs:32:13 | -32 | let b = *&bytes[1..2][0]; +LL | let b = *&bytes[1..2][0]; | ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]` error: immediately dereferencing a reference --> $DIR/reference.rs:36:13 | -36 | let b = *&(a); +LL | let b = *&(a); | ^^^^^ help: try this: `(a)` error: immediately dereferencing a reference --> $DIR/reference.rs:38:13 | -38 | let b = *(&a); +LL | let b = *(&a); | ^^^^^ help: try this: `a` error: immediately dereferencing a reference --> $DIR/reference.rs:41:13 | -41 | let b = *((&a)); +LL | let b = *((&a)); | ^^^^^^^ help: try this: `a` error: immediately dereferencing a reference --> $DIR/reference.rs:43:13 | -43 | let b = *&&a; +LL | let b = *&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference --> $DIR/reference.rs:45:14 | -45 | let b = **&aref; +LL | let b = **&aref; | ^^^^^^ help: try this: `aref` error: immediately dereferencing a reference --> $DIR/reference.rs:49:14 | -49 | let b = **&&a; +LL | let b = **&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference --> $DIR/reference.rs:53:17 | -53 | let y = *&mut x; +LL | let y = *&mut x; | ^^^^^^^ help: try this: `x` error: immediately dereferencing a reference --> $DIR/reference.rs:60:18 | -60 | let y = **&mut &mut x; +LL | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` error: aborting due to 11 previous errors diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 680cc5146e5..b6a4f6eb2af 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -1,7 +1,7 @@ error: trivial regex --> $DIR/regex.rs:22:45 | -22 | let pipe_in_wrong_position = Regex::new("|"); +LL | let pipe_in_wrong_position = Regex::new("|"); | ^^^ | = note: `-D clippy::trivial-regex` implied by `-D warnings` @@ -10,7 +10,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:23:60 | -23 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); +LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is @@ -18,7 +18,7 @@ error: trivial regex error: regex syntax error: invalid character class range, the start must be <= the end --> $DIR/regex.rs:24:42 | -24 | let wrong_char_ranice = Regex::new("[z-a]"); +LL | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ | = note: `-D clippy::invalid-regex` implied by `-D warnings` @@ -26,19 +26,19 @@ error: regex syntax error: invalid character class range, the start must be <= t error: regex syntax error: invalid character class range, the start must be <= the end --> $DIR/regex.rs:25:37 | -25 | let some_unicode = Regex::new("[é-è]"); +LL | let some_unicode = Regex::new("[é-è]"); | ^^^ error: regex syntax error on position 0: unclosed group --> $DIR/regex.rs:27:33 | -27 | let some_regex = Regex::new(OPENING_PAREN); +LL | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: trivial regex --> $DIR/regex.rs:29:53 | -29 | let binary_pipe_in_wrong_position = BRegex::new("|"); +LL | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is @@ -46,43 +46,43 @@ error: trivial regex error: regex syntax error on position 0: unclosed group --> $DIR/regex.rs:30:41 | -30 | let some_binary_regex = BRegex::new(OPENING_PAREN); +LL | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group --> $DIR/regex.rs:31:56 | -31 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); +LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group --> $DIR/regex.rs:43:37 | -43 | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); +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 | -44 | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); +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 | -46 | let raw_string_error = Regex::new(r"[...//...]"); +LL | let raw_string_error = Regex::new(r"[...//...]"); | ^^ error: regex syntax error: unrecognized escape sequence --> $DIR/regex.rs:47:46 | -47 | let raw_string_error = Regex::new(r#"[...//...]"#); +LL | let raw_string_error = Regex::new(r#"[...//...]"#); | ^^ error: trivial regex --> $DIR/regex.rs:51:33 | -51 | let trivial_eq = Regex::new("^foobar$"); +LL | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using `==` on `str`s @@ -90,7 +90,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:53:48 | -53 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); +LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using `==` on `str`s @@ -98,7 +98,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:55:42 | -55 | let trivial_starts_with = Regex::new("^foobar"); +LL | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ | = help: consider using `str::starts_with` @@ -106,7 +106,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:57:40 | -57 | let trivial_ends_with = Regex::new("foobar$"); +LL | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ | = help: consider using `str::ends_with` @@ -114,7 +114,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:59:39 | -59 | let trivial_contains = Regex::new("foobar"); +LL | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ | = help: consider using `str::contains` @@ -122,7 +122,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:61:39 | -61 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); +LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ | = help: consider using `str::contains` @@ -130,7 +130,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:63:40 | -63 | let trivial_backslash = Regex::new("a/.b"); +LL | let trivial_backslash = Regex::new("a/.b"); | ^^^^^^^ | = help: consider using `str::contains` @@ -138,7 +138,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:66:36 | -66 | let trivial_empty = Regex::new(""); +LL | let trivial_empty = Regex::new(""); | ^^ | = help: the regex is unlikely to be useful as it is @@ -146,7 +146,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:68:36 | -68 | let trivial_empty = Regex::new("^"); +LL | let trivial_empty = Regex::new("^"); | ^^^ | = help: the regex is unlikely to be useful as it is @@ -154,7 +154,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:70:36 | -70 | let trivial_empty = Regex::new("^$"); +LL | let trivial_empty = Regex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` @@ -162,7 +162,7 @@ error: trivial regex error: trivial regex --> $DIR/regex.rs:72:44 | -72 | let binary_trivial_empty = BRegex::new("^$"); +LL | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs new file mode 100644 index 00000000000..8d76a2d4586 --- /dev/null +++ b/tests/ui/rename.rs @@ -0,0 +1,13 @@ +// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(stutter)] + +#[warn(clippy::stutter)] +fn main() {} diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr new file mode 100644 index 00000000000..1efc66d442f --- /dev/null +++ b/tests/ui/rename.stderr @@ -0,0 +1,18 @@ +error: unknown lint: `stutter` + --> $DIR/rename.rs:10:10 + | +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 + | +LL | #[warn(clippy::stutter)] + | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` + | + = note: `-D renamed-and-removed-lints` implied by `-D warnings` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/replace_consts.stderr b/tests/ui/replace_consts.stderr index 401e3a527a6..e45f490463c 100644 --- a/tests/ui/replace_consts.stderr +++ b/tests/ui/replace_consts.stderr @@ -1,217 +1,217 @@ error: using `ATOMIC_BOOL_INIT` --> $DIR/replace_consts.rs:22:17 | -22 | { let foo = ATOMIC_BOOL_INIT; }; +LL | { let foo = ATOMIC_BOOL_INIT; }; | ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)` | note: lint level defined here --> $DIR/replace_consts.rs:12:9 | -12 | #![deny(clippy::replace_consts)] +LL | #![deny(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ error: using `ATOMIC_ISIZE_INIT` --> $DIR/replace_consts.rs:23:17 | -23 | { let foo = ATOMIC_ISIZE_INIT; }; +LL | { let foo = ATOMIC_ISIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)` error: using `ATOMIC_I8_INIT` --> $DIR/replace_consts.rs:24:17 | -24 | { let foo = ATOMIC_I8_INIT; }; +LL | { let foo = ATOMIC_I8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)` error: using `ATOMIC_I16_INIT` --> $DIR/replace_consts.rs:25:17 | -25 | { let foo = ATOMIC_I16_INIT; }; +LL | { let foo = ATOMIC_I16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)` error: using `ATOMIC_I32_INIT` --> $DIR/replace_consts.rs:26:17 | -26 | { let foo = ATOMIC_I32_INIT; }; +LL | { let foo = ATOMIC_I32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)` error: using `ATOMIC_I64_INIT` --> $DIR/replace_consts.rs:27:17 | -27 | { let foo = ATOMIC_I64_INIT; }; +LL | { let foo = ATOMIC_I64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)` error: using `ATOMIC_USIZE_INIT` --> $DIR/replace_consts.rs:28:17 | -28 | { let foo = ATOMIC_USIZE_INIT; }; +LL | { let foo = ATOMIC_USIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)` error: using `ATOMIC_U8_INIT` --> $DIR/replace_consts.rs:29:17 | -29 | { let foo = ATOMIC_U8_INIT; }; +LL | { let foo = ATOMIC_U8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)` error: using `ATOMIC_U16_INIT` --> $DIR/replace_consts.rs:30:17 | -30 | { let foo = ATOMIC_U16_INIT; }; +LL | { let foo = ATOMIC_U16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)` error: using `ATOMIC_U32_INIT` --> $DIR/replace_consts.rs:31:17 | -31 | { let foo = ATOMIC_U32_INIT; }; +LL | { let foo = ATOMIC_U32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)` error: using `ATOMIC_U64_INIT` --> $DIR/replace_consts.rs:32:17 | -32 | { let foo = ATOMIC_U64_INIT; }; +LL | { let foo = ATOMIC_U64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` error: using `MIN` --> $DIR/replace_consts.rs:34:17 | -34 | { let foo = std::isize::MIN; }; +LL | { let foo = std::isize::MIN; }; | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:35:17 | -35 | { let foo = std::i8::MIN; }; +LL | { let foo = std::i8::MIN; }; | ^^^^^^^^^^^^ help: try this: `i8::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:36:17 | -36 | { let foo = std::i16::MIN; }; +LL | { let foo = std::i16::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:37:17 | -37 | { let foo = std::i32::MIN; }; +LL | { let foo = std::i32::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:38:17 | -38 | { let foo = std::i64::MIN; }; +LL | { let foo = std::i64::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:39:17 | -39 | { let foo = std::i128::MIN; }; +LL | { let foo = std::i128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:40:17 | -40 | { let foo = std::usize::MIN; }; +LL | { let foo = std::usize::MIN; }; | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:41:17 | -41 | { let foo = std::u8::MIN; }; +LL | { let foo = std::u8::MIN; }; | ^^^^^^^^^^^^ help: try this: `u8::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:42:17 | -42 | { let foo = std::u16::MIN; }; +LL | { let foo = std::u16::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:43:17 | -43 | { let foo = std::u32::MIN; }; +LL | { let foo = std::u32::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:44:17 | -44 | { let foo = std::u64::MIN; }; +LL | { let foo = std::u64::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:45:17 | -45 | { let foo = std::u128::MIN; }; +LL | { let foo = std::u128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` error: using `MAX` --> $DIR/replace_consts.rs:47:17 | -47 | { let foo = std::isize::MAX; }; +LL | { let foo = std::isize::MAX; }; | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:48:17 | -48 | { let foo = std::i8::MAX; }; +LL | { let foo = std::i8::MAX; }; | ^^^^^^^^^^^^ help: try this: `i8::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:49:17 | -49 | { let foo = std::i16::MAX; }; +LL | { let foo = std::i16::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:50:17 | -50 | { let foo = std::i32::MAX; }; +LL | { let foo = std::i32::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:51:17 | -51 | { let foo = std::i64::MAX; }; +LL | { let foo = std::i64::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:52:17 | -52 | { let foo = std::i128::MAX; }; +LL | { let foo = std::i128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:53:17 | -53 | { let foo = std::usize::MAX; }; +LL | { let foo = std::usize::MAX; }; | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:54:17 | -54 | { let foo = std::u8::MAX; }; +LL | { let foo = std::u8::MAX; }; | ^^^^^^^^^^^^ help: try this: `u8::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:55:17 | -55 | { let foo = std::u16::MAX; }; +LL | { let foo = std::u16::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:56:17 | -56 | { let foo = std::u32::MAX; }; +LL | { let foo = std::u32::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:57:17 | -57 | { let foo = std::u64::MAX; }; +LL | { let foo = std::u64::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:58:17 | -58 | { let foo = std::u128::MAX; }; +LL | { let foo = std::u128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` error: aborting due to 35 previous errors diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 3f5231dcc06..e462a07ad51 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Result value where `f` is a unit function --> $DIR/result_map_unit_fn.rs:43:5 | -43 | x.field.map(do_nothing); +LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` @@ -11,7 +11,7 @@ error: called `map(f)` on an Result value where `f` is a unit function error: called `map(f)` on an Result value where `f` is a unit function --> $DIR/result_map_unit_fn.rs:45:5 | -45 | x.field.map(do_nothing); +LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` @@ -19,7 +19,7 @@ error: called `map(f)` on an Result value where `f` is a unit function error: called `map(f)` on an Result value where `f` is a unit function --> $DIR/result_map_unit_fn.rs:47:5 | -47 | x.field.map(diverge); +LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` @@ -27,7 +27,7 @@ error: called `map(f)` on an Result value where `f` is a unit function error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:53:5 | -53 | x.field.map(|value| x.do_result_nothing(value + captured)); +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) }` @@ -35,7 +35,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:55:5 | -55 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); +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); }` @@ -43,7 +43,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:58:5 | -58 | x.field.map(|value| do_nothing(value + captured)); +LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` @@ -51,7 +51,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:60:5 | -60 | x.field.map(|value| { do_nothing(value + captured) }); +LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` @@ -59,7 +59,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:62:5 | -62 | x.field.map(|value| { do_nothing(value + captured); }); +LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` @@ -67,7 +67,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:64:5 | -64 | x.field.map(|value| { { do_nothing(value + captured); } }); +LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` @@ -75,7 +75,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:67:5 | -67 | x.field.map(|value| diverge(value + captured)); +LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` @@ -83,7 +83,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:69:5 | -69 | x.field.map(|value| { diverge(value + captured) }); +LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` @@ -91,7 +91,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:71:5 | -71 | x.field.map(|value| { diverge(value + captured); }); +LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` @@ -99,7 +99,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:73:5 | -73 | x.field.map(|value| { { diverge(value + captured); } }); +LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` @@ -107,7 +107,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:78:5 | -78 | x.field.map(|value| { let y = plus_one(value + captured); }); +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); }` @@ -115,7 +115,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:80:5 | -80 | x.field.map(|value| { plus_one(value + captured); }); +LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` @@ -123,7 +123,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:82:5 | -82 | x.field.map(|value| { { plus_one(value + captured); } }); +LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` @@ -131,7 +131,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:85:5 | -85 | x.field.map(|ref value| { do_nothing(value + captured) }); +LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` @@ -139,7 +139,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:88:5 | -88 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); +LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` @@ -147,7 +147,7 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:90:5 | -90 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); +LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` @@ -155,13 +155,13 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:94:5 | -94 | x.field.map(|value| { +LL | x.field.map(|value| { | _____^ | |_____| | || -95 | || do_nothing(value); -96 | || do_nothing(value) -97 | || }); +LL | || do_nothing(value); +LL | || do_nothing(value) +LL | || }); | ||______^- help: try this: `if let Ok(value) = x.field { ... }` | |_______| | @@ -169,26 +169,26 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:98:5 | -98 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); +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 - | -102 | "12".parse::<i32>().map(diverge); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(_) = "12".parse::<i32>() { diverge(...) }` + --> $DIR/result_map_unit_fn.rs:102:5 + | +LL | "12".parse::<i32>().map(diverge); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(_) = "12".parse::<i32>() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:108:5 - | -108 | y.map(do_nothing); - | ^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(_y) = y { do_nothing(...) }` + --> $DIR/result_map_unit_fn.rs:108:5 + | +LL | y.map(do_nothing); + | ^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(_y) = y { do_nothing(...) }` error: aborting due to 23 previous errors diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index 23f10f69435..61e54d53468 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -1,12 +1,12 @@ error: you should not implement `visit_string` without also implementing `visit_str` --> $DIR/serde.rs:48:5 | -48 | / fn visit_string<E>(self, _v: String) -> Result<Self::Value, E> -49 | | where -50 | | E: serde::de::Error, -51 | | { -52 | | unimplemented!() -53 | | } +LL | / fn visit_string<E>(self, _v: String) -> Result<Self::Value, E> +LL | | where +LL | | E: serde::de::Error, +LL | | { +LL | | unimplemented!() +LL | | } | |_____^ | = note: `-D clippy::serde-api-misuse` implied by `-D warnings` diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index 196f17ac653..158933e9672 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,137 +1,137 @@ error: `x` is shadowed by itself in `&mut x` --> $DIR/shadow.rs:29:5 | -29 | let x = &mut x; +LL | let x = &mut x; | ^^^^^^^^^^^^^^^ | = note: `-D clippy::shadow-same` implied by `-D warnings` note: previous binding is here --> $DIR/shadow.rs:28:13 | -28 | let mut x = 1; +LL | let mut x = 1; | ^ error: `x` is shadowed by itself in `{ x }` --> $DIR/shadow.rs:30:5 | -30 | let x = { x }; +LL | let x = { x }; | ^^^^^^^^^^^^^^ | note: previous binding is here --> $DIR/shadow.rs:29:9 | -29 | let x = &mut x; +LL | let x = &mut x; | ^ error: `x` is shadowed by itself in `(&*x)` --> $DIR/shadow.rs:31:5 | -31 | let x = (&*x); +LL | let x = (&*x); | ^^^^^^^^^^^^^^ | note: previous binding is here --> $DIR/shadow.rs:30:9 | -30 | let x = { x }; +LL | let x = { x }; | ^ error: `x` is shadowed by `{ *x + 1 }` which reuses the original value --> $DIR/shadow.rs:32:9 | -32 | let x = { *x + 1 }; +LL | let x = { *x + 1 }; | ^ | = note: `-D clippy::shadow-reuse` implied by `-D warnings` note: initialization happens here --> $DIR/shadow.rs:32:13 | -32 | let x = { *x + 1 }; +LL | let x = { *x + 1 }; | ^^^^^^^^^^ note: previous binding is here --> $DIR/shadow.rs:31:9 | -31 | let x = (&*x); +LL | let x = (&*x); | ^ error: `x` is shadowed by `id(x)` which reuses the original value --> $DIR/shadow.rs:33:9 | -33 | let x = id(x); +LL | let x = id(x); | ^ | note: initialization happens here --> $DIR/shadow.rs:33:13 | -33 | let x = id(x); +LL | let x = id(x); | ^^^^^ note: previous binding is here --> $DIR/shadow.rs:32:9 | -32 | let x = { *x + 1 }; +LL | let x = { *x + 1 }; | ^ error: `x` is shadowed by `(1, x)` which reuses the original value --> $DIR/shadow.rs:34:9 | -34 | let x = (1, x); +LL | let x = (1, x); | ^ | note: initialization happens here --> $DIR/shadow.rs:34:13 | -34 | let x = (1, x); +LL | let x = (1, x); | ^^^^^^ note: previous binding is here --> $DIR/shadow.rs:33:9 | -33 | let x = id(x); +LL | let x = id(x); | ^ error: `x` is shadowed by `first(x)` which reuses the original value --> $DIR/shadow.rs:35:9 | -35 | let x = first(x); +LL | let x = first(x); | ^ | note: initialization happens here --> $DIR/shadow.rs:35:13 | -35 | let x = first(x); +LL | let x = first(x); | ^^^^^^^^ note: previous binding is here --> $DIR/shadow.rs:34:9 | -34 | let x = (1, x); +LL | let x = (1, x); | ^ error: `x` is shadowed by `y` --> $DIR/shadow.rs:37:9 | -37 | let x = y; +LL | let x = y; | ^ | = note: `-D clippy::shadow-unrelated` implied by `-D warnings` note: initialization happens here --> $DIR/shadow.rs:37:13 | -37 | let x = y; +LL | let x = y; | ^ note: previous binding is here --> $DIR/shadow.rs:35:9 | -35 | let x = first(x); +LL | let x = first(x); | ^ error: `x` shadows a previous declaration --> $DIR/shadow.rs:39:5 | -39 | let x; +LL | let x; | ^^^^^^ | note: previous binding is here --> $DIR/shadow.rs:37:9 | -37 | let x = y; +LL | let x = y; | ^ error: aborting due to 9 previous errors diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 7b5c843d072..4141a003fc4 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -1,7 +1,7 @@ error: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:13:5 | -13 | f() && g(); +LL | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` | = note: `-D clippy::short-circuit-statement` implied by `-D warnings` @@ -9,13 +9,13 @@ error: boolean short circuit operator in statement may be clearer using an expli error: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:14:5 | -14 | f() || g(); +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 | -15 | 1 == 2 || g(); +LL | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if !(1 == 2) { g(); }` error: aborting due to 3 previous errors diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index 353796b3928..7fa3211ab72 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,7 +1,7 @@ error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:14:13 | -14 | x.split("x"); +LL | x.split("x"); | ^^^ help: try using a char instead: `'x'` | = note: `-D clippy::single-char-pattern` implied by `-D warnings` @@ -9,115 +9,115 @@ error: single-character string constant used as pattern error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:31:16 | -31 | x.contains("x"); +LL | x.contains("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:32:19 | -32 | x.starts_with("x"); +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:33:17 | -33 | x.ends_with("x"); +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:34:12 | -34 | x.find("x"); +LL | x.find("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:35:13 | -35 | x.rfind("x"); +LL | x.rfind("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:36:14 | -36 | x.rsplit("x"); +LL | x.rsplit("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:37:24 | -37 | x.split_terminator("x"); +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:38:25 | -38 | x.rsplit_terminator("x"); +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:39:17 | -39 | x.splitn(0, "x"); +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:40:18 | -40 | x.rsplitn(0, "x"); +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:41:15 | -41 | x.matches("x"); +LL | x.matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:42:16 | -42 | x.rmatches("x"); +LL | x.rmatches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:43:21 | -43 | x.match_indices("x"); +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:44:22 | -44 | x.rmatch_indices("x"); +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:45:26 | -45 | x.trim_start_matches("x"); +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:46:24 | -46 | x.trim_end_matches("x"); +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:48:13 | -48 | x.split("/n"); +LL | x.split("/n"); | ^^^^ help: try using a char instead: `'/n'` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:53:31 | -53 | x.replace(";", ",").split(","); // issue #2978 +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:54:19 | -54 | x.starts_with("/x03"); // issue #2996 +LL | x.starts_with("/x03"); // issue #2996 | ^^^^^^ help: try using a char instead: `'/x03'` error: aborting due to 20 previous errors diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index 45fcbce0047..41776030800 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,68 +1,68 @@ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:17:5 | -17 | / match x { -18 | | Some(y) => { -19 | | println!("{:?}", y); -20 | | }, -21 | | _ => (), -22 | | }; +LL | / match x { +LL | | Some(y) => { +LL | | println!("{:?}", y); +LL | | }, +LL | | _ => (), +LL | | }; | |_____^ | = note: `-D clippy::single-match` implied by `-D warnings` help: try this | -17 | if let Some(y) = x { -18 | println!("{:?}", y); -19 | }; +LL | if let Some(y) = x { +LL | println!("{:?}", y); +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 | -25 | / match x { -26 | | // Note the missing block braces. -27 | | // We suggest `if let Some(y) = x { .. }` because the macro -28 | | // is expanded before we can do anything. -29 | | Some(y) => println!("{:?}", y), -30 | | _ => (), -31 | | } +LL | / match x { +LL | | // Note the missing block braces. +LL | | // We suggest `if let Some(y) = x { .. }` because the macro +LL | | // is expanded before we can do anything. +LL | | Some(y) => println!("{:?}", y), +LL | | _ => (), +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 | -34 | / match z { -35 | | (2...3, 7...9) => dummy(), -36 | | _ => {}, -37 | | }; +LL | / match z { +LL | | (2...3, 7...9) => dummy(), +LL | | _ => {}, +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 | -63 | / match x { -64 | | Some(y) => dummy(), -65 | | None => (), -66 | | }; +LL | / match x { +LL | | Some(y) => dummy(), +LL | | None => (), +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 | -68 | / match y { -69 | | Ok(y) => dummy(), -70 | | Err(..) => (), -71 | | }; +LL | / match y { +LL | | Ok(y) => dummy(), +LL | | Err(..) => (), +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 | -75 | / match c { -76 | | Cow::Borrowed(..) => dummy(), -77 | | Cow::Owned(..) => (), -78 | | }; +LL | / match c { +LL | | Cow::Borrowed(..) => dummy(), +LL | | Cow::Owned(..) => (), +LL | | }; | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }` error: aborting due to 6 previous errors diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 6ae9dd1a818..ff780ad9667 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -1,22 +1,22 @@ 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 | -21 | / match ExprNode::Butterflies { -22 | | ExprNode::ExprAddrOf => Some(&NODE), -23 | | _ => { -24 | | let x = 5; -25 | | None -26 | | }, -27 | | } +LL | / match ExprNode::Butterflies { +LL | | ExprNode::ExprAddrOf => Some(&NODE), +LL | | _ => { +LL | | let x = 5; +LL | | None +LL | | }, +LL | | } | |_____^ | = note: `-D clippy::single-match-else` implied by `-D warnings` help: try this | -21 | if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { -22 | let x = 5; -23 | None -24 | } +LL | if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { +LL | let x = 5; +LL | None +LL | } | error: aborting due to previous error diff --git a/tests/ui/slow_vector_initialization.stderr b/tests/ui/slow_vector_initialization.stderr index f45c3b48b1b..319234386ac 100644 --- a/tests/ui/slow_vector_initialization.stderr +++ b/tests/ui/slow_vector_initialization.stderr @@ -1,9 +1,9 @@ error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:22:5 | -21 | let mut vec1 = Vec::with_capacity(len); +LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replace allocation with: `vec![0; len]` -22 | vec1.extend(repeat(0).take(len)); +LL | vec1.extend(repeat(0).take(len)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::slow-vector-initialization` implied by `-D warnings` @@ -11,49 +11,49 @@ error: slow zero-filling initialization error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:26:5 | -25 | let mut vec2 = Vec::with_capacity(len - 10); +LL | let mut vec2 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replace allocation with: `vec![0; len - 10]` -26 | vec2.extend(repeat(0).take(len - 10)); +LL | vec2.extend(repeat(0).take(len - 10)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:40:5 | -39 | let mut resized_vec = Vec::with_capacity(30); +LL | let mut resized_vec = Vec::with_capacity(30); | ---------------------- help: consider replace allocation with: `vec![0; 30]` -40 | resized_vec.resize(30, 0); +LL | resized_vec.resize(30, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:43:5 | -42 | let mut extend_vec = Vec::with_capacity(30); +LL | let mut extend_vec = Vec::with_capacity(30); | ---------------------- help: consider replace allocation with: `vec![0; 30]` -43 | extend_vec.extend(repeat(0).take(30)); +LL | extend_vec.extend(repeat(0).take(30)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:50:5 | -49 | let mut vec1 = Vec::with_capacity(len); +LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replace allocation with: `vec![0; len]` -50 | vec1.resize(len, 0); +LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:58:5 | -57 | let mut vec3 = Vec::with_capacity(len - 10); +LL | let mut vec3 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replace allocation with: `vec![0; len - 10]` -58 | vec3.resize(len - 10, 0); +LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:62:5 | -61 | vec1 = Vec::with_capacity(10); +LL | vec1 = Vec::with_capacity(10); | ---------------------- help: consider replace allocation with: `vec![0; 10]` -62 | vec1.resize(10, 0); +LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index 0b1b7c020d9..ed1ccad9814 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,7 +1,7 @@ error: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:16:5 | -16 | "".chars().next() == Some(' '); +LL | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` | = note: `-D clippy::chars-next-cmp` implied by `-D warnings` @@ -9,19 +9,19 @@ error: you should use the `starts_with` method error: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:17:5 | -17 | Some(' ') != "".chars().next(); +LL | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` error: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:22:8 | -22 | if s.chars().next().unwrap() == 'f' { +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 | -26 | if s.chars().next_back().unwrap() == 'o' { +LL | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` | = note: `-D clippy::chars-last-cmp` implied by `-D warnings` @@ -29,49 +29,49 @@ error: you should use the `ends_with` method error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:30:8 | -30 | if s.chars().last().unwrap() == 'o' { +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 | -34 | if s.chars().next().unwrap() != 'f' { +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 | -38 | if s.chars().next_back().unwrap() != 'o' { +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 | -42 | if s.chars().last().unwrap() != 'o' { +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 | -50 | "".chars().last() == Some(' '); +LL | "".chars().last() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:51:5 | -51 | Some(' ') != "".chars().last(); +LL | Some(' ') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:52:5 | -52 | "".chars().next_back() == Some(' '); +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 | -53 | Some(' ') != "".chars().next_back(); +LL | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: aborting due to 12 previous errors diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index 36af80b8665..80a490b7884 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -1,7 +1,7 @@ error: calling `.extend(_.chars())` --> $DIR/string_extend.rs:25:5 | -25 | s.extend(abc.chars()); +LL | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)` | = note: `-D clippy::string-extend-chars` implied by `-D warnings` @@ -9,13 +9,13 @@ error: calling `.extend(_.chars())` error: calling `.extend(_.chars())` --> $DIR/string_extend.rs:28:5 | -28 | s.extend("abc".chars()); +LL | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str("abc")` error: calling `.extend(_.chars())` --> $DIR/string_extend.rs:31:5 | -31 | s.extend(def.chars()); +LL | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)` error: aborting due to 3 previous errors diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index fe491d29b78..a8c80939b55 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -1,7 +1,7 @@ error: manual implementation of an assign operation --> $DIR/strings.rs:17:9 | -17 | x = x + "."; +LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` @@ -9,7 +9,7 @@ error: manual implementation of an assign operation error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:17:13 | -17 | x = x + "."; +LL | x = x + "."; | ^^^^^^^ | = note: `-D clippy::string-add` implied by `-D warnings` @@ -17,13 +17,13 @@ error: you added something to a string. Consider using `String::push_str()` inst error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:21:13 | -21 | let z = y + "..."; +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 | -31 | x = x + "."; +LL | x = x + "."; | ^^^^^^^^^^^ | = note: `-D clippy::string-add-assign` implied by `-D warnings` @@ -31,31 +31,31 @@ error: you assigned the result of adding something to this string. Consider usin error: manual implementation of an assign operation --> $DIR/strings.rs:31:9 | -31 | x = x + "."; +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 | -45 | x = x + "."; +LL | x = x + "."; | ^^^^^^^^^^^ error: manual implementation of an assign operation --> $DIR/strings.rs:45:9 | -45 | x = x + "."; +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 | -49 | let z = y + "..."; +LL | let z = y + "..."; | ^^^^^^^^^ error: calling `as_bytes()` on a string literal --> $DIR/strings.rs:57:14 | -57 | let bs = "hello there".as_bytes(); +LL | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` | = note: `-D clippy::string-lit-as-bytes` implied by `-D warnings` @@ -63,13 +63,13 @@ error: calling `as_bytes()` on a string literal error: calling `as_bytes()` on a string literal --> $DIR/strings.rs:59:14 | -59 | let bs = r###"raw string with three ### in it and some " ""###.as_bytes(); +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 | -66 | let includestr = include_str!("entry.rs").as_bytes(); +LL | let includestr = include_str!("entry.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("entry.rs")` error: aborting due to 11 previous errors diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 5e27dd1d44f..71cb08c77d7 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,7 +1,7 @@ error: Suspicious use of binary operator in `Add` impl --> $DIR/suspicious_arithmetic_impl.rs:20:20 | -20 | Foo(self.0 - other.0) +LL | Foo(self.0 - other.0) | ^ | = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` @@ -9,7 +9,7 @@ error: Suspicious use of binary operator in `Add` impl error: Suspicious use of binary operator in `AddAssign` impl --> $DIR/suspicious_arithmetic_impl.rs:26:23 | -26 | *self = *self - other; +LL | *self = *self - other; | ^ | = note: #[deny(clippy::suspicious_op_assign_impl)] on by default diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index c8e803c4afd..25afaccd754 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,9 +1,9 @@ error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:17:5 | -17 | / let temp = foo[0]; -18 | | foo[0] = foo[1]; -19 | | foo[1] = temp; +LL | / let temp = foo[0]; +LL | | foo[0] = foo[1]; +LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` | = note: `-D clippy::manual-swap` implied by `-D warnings` @@ -11,26 +11,26 @@ error: this looks like you are swapping elements of `foo` manually error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:26:5 | -26 | / let temp = foo[0]; -27 | | foo[0] = foo[1]; -28 | | foo[1] = temp; +LL | / let temp = foo[0]; +LL | | foo[0] = foo[1]; +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 | -35 | / let temp = foo[0]; -36 | | foo[0] = foo[1]; -37 | | foo[1] = temp; +LL | / let temp = foo[0]; +LL | | foo[0] = foo[1]; +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 | -54 | ; let t = a; +LL | ; let t = a; | _______^ -55 | | a = b; -56 | | b = t; +LL | | a = b; +LL | | b = t; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: or maybe you should use `std::mem::replace`? @@ -38,10 +38,10 @@ error: this looks like you are swapping `a` and `b` manually error: this looks like you are swapping `c.0` and `a` manually --> $DIR/swap.rs:63:7 | -63 | ; let t = c.0; +LL | ; let t = c.0; | _______^ -64 | | c.0 = a; -65 | | a = t; +LL | | c.0 = a; +LL | | a = t; | |_________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? @@ -49,8 +49,8 @@ error: this looks like you are swapping `c.0` and `a` manually error: this looks like you are trying to swap `a` and `b` --> $DIR/swap.rs:51:5 | -51 | / a = b; -52 | | b = a; +LL | / a = b; +LL | | b = a; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: `-D clippy::almost-swapped` implied by `-D warnings` @@ -59,8 +59,8 @@ error: this looks like you are trying to swap `a` and `b` error: this looks like you are trying to swap `c.0` and `a` --> $DIR/swap.rs:60:5 | -60 | / c.0 = a; -61 | | a = c.0; +LL | / c.0 = a; +LL | | a = c.0; | |___________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 17b1ca1251a..a9736385048 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -1,7 +1,7 @@ error: assignment to temporary --> $DIR/temporary_assignment.rs:39:5 | -39 | Struct { field: 0 }.field = 1; +LL | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::temporary-assignment` implied by `-D warnings` @@ -9,7 +9,7 @@ error: assignment to temporary error: assignment to temporary --> $DIR/temporary_assignment.rs:40:5 | -40 | (0, 0).0 = 1; +LL | (0, 0).0 = 1; | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 2807539604d..7b7a46d9f8e 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,7 +1,7 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead. --> $DIR/toplevel_ref_arg.rs:13:15 | -13 | fn the_answer(ref mut x: u8) { +LL | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` @@ -9,25 +9,25 @@ error: `ref` directly on a function argument is ignored. Consider using a refere error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:24:9 | -24 | let ref x = 1; +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 | -26 | let ref y: (&_, u8) = (&1, 2); +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 | -28 | let ref z = 1 + 2; +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 | -30 | let ref mut z = 1 + 2; +LL | let ref mut z = 1 + 2; | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` error: aborting due to 5 previous errors diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 0bd3580a7dd..1675eb44efd 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,7 +1,7 @@ error: bit mask could be simplified with a call to `trailing_zeros` --> $DIR/trailing_zeros.rs:16:5 | -16 | (x & 0b1111 == 0); // suggest trailing_zeros +LL | (x & 0b1111 == 0); // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` @@ -9,7 +9,7 @@ error: bit mask could be simplified with a call to `trailing_zeros` error: bit mask could be simplified with a call to `trailing_zeros` --> $DIR/trailing_zeros.rs:17:13 | -17 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros +LL | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` error: aborting due to 2 previous errors diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index 6e4fe32a4a6..a6e87a72104 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,7 +1,7 @@ error: transmute from a type (`&'a T`) to itself --> $DIR/transmute.rs:28:20 | -28 | let _: &'a T = core::intrinsics::transmute(t); +LL | let _: &'a T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::useless-transmute` implied by `-D warnings` @@ -9,25 +9,25 @@ error: transmute from a type (`&'a T`) to itself error: transmute from a reference to a pointer --> $DIR/transmute.rs:32:23 | -32 | let _: *const T = core::intrinsics::transmute(t); +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 | -34 | let _: *mut T = core::intrinsics::transmute(t); +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 | -36 | let _: *const U = core::intrinsics::transmute(t); +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 | -41 | let _: &T = std::mem::transmute(p); +LL | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` | = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` @@ -35,212 +35,212 @@ error: transmute from a pointer type (`*const T`) to a reference type (`&T`) error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute.rs:44:21 | -44 | let _: &mut T = std::mem::transmute(m); +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 | -47 | let _: &T = std::mem::transmute(m); +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 | -50 | let _: &mut T = std::mem::transmute(p as *mut T); +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 | -53 | let _: &T = std::mem::transmute(o); +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 | -56 | let _: &mut T = std::mem::transmute(om); +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 | -59 | let _: &T = std::mem::transmute(om); +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 | -70 | let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; +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 (`&issue1231::Foo<'_, &u8>`) --> $DIR/transmute.rs:72:33 | -72 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; +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 | -76 | unsafe { std::mem::transmute::<_, Bar>(raw) }; +LL | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` error: transmute from a type (`std::vec::Vec<i32>`) to itself --> $DIR/transmute.rs:82:27 | -82 | let _: Vec<i32> = core::intrinsics::transmute(my_vec()); +LL | let _: Vec<i32> = core::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec<i32>`) to itself --> $DIR/transmute.rs:84:27 | -84 | let _: Vec<i32> = core::mem::transmute(my_vec()); +LL | let _: Vec<i32> = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec<i32>`) to itself --> $DIR/transmute.rs:86:27 | -86 | let _: Vec<i32> = std::intrinsics::transmute(my_vec()); +LL | let _: Vec<i32> = std::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec<i32>`) to itself --> $DIR/transmute.rs:88:27 | -88 | let _: Vec<i32> = std::mem::transmute(my_vec()); +LL | let _: Vec<i32> = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec<i32>`) to itself --> $DIR/transmute.rs:90:27 | -90 | let _: Vec<i32> = my_transmute(my_vec()); +LL | let _: Vec<i32> = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer --> $DIR/transmute.rs:98:31 | -98 | let _: *const usize = std::mem::transmute(5_isize); +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 - | -102 | let _: *const usize = std::mem::transmute(1 + 1usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize` + --> $DIR/transmute.rs:102: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 - | -117 | let _: Usize = core::intrinsics::transmute(int_const_ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` + --> $DIR/transmute.rs:117:24 + | +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 - | -119 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:119: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 - | -121 | let _: *const Usize = core::intrinsics::transmute(my_int()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:121: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 - | -123 | let _: *mut Usize = core::intrinsics::transmute(my_int()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:123:29 + | +LL | let _: *mut Usize = core::intrinsics::transmute(my_int()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u32` to a `char` - --> $DIR/transmute.rs:129:28 - | -129 | let _: char = unsafe { std::mem::transmute(0_u32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` - | - = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` + --> $DIR/transmute.rs:129:28 + | +LL | let _: char = unsafe { std::mem::transmute(0_u32) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` + | + = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` error: transmute from a `i32` to a `char` - --> $DIR/transmute.rs:130:28 - | -130 | let _: char = unsafe { std::mem::transmute(0_i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` + --> $DIR/transmute.rs:130: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 - | -135 | let _: bool = unsafe { std::mem::transmute(0_u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` - | - = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` + --> $DIR/transmute.rs:135:28 + | +LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` + | + = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` error: transmute from a `u32` to a `f32` - --> $DIR/transmute.rs:140:27 - | -140 | let _: f32 = unsafe { std::mem::transmute(0_u32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` - | - = note: `-D clippy::transmute-int-to-float` implied by `-D warnings` + --> $DIR/transmute.rs:140:27 + | +LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(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 - | -141 | let _: f32 = unsafe { std::mem::transmute(0_i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` + --> $DIR/transmute.rs:141: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 - | -145 | let _: &str = unsafe { std::mem::transmute(b) }; - | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()` - | - = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings` + --> $DIR/transmute.rs:145:28 + | +LL | let _: &str = unsafe { std::mem::transmute(b) }; + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()` + | + = 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 - | -146 | let _: &mut str = unsafe { std::mem::transmute(mb) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` + --> $DIR/transmute.rs:146: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 - | -178 | let _: *const f32 = std::mem::transmute(ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` - | - = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` + --> $DIR/transmute.rs:178:29 + | +LL | let _: *const f32 = std::mem::transmute(ptr); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` + | + = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:179:27 - | -179 | let _: *mut f32 = std::mem::transmute(mut_ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` + --> $DIR/transmute.rs:179: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 - | -181 | let _: &f32 = std::mem::transmute(&1u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` + --> $DIR/transmute.rs:181: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 - | -182 | let _: &f64 = std::mem::transmute(&1f32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` + --> $DIR/transmute.rs:182: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 - | -185 | let _: &mut f32 = std::mem::transmute(&mut 1u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` + --> $DIR/transmute.rs:185: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 - | -186 | let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: 1u32 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)` + --> $DIR/transmute.rs:186:37 + | +LL | let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: 1u32 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)` error: aborting due to 38 previous errors diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index 320bbeb7d29..bbca3bc0b36 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,7 +1,7 @@ error: transmute from a `f64` to a pointer --> $DIR/transmute_64bit.rs:16:31 | -16 | let _: *const usize = std::mem::transmute(6.0f64); +LL | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::wrong-transmute` implied by `-D warnings` @@ -9,7 +9,7 @@ error: transmute from a `f64` to a pointer error: transmute from a `f64` to a pointer --> $DIR/transmute_64bit.rs:18:29 | -18 | let _: *mut usize = std::mem::transmute(6.0f64); +LL | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 41aa52ecd14..6f2967bc392 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,7 +1,7 @@ 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 | -56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} +LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` | = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` @@ -9,85 +9,85 @@ error: this argument is passed by reference, but would be more efficient if pass 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 | -56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} +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 | -56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} +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 | -63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} +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 | -63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} +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 | -63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} +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 | -63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} +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 | -65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} +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 | -65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} +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 | -65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} +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 | -77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} +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 | -77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} +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 | -77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} +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 | -81 | fn trait_method(&self, _foo: &Foo); +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 | -85 | fn trait_method2(&self, _color: &Color); +LL | fn trait_method2(&self, _color: &Color); | ^^^^^^ help: consider passing by value instead: `Color` error: aborting due to 15 previous errors diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index e8770490abb..76dc07aef31 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,7 +1,7 @@ error: casting i32 to i64 may become silently lossy if types change --> $DIR/types.rs:18:22 | -18 | let c_i64: i64 = c as i64; +LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index e27b5866372..9b78271e1fa 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -1,7 +1,7 @@ error: zero-width space detected --> $DIR/unicode.rs:12:12 | -12 | print!("Here >< is a ZWS, and another"); +LL | print!("Here >< is a ZWS, and another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::zero-width-space` implied by `-D warnings` @@ -11,7 +11,7 @@ error: zero-width space detected error: non-nfc unicode sequence detected --> $DIR/unicode.rs:18:12 | -18 | print!("̀àh?"); +LL | print!("̀àh?"); | ^^^^^ | = note: `-D clippy::unicode-not-nfc` implied by `-D warnings` @@ -21,7 +21,7 @@ error: non-nfc unicode sequence detected error: literal non-ASCII character detected --> $DIR/unicode.rs:24:12 | -24 | print!("Üben!"); +LL | print!("Üben!"); | ^^^^^^^ | = note: `-D clippy::non-ascii-literal` implied by `-D warnings` diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index ed8d4cdfd3d..013016574ff 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,73 +1,73 @@ error: passing a unit value to a function --> $DIR/unit_arg.rs:32:9 | -32 | foo({}); +LL | foo({}); | ^^ | = note: `-D clippy::unit-arg` implied by `-D warnings` help: if you intended to pass a unit value, use a unit literal instead | -32 | foo(()); +LL | foo(()); | ^^ error: passing a unit value to a function --> $DIR/unit_arg.rs:33:9 | -33 | foo({ +LL | foo({ | _________^ -34 | | 1; -35 | | }); +LL | | 1; +LL | | }); | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -33 | foo(()); +LL | foo(()); | ^^ error: passing a unit value to a function --> $DIR/unit_arg.rs:36:9 | -36 | foo(foo(1)); +LL | foo(foo(1)); | ^^^^^^ help: if you intended to pass a unit value, use a unit literal instead | -36 | foo(()); +LL | foo(()); | ^^ error: passing a unit value to a function --> $DIR/unit_arg.rs:37:9 | -37 | foo({ +LL | foo({ | _________^ -38 | | foo(1); -39 | | foo(2); -40 | | }); +LL | | foo(1); +LL | | foo(2); +LL | | }); | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -37 | foo(()); +LL | foo(()); | ^^ error: passing a unit value to a function --> $DIR/unit_arg.rs:41:10 | -41 | foo3({}, 2, 2); +LL | foo3({}, 2, 2); | ^^ help: if you intended to pass a unit value, use a unit literal instead | -41 | foo3((), 2, 2); +LL | foo3((), 2, 2); | ^^ error: passing a unit value to a function --> $DIR/unit_arg.rs:43:11 | -43 | b.bar({ +LL | b.bar({ | ___________^ -44 | | 1; -45 | | }); +LL | | 1; +LL | | }); | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -43 | b.bar(()); +LL | b.bar(()); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 7c76945fe3e..481891b99b0 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,12 +1,12 @@ error: ==-comparison of unit values detected. This will always be true --> $DIR/unit_cmp.rs:21:8 | -21 | if { +LL | if { | ________^ -22 | | true; -23 | | } == { -24 | | false; -25 | | } {} +LL | | true; +LL | | } == { +LL | | false; +LL | | } {} | |_____^ | = note: `-D clippy::unit-cmp` implied by `-D warnings` @@ -14,12 +14,12 @@ error: ==-comparison of unit values detected. This will always be true error: >-comparison of unit values detected. This will always be false --> $DIR/unit_cmp.rs:27:8 | -27 | if { +LL | if { | ________^ -28 | | true; -29 | | } > { -30 | | false; -31 | | } {} +LL | | true; +LL | | } > { +LL | | false; +LL | | } {} | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/unknown_clippy_lints.stderr b/tests/ui/unknown_clippy_lints.stderr index 83ee0e9dd31..f83a51728e7 100644 --- a/tests/ui/unknown_clippy_lints.stderr +++ b/tests/ui/unknown_clippy_lints.stderr @@ -1,7 +1,7 @@ error: unknown clippy lint: clippy::if_not_els --> $DIR/unknown_clippy_lints.rs:13:8 | -13 | #[warn(clippy::if_not_els)] +LL | #[warn(clippy::if_not_els)] | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unknown-clippy-lints` implied by `-D warnings` @@ -9,7 +9,7 @@ error: unknown clippy lint: clippy::if_not_els error: unknown clippy lint: clippy::All --> $DIR/unknown_clippy_lints.rs:10:10 | -10 | #![allow(clippy::All)] +LL | #![allow(clippy::All)] | ^^^^^^^^^^^ help: lowercase the lint name: `all` error: aborting due to 2 previous errors diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 8a0bf9d55b5..604902e5d6d 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,7 +1,7 @@ error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:26:5 | -26 | 42.clone(); +LL | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` @@ -9,19 +9,19 @@ error: using `clone` on a `Copy` type error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:30:5 | -30 | (&42).clone(); +LL | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:33:5 | -33 | rc.borrow().clone(); +LL | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:43:5 | -43 | rc.clone(); +LL | rc.clone(); | ^^^^^^^^^^ help: try this: `Rc::<bool>::clone(&rc)` | = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` @@ -29,68 +29,68 @@ error: using '.clone()' on a ref-counted pointer error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:46:5 | -46 | arc.clone(); +LL | arc.clone(); | ^^^^^^^^^^^ help: try this: `Arc::<bool>::clone(&arc)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:49:5 | -49 | rcweak.clone(); +LL | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try this: `Weak::<bool>::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:52:5 | -52 | arc_weak.clone(); +LL | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try this: `Weak::<bool>::clone(&arc_weak)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:56:29 | -56 | let _: Arc<SomeTrait> = x.clone(); +LL | let _: Arc<SomeTrait> = x.clone(); | ^^^^^^^^^ help: try this: `Arc::<SomeImpl>::clone(&x)` error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:60:5 | -60 | t.clone(); +LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:62:5 | -62 | Some(t).clone(); +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 | -68 | let z: &Vec<_> = y.clone(); +LL | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | = note: #[deny(clippy::clone_double_ref)] on by default help: try dereferencing it | -68 | let z: &Vec<_> = &(*y).clone(); +LL | let z: &Vec<_> = &(*y).clone(); | ^^^^^^^^^^^^^ help: or try being explicit about what type to clone | -68 | let z: &Vec<_> = &std::vec::Vec<i32>::clone(y); +LL | let z: &Vec<_> = &std::vec::Vec<i32>::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 | -75 | let v2: Vec<isize> = v.iter().cloned().collect(); +LL | let v2: Vec<isize> = 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 - | -111 | let _: E = a.clone(); - | ^^^^^^^^^ help: try dereferencing it: `*****a` + --> $DIR/unnecessary_clone.rs:111:20 + | +LL | let _: E = a.clone(); + | ^^^^^^^^^ help: try dereferencing it: `*****a` error: aborting due to 13 previous errors diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 53311b3d275..09f8973708f 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -1,7 +1,7 @@ error: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:11:13 | -11 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); +LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings` @@ -9,29 +9,29 @@ error: this `.filter_map` can be written more simply using `.filter` error: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:12:13 | -12 | let _ = (0..4).filter_map(|x| { +LL | let _ = (0..4).filter_map(|x| { | _____________^ -13 | | if x > 1 { -14 | | return Some(x); -15 | | }; -16 | | None -17 | | }); +LL | | if x > 1 { +LL | | return Some(x); +LL | | }; +LL | | None +LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:18:13 | -18 | let _ = (0..4).filter_map(|x| match x { +LL | let _ = (0..4).filter_map(|x| match x { | _____________^ -19 | | 0 | 1 => None, -20 | | _ => Some(x), -21 | | }); +LL | | 0 | 1 => None, +LL | | _ => Some(x), +LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.map` --> $DIR/unnecessary_filter_map.rs:23:13 | -23 | let _ = (0..4).filter_map(|x| Some(x + 1)); +LL | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index e0bd744265c..2c2349bd3bc 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,7 +1,7 @@ error: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:13:19 | -13 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); +LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` | = note: `-D clippy::unnecessary-fold` implied by `-D warnings` @@ -9,25 +9,25 @@ error: this `.fold` can be written more succinctly using another method error: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:15:19 | -15 | let _ = (0..3).fold(true, |acc, x| acc && x > 2); +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 | -17 | let _ = (0..3).fold(0, |acc, x| acc + x); +LL | let _ = (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 | -19 | let _ = (0..3).fold(1, |acc, x| acc * x); +LL | let _ = (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 | -24 | let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); +LL | let _ = (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.stderr b/tests/ui/unnecessary_operation.stderr index 8b576bef648..e46002dd97b 100644 --- a/tests/ui/unnecessary_operation.stderr +++ b/tests/ui/unnecessary_operation.stderr @@ -1,7 +1,7 @@ error: statement can be reduced --> $DIR/unnecessary_operation.rs:54:5 | -54 | Tuple(get_number()); +LL | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | = note: `-D clippy::unnecessary-operation` implied by `-D warnings` @@ -9,119 +9,119 @@ error: statement can be reduced error: statement can be reduced --> $DIR/unnecessary_operation.rs:55:5 | -55 | Struct { field: get_number() }; +LL | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:56:5 | -56 | Struct { ..get_struct() }; +LL | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:57:5 | -57 | Enum::Tuple(get_number()); +LL | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:58:5 | -58 | Enum::Struct { field: get_number() }; +LL | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:59:5 | -59 | 5 + get_number(); +LL | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:60:5 | -60 | *&get_number(); +LL | *&get_number(); | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:61:5 | -61 | &get_number(); +LL | &get_number(); | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:62:5 | -62 | (5, 6, get_number()); +LL | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:63:5 | -63 | box get_number(); +LL | box get_number(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:64:5 | -64 | get_number()..; +LL | get_number()..; | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:65:5 | -65 | ..get_number(); +LL | ..get_number(); | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:66:5 | -66 | 5..get_number(); +LL | 5..get_number(); | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:67:5 | -67 | [42, get_number()]; +LL | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:68:5 | -68 | [42, 55][get_number() as usize]; +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 | -69 | (42, get_number()).1; +LL | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:70:5 | -70 | [get_number(); 55]; +LL | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:71:5 | -71 | [42; 55][get_number() as usize]; +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 | -72 | / { -73 | | get_number() -74 | | }; +LL | / { +LL | | get_number() +LL | | }; | |______^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:75:5 | -75 | / FooString { -76 | | s: String::from("blah"), -77 | | }; +LL | / FooString { +LL | | s: String::from("blah"), +LL | | }; | |______^ help: replace it with: `String::from("blah");` error: aborting due to 20 previous errors diff --git a/tests/ui/unnecessary_ref.stderr b/tests/ui/unnecessary_ref.stderr index f048df6e39b..77503026bde 100644 --- a/tests/ui/unnecessary_ref.stderr +++ b/tests/ui/unnecessary_ref.stderr @@ -1,13 +1,13 @@ error: Creating a reference that is immediately dereferenced. --> $DIR/unnecessary_ref.rs:20:17 | -20 | let inner = (&outer).inner; +LL | let inner = (&outer).inner; | ^^^^^^^^ help: try this: `outer.inner` | note: lint level defined here --> $DIR/unnecessary_ref.rs:17:8 | -17 | #[deny(clippy::ref_in_deref)] +LL | #[deny(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index a1e43e493b7..23e35923f83 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,7 +1,7 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead --> $DIR/unneeded_field_pattern.rs:23:15 | -23 | Foo { a: _, b: 0, .. } => {}, +LL | Foo { a: _, b: 0, .. } => {}, | ^^^^ | = note: `-D clippy::unneeded-field-pattern` implied by `-D warnings` @@ -10,7 +10,7 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead error: All the struct fields are matched to a wildcard pattern, consider using `..`. --> $DIR/unneeded_field_pattern.rs:25:9 | -25 | Foo { a: _, b: _, c: _ } => {}, +LL | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Try with `Foo { .. }` instead diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index 83372a2a5a7..6696f155fb8 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -1,7 +1,7 @@ error: long literal lacking separators --> $DIR/unreadable_literal.rs:24:16 | -24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +LL | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` @@ -9,25 +9,25 @@ error: long literal lacking separators error: long literal lacking separators --> $DIR/unreadable_literal.rs:24:30 | -24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +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:24:51 | -24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +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:24:63 | -24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +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:26:19 | -26 | let bad_sci = 1.123456e1; +LL | let bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` error: aborting due to 5 previous errors diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 3b285208978..cdc2b907ec5 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -1,7 +1,7 @@ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell` --> $DIR/unsafe_removed_from_name.rs:14:1 | -14 | use std::cell::UnsafeCell as TotallySafeCell; +LL | use std::cell::UnsafeCell as TotallySafeCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` @@ -9,13 +9,13 @@ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` --> $DIR/unsafe_removed_from_name.rs:16:1 | -16 | use std::cell::UnsafeCell as TotallySafeCellAgain; +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 | -30 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; +LL | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index 0ec8ce57ad7..4e721527249 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -12,7 +12,6 @@ use std::io; - fn try_macro<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> { try!(s.write(b"test")); let mut buf = [0u8; 4]; diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index f7b9b361502..528d35ebdef 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -1,42 +1,42 @@ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:17:5 + --> $DIR/unused_io_amount.rs:16:5 | -17 | try!(s.write(b"test")); +LL | try!(s.write(b"test")); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-io-amount` implied by `-D warnings` = 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:19:5 + --> $DIR/unused_io_amount.rs:18:5 | -19 | try!(s.read(&mut buf)); +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:24:5 + --> $DIR/unused_io_amount.rs:23:5 | -24 | s.write(b"test")?; +LL | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:26:5 + --> $DIR/unused_io_amount.rs:25:5 | -26 | s.read(&mut buf)?; +LL | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:31:5 + --> $DIR/unused_io_amount.rs:30:5 | -31 | s.write(b"test").unwrap(); +LL | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:33:5 + --> $DIR/unused_io_amount.rs:32:5 | -33 | s.read(&mut buf).unwrap(); +LL | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index cbade54c157..07ff5083ed2 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -1,11 +1,11 @@ error: unused label `'label` --> $DIR/unused_labels.rs:14:5 | -14 | / 'label: for i in 1..2 { -15 | | if i > 4 { -16 | | continue; -17 | | } -18 | | } +LL | / 'label: for i in 1..2 { +LL | | if i > 4 { +LL | | continue; +LL | | } +LL | | } | |_____^ | = note: `-D clippy::unused-label` implied by `-D warnings` @@ -13,17 +13,17 @@ error: unused label `'label` error: unused label `'a` --> $DIR/unused_labels.rs:28:5 | -28 | / 'a: loop { -29 | | break; -30 | | } +LL | / 'a: loop { +LL | | break; +LL | | } | |_____^ error: unused label `'same_label_in_two_fns` --> $DIR/unused_labels.rs:41:5 | -41 | / 'same_label_in_two_fns: loop { -42 | | let _ = 1; -43 | | } +LL | / 'same_label_in_two_fns: loop { +LL | | let _ = 1; +LL | | } | |_____^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index e590cfc91aa..30ce7b68578 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -1,7 +1,7 @@ error: this lifetime isn't used in the function definition --> $DIR/unused_lt.rs:23:14 | -23 | fn unused_lt<'a>(x: u8) {} +LL | fn unused_lt<'a>(x: u8) {} | ^^ | = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` @@ -9,13 +9,13 @@ error: this lifetime isn't used in the function definition error: this lifetime isn't used in the function definition --> $DIR/unused_lt.rs:25:25 | -25 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { +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 | -50 | fn x<'a>(&self) {} +LL | fn x<'a>(&self) {} | ^^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_unit.stderr b/tests/ui/unused_unit.stderr index aac092b9f7f..ac76d75b176 100644 --- a/tests/ui/unused_unit.stderr +++ b/tests/ui/unused_unit.stderr @@ -1,51 +1,51 @@ error: unneeded unit return type --> $DIR/unused_unit.rs:25:59 | -25 | pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> +LL | pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> | ___________________________________________________________^ -26 | | () +LL | | () | |__________^ help: remove the `-> ()` | note: lint level defined here --> $DIR/unused_unit.rs:19:9 | -19 | #![deny(clippy::unused_unit)] +LL | #![deny(clippy::unused_unit)] | ^^^^^^^^^^^^^^^^^^^ error: unneeded unit return type --> $DIR/unused_unit.rs:35:19 | -35 | fn into(self) -> () { +LL | fn into(self) -> () { | ^^^^^ help: remove the `-> ()` error: unneeded unit expression --> $DIR/unused_unit.rs:36:9 | -36 | () +LL | () | ^^ help: remove the final `()` error: unneeded unit return type --> $DIR/unused_unit.rs:40:18 | -40 | fn return_unit() -> () { () } +LL | fn return_unit() -> () { () } | ^^^^^ help: remove the `-> ()` error: unneeded unit expression --> $DIR/unused_unit.rs:40:26 | -40 | fn return_unit() -> () { () } +LL | fn return_unit() -> () { () } | ^^ help: remove the final `()` error: unneeded `()` --> $DIR/unused_unit.rs:47:14 | -47 | break(); +LL | break(); | ^^ help: remove the `()` error: unneeded `()` --> $DIR/unused_unit.rs:49:11 | -49 | return(); +LL | return(); | ^^ help: remove the `()` error: aborting due to 7 previous errors diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index 2432b7970f6..3970b68de7a 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,7 +1,7 @@ error: use of `unwrap_or` followed by a function call --> $DIR/unwrap_or.rs:13:47 | -13 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); +LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` | = note: `-D clippy::or-fun-call` implied by `-D warnings` @@ -9,7 +9,7 @@ error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call --> $DIR/unwrap_or.rs:17:47 | -17 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); +LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` error: aborting due to 2 previous errors diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 0904db2e942..82b44d424df 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,7 +1,7 @@ error: unnecessary structure name repetition --> $DIR/use_self.rs:20:21 | -20 | fn new() -> Foo { +LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` | = note: `-D clippy::use-self` implied by `-D warnings` @@ -9,122 +9,122 @@ error: unnecessary structure name repetition error: unnecessary structure name repetition --> $DIR/use_self.rs:21:13 | -21 | Foo {} +LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:23:22 | -23 | fn test() -> Foo { +LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:24:13 | -24 | Foo::new() +LL | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:29:25 | -29 | fn default() -> Foo { +LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:30:13 | -30 | Foo::new() +LL | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:96:22 | -96 | fn refs(p1: &Bad) -> &Bad { +LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:96:31 | -96 | fn refs(p1: &Bad) -> &Bad { +LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:100:37 - | -100 | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:100: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:100:53 - | -100 | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:100: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:104:30 - | -104 | fn mut_refs(p1: &mut Bad) -> &mut Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:104: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:104:43 - | -104 | fn mut_refs(p1: &mut Bad) -> &mut Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:104: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:108:28 - | -108 | fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {} - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:108:28 + | +LL | fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {} + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:108:46 - | -108 | fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {} - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:108:46 + | +LL | fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {} + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:110:20 - | -110 | fn vals(_: Bad) -> Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:110:20 + | +LL | fn vals(_: Bad) -> Bad { + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:110:28 - | -110 | fn vals(_: Bad) -> Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:110:28 + | +LL | fn vals(_: Bad) -> Bad { + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:13 - | -111 | Bad::default() - | ^^^^^^^^^^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:111:13 + | +LL | Bad::default() + | ^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:116:23 - | -116 | type Output = Bad; - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:116:23 + | +LL | type Output = Bad; + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:118:27 - | -118 | fn mul(self, rhs: Bad) -> Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:118:27 + | +LL | fn mul(self, rhs: Bad) -> Bad { + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:118:35 - | -118 | fn mul(self, rhs: Bad) -> Bad { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:118:35 + | +LL | fn mul(self, rhs: Bad) -> Bad { + | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:210:56 - | -210 | fn bad(foos: &[Self]) -> impl Iterator<Item = &Foo> { - | ^^^ help: use the applicable keyword: `Self` + --> $DIR/use_self.rs:210:56 + | +LL | fn bad(foos: &[Self]) -> impl Iterator<Item = &Foo> { + | ^^^ help: use the applicable keyword: `Self` error: aborting due to 21 previous errors diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index c844a8cd75b..798dde2ea0e 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,7 +1,7 @@ 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 | -23 | _foo + 1 +LL | _foo + 1 | ^^^^ | = note: `-D clippy::used-underscore-binding` implied by `-D warnings` @@ -9,25 +9,25 @@ error: used binding `_foo` which is prefixed with an underscore. A leading under 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 | -28 | println!("{}", _foo); +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 | -29 | assert_eq!(_foo, _foo); +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 | -29 | assert_eq!(_foo, _foo); +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 | -42 | s._underscore_field += 1; +LL | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 397ec7108d4..2e4a7f80444 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,74 +1,74 @@ error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:50:18 | -50 | foo_rstr(rstr.as_ref()); +LL | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try this: `rstr` | note: lint level defined here --> $DIR/useless_asref.rs:10:9 | -10 | #![deny(clippy::useless_asref)] +LL | #![deny(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:52:20 | -52 | foo_rslice(rslice.as_ref()); +LL | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try this: `rslice` error: this call to `as_mut` does nothing --> $DIR/useless_asref.rs:56:21 | -56 | foo_mrslice(mrslice.as_mut()); +LL | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:58:20 | -58 | foo_rslice(mrslice.as_ref()); +LL | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:65:20 | -65 | foo_rslice(rrrrrslice.as_ref()); +LL | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:67:18 | -67 | foo_rstr(rrrrrstr.as_ref()); +LL | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` error: this call to `as_mut` does nothing --> $DIR/useless_asref.rs:72:21 | -72 | foo_mrslice(mrrrrrslice.as_mut()); +LL | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:74:20 | -74 | foo_rslice(mrrrrrslice.as_ref()); +LL | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:77:16 | -77 | foo_rrrrmr((&&&&MoreRef).as_ref()); +LL | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:127:13 - | -127 | foo_mrt(mrt.as_mut()); - | ^^^^^^^^^^^^ help: try this: `mrt` + --> $DIR/useless_asref.rs:127: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 - | -129 | foo_rt(mrt.as_ref()); - | ^^^^^^^^^^^^ help: try this: `mrt` + --> $DIR/useless_asref.rs:129:12 + | +LL | foo_rt(mrt.as_ref()); + | ^^^^^^^^^^^^ help: try this: `mrt` error: aborting due to 11 previous errors diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 2dde3fd7eac..b9340ce8c02 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,7 +1,7 @@ error: useless lint attribute --> $DIR/useless_attribute.rs:12:1 | -12 | #[allow(dead_code)] +LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` | = note: `-D clippy::useless-attribute` implied by `-D warnings` @@ -9,7 +9,7 @@ error: useless lint attribute error: useless lint attribute --> $DIR/useless_attribute.rs:13:1 | -13 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` error: aborting due to 2 previous errors diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index ccd6a7d25c7..0afb95629d9 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,7 +1,7 @@ error: useless use of `vec!` --> $DIR/vec.rs:30:14 | -30 | on_slice(&vec![]); +LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` | = note: `-D clippy::useless-vec` implied by `-D warnings` @@ -9,31 +9,31 @@ error: useless use of `vec!` error: useless use of `vec!` --> $DIR/vec.rs:33:14 | -33 | on_slice(&vec![1, 2]); +LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:36:14 | -36 | on_slice(&vec![1, 2]); +LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:39:14 | -39 | on_slice(&vec!(1, 2)); +LL | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:42:14 | -42 | on_slice(&vec![1; 2]); +LL | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` --> $DIR/vec.rs:55:14 | -55 | for a in vec![1, 2, 3] { +LL | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` error: aborting due to 6 previous errors diff --git a/tests/ui/vec_box_sized.rs b/tests/ui/vec_box_sized.rs index d740f95edfe..884761675fc 100644 --- a/tests/ui/vec_box_sized.rs +++ b/tests/ui/vec_box_sized.rs @@ -1,17 +1,17 @@ struct SizedStruct { - _a: i32, + _a: i32, } struct UnsizedStruct { - _a: [i32], + _a: [i32], } struct StructWithVecBox { - sized_type: Vec<Box<SizedStruct>>, + sized_type: Vec<Box<SizedStruct>>, } struct StructWithVecBoxButItsUnsized { - unsized_type: Vec<Box<UnsizedStruct>>, + unsized_type: Vec<Box<UnsizedStruct>>, } fn main() {} diff --git a/tests/ui/vec_box_sized.stderr b/tests/ui/vec_box_sized.stderr index 7f4bdfb5aed..21b515fa486 100644 --- a/tests/ui/vec_box_sized.stderr +++ b/tests/ui/vec_box_sized.stderr @@ -1,7 +1,7 @@ error: `Vec<T>` is already on the heap, the boxing is unnecessary. - --> $DIR/vec_box_sized.rs:10:14 + --> $DIR/vec_box_sized.rs:10:17 | -10 | sized_type: Vec<Box<SizedStruct>>, +LL | sized_type: Vec<Box<SizedStruct>>, | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` | = note: `-D clippy::vec-box` implied by `-D warnings` diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index 57cfa14a392..0e6c97e48d4 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -1,13 +1,13 @@ error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:15:5 | -15 | / loop { -16 | | if let Some(_x) = y { -17 | | let _v = 1; -18 | | } else { -19 | | break; -20 | | } -21 | | } +LL | / loop { +LL | | if let Some(_x) = y { +LL | | let _v = 1; +LL | | } else { +LL | | break; +LL | | } +LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` | = note: `-D clippy::while-let-loop` implied by `-D warnings` @@ -15,54 +15,54 @@ error: this loop could be written as a `while let` loop error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:29:5 | -29 | / loop { -30 | | match y { -31 | | Some(_x) => true, -32 | | None => break, -33 | | }; -34 | | } +LL | / loop { +LL | | match y { +LL | | Some(_x) => true, +LL | | None => break, +LL | | }; +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 | -35 | / loop { -36 | | let x = match y { -37 | | Some(x) => x, -38 | | None => break, +LL | / loop { +LL | | let x = match y { +LL | | Some(x) => x, +LL | | None => break, ... | -41 | | let _str = "foo"; -42 | | } +LL | | let _str = "foo"; +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 | -43 | / loop { -44 | | let x = match y { -45 | | Some(x) => x, -46 | | None => break, +LL | / loop { +LL | | let x = match y { +LL | | Some(x) => x, +LL | | None => break, ... | -53 | | } -54 | | } +LL | | } +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 | -71 | / loop { -72 | | let (e, l) = match "".split_whitespace().next() { -73 | | Some(word) => (word.is_empty(), word.len()), -74 | | None => break, +LL | / loop { +LL | | let (e, l) = match "".split_whitespace().next() { +LL | | Some(word) => (word.is_empty(), word.len()), +LL | | None => break, ... | -77 | | let _ = (e, l); -78 | | } +LL | | let _ = (e, l); +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 | -81 | while let Option::Some(x) = iter.next() { +LL | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` | = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` @@ -70,46 +70,46 @@ error: this loop could be written as a `for` loop error: this loop could be written as a `for` loop --> $DIR/while_loop.rs:86:25 | -86 | while let Some(x) = iter.next() { +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 | -91 | while let Some(_) = iter.next() {} +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 - | -134 | / loop { -135 | | let _ = match iter.next() { -136 | | Some(ele) => ele, -137 | | None => break, -138 | | }; -139 | | loop {} -140 | | } - | |_____^ help: try: `while let Some(ele) = iter.next() { .. }` + --> $DIR/while_loop.rs:134:5 + | +LL | / loop { +LL | | let _ = match iter.next() { +LL | | Some(ele) => ele, +LL | | None => break, +LL | | }; +LL | | loop {} +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 - | -139 | loop {} - | ^^^^^^^ - | - = note: `-D clippy::empty-loop` implied by `-D warnings` + --> $DIR/while_loop.rs:139:9 + | +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 - | -197 | while let Some(v) = y.next() { - | ^^^^^^^^ help: try: `for v in y { .. }` + --> $DIR/while_loop.rs:197: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 - | -225 | while let Some(..) = values.iter().next() { - | ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }` + --> $DIR/while_loop.rs:225:26 + | +LL | while let Some(..) = values.iter().next() { + | ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }` error: aborting due to 12 previous errors diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 40c21902bf2..7daf52a4445 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,7 +1,7 @@ error: literal with an empty format string --> $DIR/write_literal.rs:36:79 | -36 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); +LL | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D clippy::write-literal` implied by `-D warnings` @@ -9,79 +9,79 @@ error: literal with an empty format string error: literal with an empty format string --> $DIR/write_literal.rs:37:32 | -37 | write!(&mut v, "Hello {}", "world"); +LL | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:38:44 | -38 | writeln!(&mut v, "Hello {} {}", world, "world"); +LL | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:39:34 | -39 | writeln!(&mut v, "Hello {}", "world"); +LL | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:40:38 | -40 | writeln!(&mut v, "10 / 4 is {}", 2.5); +LL | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string --> $DIR/write_literal.rs:41:36 | -41 | writeln!(&mut v, "2 + 1 = {}", 3); +LL | writeln!(&mut v, "2 + 1 = {}", 3); | ^ error: literal with an empty format string --> $DIR/write_literal.rs:46:33 | -46 | writeln!(&mut v, "{0} {1}", "hello", "world"); +LL | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:46:42 | -46 | writeln!(&mut v, "{0} {1}", "hello", "world"); +LL | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:47:33 | -47 | writeln!(&mut v, "{1} {0}", "hello", "world"); +LL | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:47:42 | -47 | writeln!(&mut v, "{1} {0}", "hello", "world"); +LL | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:50:43 | -50 | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); +LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:50:58 | -50 | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); +LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:51:43 | -51 | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); +LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string --> $DIR/write_literal.rs:51:58 | -51 | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); +LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index ead6b5d08a0..c18ec184876 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,7 +1,7 @@ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead --> $DIR/write_with_newline.rs:19:5 | -19 | write!(&mut v, "Hello/n"); +LL | write!(&mut v, "Hello/n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::write-with-newline` implied by `-D warnings` @@ -9,25 +9,25 @@ error: using `write!()` with a format string that ends in a single newline, cons error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead --> $DIR/write_with_newline.rs:20:5 | -20 | write!(&mut v, "Hello {}/n", "world"); +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 | -21 | write!(&mut v, "Hello {} {}/n", "world", "#2"); +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 | -22 | write!(&mut v, "{}/n", 1265); +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 | -41 | write!(&mut v, "//n"); +LL | write!(&mut v, "//n"); | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 5943dfa09b1..9b4061f0fe4 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,7 +1,7 @@ error: using `writeln!(&mut v, "")` --> $DIR/writeln_empty_string.rs:18:5 | -18 | writeln!(&mut v, ""); +LL | writeln!(&mut v, ""); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` | = note: `-D clippy::writeln-empty-string` implied by `-D warnings` @@ -9,7 +9,7 @@ error: using `writeln!(&mut v, "")` error: using `writeln!(&mut suggestion, "")` --> $DIR/writeln_empty_string.rs:21:5 | -21 | writeln!(&mut suggestion, ""); +LL | writeln!(&mut suggestion, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)` error: aborting due to 2 previous errors diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index fa97713ed78..f9d20cb3d47 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,7 +1,7 @@ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:26:17 | -26 | fn from_i32(self) {} +LL | fn from_i32(self) {} | ^^^^ | = note: `-D clippy::wrong-self-convention` implied by `-D warnings` @@ -9,67 +9,67 @@ error: methods called `from_*` usually take no self; consider choosing a less am error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:32:21 | -32 | pub fn from_i64(self) {} +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 | -44 | fn as_i32(self) {} +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 | -46 | fn into_i32(&self) {} +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 | -48 | fn is_i32(self) {} +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 | -50 | fn to_i32(self) {} +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 | -52 | fn from_i32(self) {} +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 | -54 | pub fn as_i64(self) {} +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 | -55 | pub fn into_i64(&self) {} +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 | -56 | pub fn is_i64(self) {} +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 | -57 | pub fn to_i64(self) {} +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 | -58 | pub fn from_i64(self) {} +LL | pub fn from_i64(self) {} | ^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 312392050c5..653a76c6978 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,7 +1,7 @@ error: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:13:15 | -13 | let nan = 0.0 / 0.0; +LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: #[deny(clippy::eq_op)] on by default @@ -9,7 +9,7 @@ error: equal expressions as operands to `/` error: constant division of 0.0 with 0.0 will always result in NaN --> $DIR/zero_div_zero.rs:13:15 | -13 | let nan = 0.0 / 0.0; +LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: `-D clippy::zero-divided-by-zero` implied by `-D warnings` @@ -18,13 +18,13 @@ error: constant division of 0.0 with 0.0 will always result in NaN error: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:14:19 | -14 | let f64_nan = 0.0 / 0.0f64; +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 | -14 | let f64_nan = 0.0 / 0.0f64; +LL | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN @@ -32,13 +32,13 @@ error: constant division of 0.0 with 0.0 will always result in NaN error: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:15:25 | -15 | let other_f64_nan = 0.0f64 / 0.0; +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 | -15 | let other_f64_nan = 0.0f64 / 0.0; +LL | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN @@ -46,13 +46,13 @@ error: constant division of 0.0 with 0.0 will always result in NaN error: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:16:28 | -16 | let one_more_f64_nan = 0.0f64 / 0.0f64; +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 | -16 | let one_more_f64_nan = 0.0f64 / 0.0f64; +LL | let one_more_f64_nan = 0.0f64 / 0.0f64; | ^^^^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 15b27c7c0ad..5aa5e275ee6 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -1,7 +1,7 @@ error: `0 as *const _` detected. Consider using `ptr::null()` --> $DIR/zero_ptr.rs:12:13 | -12 | let x = 0 as *const usize; +LL | let x = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::zero-ptr` implied by `-D warnings` @@ -9,7 +9,7 @@ error: `0 as *const _` detected. Consider using `ptr::null()` error: `0 as *mut _` detected. Consider using `ptr::null_mut()` --> $DIR/zero_ptr.rs:13:13 | -13 | let y = 0 as *mut f64; +LL | let y = 0 as *mut f64; | ^^^^^^^^^^^^^ error: aborting due to 2 previous errors |
