From dc4e0267f0d36b6e1b948f7200d74171a1bcdf45 Mon Sep 17 00:00:00 2001 From: onestacked Date: Sun, 9 Jul 2023 18:31:40 +0200 Subject: [PATCH 01/73] Document soundness of Integer -> Pointer -> Integer conversions in ` const` contexts. see this [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Soundness.20of.20Integer.20-.3E.20Pointer.20-.3E.20Integer.20conversions) --- library/core/src/intrinsics.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index d042aaf3084d6..509a8b63743c5 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1130,7 +1130,10 @@ extern "rust-intrinsic" { /// may lead to unexpected and unstable compilation results. This makes `transmute` **incredibly /// unsafe**. `transmute` should be the absolute last resort. /// - /// Transmuting pointers to integers in a `const` context is [undefined behavior][ub]. + /// Transmuting pointers *to* integers in a `const` context is [undefined behavior][ub], + /// unless the pointer was originally created *from* an integer. + /// (That includes this function specifically, integer-to-pointer casts, and helpers like [`invalid`][crate::ptr::invalid], + /// but also semantically-equivalent conversions such as punning through `repr(C)` union fields.) /// Any attempt to use the resulting value for integer operations will abort const-evaluation. /// (And even outside `const`, such transmutation is touching on many unspecified aspects of the /// Rust memory model and should be avoided. See below for alternatives.) From dfee1ba4c466c32d1817631e675ed458a18e088c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 3 Aug 2023 14:05:18 +0200 Subject: [PATCH 02/73] document our assumptions about symbols provided by the libc --- library/core/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 37216d6a7210b..d8531c70a8a7b 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -20,11 +20,15 @@ // FIXME: Fill me in with more detail when the interface settles //! This library is built on the assumption of a few existing symbols: //! -//! * `memcpy`, `memcmp`, `memset`, `strlen` - These are core memory routines which are -//! often generated by LLVM. Additionally, this library can make explicit -//! calls to these functions. Their signatures are the same as found in C. -//! These functions are often provided by the system libc, but can also be -//! provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins). +//! * `memcpy`, `memmove`, `memset`, `memcmp`, `bcmp`, `strlen` - These are core memory routines +//! which are generated by Rust codegen backends. Additionally, this library can make explicit +//! calls to `strlen`. Their signatures are the same as found in C, but there are extra +//! assumptions about their semantics: For `memcpy`, `memmove`, `memset`, `memcmp`, and `bcmp`, if +//! the `n` parameter is 0, the function is assumed to not be UB. Furthermore, for `memcpy`, if +//! source and target pointer are equal, the function is assumed to not be UB. +//! (Note that these are [standard assumptions](https://reviews.llvm.org/D86993) among compilers.) +//! These functions are often provided by the system libc, but can also be provided by the +//! [compiler-builtins crate](https://crates.io/crates/compiler_builtins). //! //! * `rust_begin_panic` - This function takes four arguments, a //! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments From b9c15c5d3bfb503676fffccab69fe27c5b532283 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 14 Aug 2023 09:40:09 +0200 Subject: [PATCH 03/73] clarify safety documentation of ptr::swap and ptr::copy --- library/core/src/intrinsics.rs | 3 +++ library/core/src/ptr/mod.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 9ef2c7cde02eb..84b9a3bba88e3 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2709,6 +2709,9 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us /// /// * `dst` must be [valid] for writes of `count * size_of::()` bytes. /// +/// * `src` must remain valid for reads even after `dst` is written, and vice versa. +/// (In other words, there cannot be aliasing restrictions on the use of these pointers.) +/// /// * Both `src` and `dst` must be properly aligned. /// /// Like [`read`], `copy` creates a bitwise copy of `T`, regardless of diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 5f094ac4e7e64..f8badc4130dca 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -797,6 +797,9 @@ pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { /// /// * Both `x` and `y` must be [valid] for both reads and writes. /// +/// * `x` must remain valid for reads and writes even after `y` is read/written, and vice versa. +/// (In other words, there cannot be aliasing restrictions on the use of these pointers.) +/// /// * Both `x` and `y` must be properly aligned. /// /// Note that even if `T` has size `0`, the pointers must be non-null and properly aligned. From b4714a8f00ef587677270fb0567ad48be8a9e1ab Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 14 Aug 2023 16:08:42 +0200 Subject: [PATCH 04/73] explain why we can mutate the FPU control word --- library/core/src/num/dec2flt/fpu.rs | 11 +++++++++++ library/core/src/num/dec2flt/number.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/library/core/src/num/dec2flt/fpu.rs b/library/core/src/num/dec2flt/fpu.rs index 3806977f70ee4..8d62684f8d383 100644 --- a/library/core/src/num/dec2flt/fpu.rs +++ b/library/core/src/num/dec2flt/fpu.rs @@ -8,6 +8,17 @@ pub use fpu_precision::set_precision; // round to 80 bits causing double rounding to happen when values are eventually represented as // 32/64 bit float values. To overcome this, the FPU control word can be set so that the // computations are performed in the desired precision. +// +// Note that normally, it is Undefined Behavior to alter the FPU control word while Rust code runs. +// The compiler assumes that the control word is always in its default state. However, in this +// particular case the semantics with the altered control word are actually *more faithful* +// to Rust semantics than the default -- arguably it is all the code that runs *outside* of the scope +// of a `set_precision` guard that is wrong. +// In other words, we are only using this to work around . +// Sometimes killing UB with UB actually works... +// (If this is used to set 32bit precision, there is still a risk that the compiler moves some 64bit +// operation into the scope of the `set_precision` guard. So it's not like this is totally sound. +// But it's not really any less sound than the default state of 80bit precision...) #[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] mod fpu_precision { use core::arch::asm; diff --git a/library/core/src/num/dec2flt/number.rs b/library/core/src/num/dec2flt/number.rs index 8589e2bbd4fac..2538991564ae4 100644 --- a/library/core/src/num/dec2flt/number.rs +++ b/library/core/src/num/dec2flt/number.rs @@ -51,6 +51,7 @@ impl Number { /// There is an exception: disguised fast-path cases, where we can shift /// powers-of-10 from the exponent to the significant digits. pub fn try_fast_path(&self) -> Option { + // Here we need to work around . // The fast path crucially depends on arithmetic being rounded to the correct number of bits // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit. From fb4ac63415fbf6635a59a39c078d766ba8fc4b5c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 15 Aug 2023 13:39:46 +0200 Subject: [PATCH 05/73] clarify that these assumtpions are for us, not all Rust code --- library/core/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index d8531c70a8a7b..c2602fa19eb4f 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -29,6 +29,10 @@ //! (Note that these are [standard assumptions](https://reviews.llvm.org/D86993) among compilers.) //! These functions are often provided by the system libc, but can also be provided by the //! [compiler-builtins crate](https://crates.io/crates/compiler_builtins). +//! Note that the library does not guarantee that it will always make these assumptions, so Rust +//! user code directly calling the C functions should follow the C specification! The advice for +//! Rust user code is to call the functions provided by this library instead (such as +//! `ptr::copy`). //! //! * `rust_begin_panic` - This function takes four arguments, a //! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments From 0188b9cbb43c2631111281fad0624f8bb0538e3a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 21 Aug 2023 13:54:03 +0200 Subject: [PATCH 06/73] try to clarify wording --- library/core/src/intrinsics.rs | 11 ++++++----- library/core/src/ptr/mod.rs | 7 +++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 84b9a3bba88e3..f7469008d7c00 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2705,12 +2705,13 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * `src` must be [valid] for reads of `count * size_of::()` bytes. -/// -/// * `dst` must be [valid] for writes of `count * size_of::()` bytes. +/// * `src` must be [valid] for reads of `count * size_of::()` bytes, and must remain valid even +/// if `dst` is written for `count * size_of::()` bytes. (This means if the memory ranges +/// overlap, the two pointers must not be subject to aliasing restrictions relative to each +/// other.) /// -/// * `src` must remain valid for reads even after `dst` is written, and vice versa. -/// (In other words, there cannot be aliasing restrictions on the use of these pointers.) +/// * `dst` must be [valid] for writes of `count * size_of::()` bytes, and must remain valid even +/// if `src` is read for `count * size_of::()` bytes. /// /// * Both `src` and `dst` must be properly aligned. /// diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index f8badc4130dca..69d775075f369 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -795,10 +795,9 @@ pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * Both `x` and `y` must be [valid] for both reads and writes. -/// -/// * `x` must remain valid for reads and writes even after `y` is read/written, and vice versa. -/// (In other words, there cannot be aliasing restrictions on the use of these pointers.) +/// * Both `x` and `y` must be [valid] for both reads and writes. They must remain valid even if the +/// other pointer is written. (This means if the memory ranges overlap, the two pointers must not +/// be subject to aliasing restrictions relative to each other.) /// /// * Both `x` and `y` must be properly aligned. /// From 2a270a0066c6cf1d713eedc1e096548cee5442fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anselm=20Sch=C3=BCler?= Date: Sun, 27 Aug 2023 19:16:15 +0200 Subject: [PATCH 07/73] Remove parens around .. in documentation snippet --- library/core/src/ops/range.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index ba5e6ddc752a4..cc596293ca3fe 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -11,7 +11,7 @@ use crate::hash::Hash; /// The `..` syntax is a `RangeFull`: /// /// ``` -/// assert_eq!((..), std::ops::RangeFull); +/// assert_eq!(.., std::ops::RangeFull); /// ``` /// /// It does not have an [`IntoIterator`] implementation, so you can't use it in From a293619caad49bb0e8d9a4d417bedf50f31d1b06 Mon Sep 17 00:00:00 2001 From: Sebastian Toh Date: Sun, 27 Aug 2023 20:14:56 +0800 Subject: [PATCH 08/73] Add note that str cannot be matched exhaustively --- .../src/thir/pattern/check_match.rs | 16 ++++++++++------ .../issue-105479-str-non-exhaustiveness.rs | 12 ++++++++++++ .../issue-105479-str-non-exhaustiveness.stderr | 17 +++++++++++++++++ tests/ui/pattern/usefulness/issue-30240.stderr | 2 ++ 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs create mode 100644 tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index f46cf0dc0ff1b..cce2a8c5259a4 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -735,17 +735,21 @@ fn non_exhaustive_match<'p, 'tcx>( collect_non_exhaustive_tys(&witnesses[0], &mut non_exhaustive_tys); for ty in non_exhaustive_tys { - if ty == cx.tcx.types.usize || ty == cx.tcx.types.isize { + if ty.is_ptr_sized_integral() { err.note(format!( "`{ty}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \ - exhaustively", - )); + exhaustively", + )); if cx.tcx.sess.is_nightly_build() { err.help(format!( - "add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \ - enable precise `{ty}` matching", - )); + "add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \ + enable precise `{ty}` matching", + )); } + } else if ty == cx.tcx.types.str_ { + err.note(format!( + "`{ty}` cannot be matched exhaustively, so a wildcard `_` is necessary", + )); } } } diff --git a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs new file mode 100644 index 0000000000000..faf37b07513f6 --- /dev/null +++ b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs @@ -0,0 +1,12 @@ +fn main() { + let a = ""; + let b = ""; + match (a, b) { + //~^ ERROR non-exhaustive patterns: `(&_, _)` not covered [E0004] + //~| NOTE pattern `(&_, _)` not covered + //~| NOTE the matched value is of type `(&str, &str)` + //~| NOTE `str` cannot be matched exhaustively, so a wildcard `_` is necessary + ("a", "b") => {} + ("c", "d") => {} + } +} diff --git a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr new file mode 100644 index 0000000000000..5c09b3bada6b9 --- /dev/null +++ b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: `(&_, _)` not covered + --> $DIR/issue-105479-str-non-exhaustiveness.rs:4:11 + | +LL | match (a, b) { + | ^^^^^^ pattern `(&_, _)` not covered + | + = note: the matched value is of type `(&str, &str)` + = note: `str` cannot be matched exhaustively, so a wildcard `_` is necessary +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ ("c", "d") => {}, +LL + (&_, _) => todo!() + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/issue-30240.stderr b/tests/ui/pattern/usefulness/issue-30240.stderr index ff755d681ac73..736ab34e16468 100644 --- a/tests/ui/pattern/usefulness/issue-30240.stderr +++ b/tests/ui/pattern/usefulness/issue-30240.stderr @@ -5,6 +5,7 @@ LL | match "world" { | ^^^^^^^ pattern `&_` not covered | = note: the matched value is of type `&str` + = note: `str` cannot be matched exhaustively, so a wildcard `_` is necessary help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ "hello" => {}, @@ -18,6 +19,7 @@ LL | match "world" { | ^^^^^^^ pattern `&_` not covered | = note: the matched value is of type `&str` + = note: `str` cannot be matched exhaustively, so a wildcard `_` is necessary help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ "hello" => {}, From 43dd8613a308745a9f75690bb5365f8b8ca05926 Mon Sep 17 00:00:00 2001 From: Sebastian Toh Date: Mon, 28 Aug 2023 14:25:52 +0800 Subject: [PATCH 09/73] Add note when matching on nested non-exhaustive enums --- .../src/thir/pattern/check_match.rs | 11 ++--- .../src/thir/pattern/usefulness.rs | 49 ++++++++++--------- .../match/non-exhaustive-match.stderr | 3 +- tests/ui/match/match_non_exhaustive.stderr | 3 +- .../usefulness/auxiliary/non-exhaustive.rs | 2 + .../usefulness/nested-non-exhaustive-enums.rs | 18 +++++++ .../nested-non-exhaustive-enums.stderr | 22 +++++++++ .../rfcs/rfc-2008-non-exhaustive/enum.stderr | 5 +- 8 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 tests/ui/pattern/usefulness/auxiliary/non-exhaustive.rs create mode 100644 tests/ui/pattern/usefulness/nested-non-exhaustive-enums.rs create mode 100644 tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index cce2a8c5259a4..38c24e0ab5ee3 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -720,15 +720,8 @@ fn non_exhaustive_match<'p, 'tcx>( }; }; - let is_variant_list_non_exhaustive = matches!(scrut_ty.kind(), - ty::Adt(def, _) if def.is_variant_list_non_exhaustive() && !def.did().is_local()); - adt_defined_here(cx, &mut err, scrut_ty, &witnesses); - err.note(format!( - "the matched value is of type `{}`{}", - scrut_ty, - if is_variant_list_non_exhaustive { ", which is marked as non-exhaustive" } else { "" } - )); + err.note(format!("the matched value is of type `{}`", scrut_ty)); if !is_empty_match && witnesses.len() == 1 { let mut non_exhaustive_tys = FxHashSet::default(); @@ -750,6 +743,8 @@ fn non_exhaustive_match<'p, 'tcx>( err.note(format!( "`{ty}` cannot be matched exhaustively, so a wildcard `_` is necessary", )); + } else if cx.is_foreign_non_exhaustive_enum(ty) { + err.note(format!("`{ty}` is marked as non-exhaustive")); } } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index 08cfe98bb68b9..21031e8ba9d7e 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -618,10 +618,15 @@ impl<'p, 'tcx> Usefulness<'p, 'tcx> { let new_witnesses = if let Constructor::Missing { .. } = ctor { // We got the special `Missing` constructor, so each of the missing constructors // gives a new pattern that is not caught by the match. We list those patterns. - let new_patterns = if pcx.is_non_exhaustive { - // Here we don't want the user to try to list all variants, we want them to add - // a wildcard, so we only suggest that. - vec![DeconstructedPat::wildcard(pcx.ty, pcx.span)] + if pcx.is_non_exhaustive { + witnesses + .into_iter() + // Here we don't want the user to try to list all variants, we want them to add + // a wildcard, so we only suggest that. + .map(|witness| { + witness.apply_constructor(pcx, &Constructor::NonExhaustive) + }) + .collect() } else { let mut split_wildcard = SplitWildcard::new(pcx); split_wildcard.split(pcx, matrix.heads().map(DeconstructedPat::ctor)); @@ -633,7 +638,7 @@ impl<'p, 'tcx> Usefulness<'p, 'tcx> { // constructor, that matches everything that can be built with // it. For example, if `ctor` is a `Constructor::Variant` for // `Option::Some`, we get the pattern `Some(_)`. - let mut new: Vec> = split_wildcard + let mut new_patterns: Vec> = split_wildcard .iter_missing(pcx) .filter_map(|missing_ctor| { // Check if this variant is marked `doc(hidden)` @@ -648,27 +653,25 @@ impl<'p, 'tcx> Usefulness<'p, 'tcx> { .collect(); if hide_variant_show_wild { - new.push(DeconstructedPat::wildcard(pcx.ty, pcx.span)); + new_patterns.push(DeconstructedPat::wildcard(pcx.ty, pcx.span)); } - new - }; - - witnesses - .into_iter() - .flat_map(|witness| { - new_patterns.iter().map(move |pat| { - Witness( - witness - .0 - .iter() - .chain(once(pat)) - .map(DeconstructedPat::clone_and_forget_reachability) - .collect(), - ) + witnesses + .into_iter() + .flat_map(|witness| { + new_patterns.iter().map(move |pat| { + Witness( + witness + .0 + .iter() + .chain(once(pat)) + .map(DeconstructedPat::clone_and_forget_reachability) + .collect(), + ) + }) }) - }) - .collect() + .collect() + } } else { witnesses .into_iter() diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index 3a5fad15421c6..fddd769c3dfc3 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -45,7 +45,8 @@ note: `E2` defined here | LL | pub enum E2 { A, B } | ^^^^^^^^^^^ - = note: the matched value is of type `E2`, which is marked as non-exhaustive + = note: the matched value is of type `E2` + = note: `E2` is marked as non-exhaustive help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; diff --git a/tests/ui/match/match_non_exhaustive.stderr b/tests/ui/match/match_non_exhaustive.stderr index 46ee8d5179e6b..d07e284e299bb 100644 --- a/tests/ui/match/match_non_exhaustive.stderr +++ b/tests/ui/match/match_non_exhaustive.stderr @@ -45,7 +45,8 @@ note: `E2` defined here | LL | pub enum E2 { A, B } | ^^^^^^^^^^^ - = note: the matched value is of type `E2`, which is marked as non-exhaustive + = note: the matched value is of type `E2` + = note: `E2` is marked as non-exhaustive help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | match e2 { E2::A => (), E2::B => (), _ => todo!() }; diff --git a/tests/ui/pattern/usefulness/auxiliary/non-exhaustive.rs b/tests/ui/pattern/usefulness/auxiliary/non-exhaustive.rs new file mode 100644 index 0000000000000..6f459b8268f6f --- /dev/null +++ b/tests/ui/pattern/usefulness/auxiliary/non-exhaustive.rs @@ -0,0 +1,2 @@ +#[non_exhaustive] +pub enum NonExhaustiveEnum { A, B } diff --git a/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.rs b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.rs new file mode 100644 index 0000000000000..3a8a74d1fd65f --- /dev/null +++ b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.rs @@ -0,0 +1,18 @@ +// aux-build:non-exhaustive.rs + +extern crate non_exhaustive; + +use non_exhaustive::NonExhaustiveEnum; + +fn main() { + match Some(NonExhaustiveEnum::A) { + //~^ ERROR non-exhaustive patterns: `Some(_)` not covered [E0004] + //~| NOTE pattern `Some(_)` not covered + //~| NOTE `Option` defined here + //~| NOTE the matched value is of type `Option` + //~| NOTE `NonExhaustiveEnum` is marked as non-exhaustive + Some(NonExhaustiveEnum::A) => {} + Some(NonExhaustiveEnum::B) => {} + None => {} + } +} diff --git a/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr new file mode 100644 index 0000000000000..ae81f307fde34 --- /dev/null +++ b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr @@ -0,0 +1,22 @@ +error[E0004]: non-exhaustive patterns: `Some(_)` not covered + --> $DIR/nested-non-exhaustive-enums.rs:8:11 + | +LL | match Some(NonExhaustiveEnum::A) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Some(_)` not covered + | +note: `Option` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + ::: $SRC_DIR/core/src/option.rs:LL:COL + | + = note: not covered + = note: the matched value is of type `Option` + = note: `NonExhaustiveEnum` is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ None => {}, +LL + Some(_) => todo!() + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr index 872cb9b8bc68e..50209e18bd173 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr @@ -28,7 +28,8 @@ note: `NonExhaustiveEnum` defined here | LL | pub enum NonExhaustiveEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive + = note: the matched value is of type `NonExhaustiveEnum` + = note: `NonExhaustiveEnum` is marked as non-exhaustive help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ NonExhaustiveEnum::Struct { .. } => "third", @@ -46,7 +47,7 @@ note: `NonExhaustiveEnum` defined here | LL | pub enum NonExhaustiveEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive + = note: the matched value is of type `NonExhaustiveEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ match enum_unit { From 56c17dc280c32112a9adf2cc69c845aa90d18dc4 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 28 Aug 2023 10:30:48 +0100 Subject: [PATCH 10/73] Add tests for struct literals in if let/while let --- tests/ui/parser/struct-literal-in-if.rs | 5 +++++ tests/ui/parser/struct-literal-in-if.stderr | 18 +++++++++++++++++- tests/ui/parser/struct-literal-in-while.rs | 5 +++++ tests/ui/parser/struct-literal-in-while.stderr | 18 +++++++++++++++++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/tests/ui/parser/struct-literal-in-if.rs b/tests/ui/parser/struct-literal-in-if.rs index 2ce2c8f189944..c4a253c3da25a 100644 --- a/tests/ui/parser/struct-literal-in-if.rs +++ b/tests/ui/parser/struct-literal-in-if.rs @@ -14,4 +14,9 @@ fn main() { }.hi() { println!("yo"); } + if let true = Foo { //~ ERROR struct literals are not allowed here + x: 3 + }.hi() { + println!("yo"); + } } diff --git a/tests/ui/parser/struct-literal-in-if.stderr b/tests/ui/parser/struct-literal-in-if.stderr index b5a9864bbc4c4..8b72469fcf582 100644 --- a/tests/ui/parser/struct-literal-in-if.stderr +++ b/tests/ui/parser/struct-literal-in-if.stderr @@ -14,5 +14,21 @@ LL | x: 3 LL ~ }).hi() { | -error: aborting due to previous error +error: struct literals are not allowed here + --> $DIR/struct-literal-in-if.rs:17:19 + | +LL | if let true = Foo { + | ___________________^ +LL | | x: 3 +LL | | }.hi() { + | |_____^ + | +help: surround the struct literal with parentheses + | +LL ~ if let true = (Foo { +LL | x: 3 +LL ~ }).hi() { + | + +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/struct-literal-in-while.rs b/tests/ui/parser/struct-literal-in-while.rs index 5000ce85b7f71..86931f7888dd8 100644 --- a/tests/ui/parser/struct-literal-in-while.rs +++ b/tests/ui/parser/struct-literal-in-while.rs @@ -14,4 +14,9 @@ fn main() { }.hi() { println!("yo"); } + while let true = Foo { //~ ERROR struct literals are not allowed here + x: 3 + }.hi() { + println!("yo"); + } } diff --git a/tests/ui/parser/struct-literal-in-while.stderr b/tests/ui/parser/struct-literal-in-while.stderr index 17e9277e07413..13d003608a1b0 100644 --- a/tests/ui/parser/struct-literal-in-while.stderr +++ b/tests/ui/parser/struct-literal-in-while.stderr @@ -14,5 +14,21 @@ LL | x: 3 LL ~ }).hi() { | -error: aborting due to previous error +error: struct literals are not allowed here + --> $DIR/struct-literal-in-while.rs:17:22 + | +LL | while let true = Foo { + | ______________________^ +LL | | x: 3 +LL | | }.hi() { + | |_____^ + | +help: surround the struct literal with parentheses + | +LL ~ while let true = (Foo { +LL | x: 3 +LL ~ }).hi() { + | + +error: aborting due to 2 previous errors From 89235fd8379d6b1b0bcea704e162ba3d314906da Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 28 Aug 2023 10:31:45 +0100 Subject: [PATCH 11/73] Allow stuct literals in if let guards This is consistent with normal match guards. --- compiler/rustc_parse/src/parser/expr.rs | 4 +--- tests/ui/parser/struct-literal-in-match-guard.rs | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 9ae3ef6172c73..5898c6565e6ef 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2477,9 +2477,7 @@ impl<'a> Parser<'a> { } else { self.expect(&token::Eq)?; } - let expr = self.with_res(self.restrictions | Restrictions::NO_STRUCT_LITERAL, |this| { - this.parse_expr_assoc_with(1 + prec_let_scrutinee_needs_par(), None.into()) - })?; + let expr = self.parse_expr_assoc_with(1 + prec_let_scrutinee_needs_par(), None.into())?; let span = lo.to(expr.span); self.sess.gated_spans.gate(sym::let_chains, span); Ok(self.mk_expr(span, ExprKind::Let(pat, expr, span))) diff --git a/tests/ui/parser/struct-literal-in-match-guard.rs b/tests/ui/parser/struct-literal-in-match-guard.rs index bf0551b5c97b0..bbee60e281732 100644 --- a/tests/ui/parser/struct-literal-in-match-guard.rs +++ b/tests/ui/parser/struct-literal-in-match-guard.rs @@ -3,6 +3,8 @@ // Unlike `if` condition, `match` guards accept struct literals. // This is detected in . +#![feature(if_let_guard)] + #[derive(PartialEq)] struct Foo { x: isize, @@ -11,6 +13,7 @@ struct Foo { fn foo(f: Foo) { match () { () if f == Foo { x: 42 } => {} + () if let Foo { x: 0.. } = Foo { x: 42 } => {} _ => {} } } From 4429ccfa9ff6f0d540ea5ccfb51b548d71c46125 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 28 Aug 2023 11:57:32 -0400 Subject: [PATCH 12/73] Reference uplifted clippy lints' rustc name in the release notes I updated to Rust 1.72.0, got a new warning from rustc, wanted to read more about it, so I went to RELEASES.md and searched for the new lint's name as shown in the warning I got. I found no results because the relevant entry in RELEASES only contained the lint's old Clippy name, not its new rustc name. This adds the rustc name for lints so that someone doing the same thing I did will have more success. Some of the uplifted lints didn't have a name change, so I didn't add the rustc name as a search for it will succeed. --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 242b1c2eefd28..5431df06d50d7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -10,9 +10,9 @@ Language - [expand: Change how `#![cfg(FALSE)]` behaves on crate root](https://github.com/rust-lang/rust/pull/110141/) - [Stabilize inline asm for LoongArch64](https://github.com/rust-lang/rust/pull/111235/) - [Uplift `clippy::undropped_manually_drops` lint](https://github.com/rust-lang/rust/pull/111530/) -- [Uplift `clippy::invalid_utf8_in_unchecked` lint](https://github.com/rust-lang/rust/pull/111543/) +- [Uplift `clippy::invalid_utf8_in_unchecked` lint](https://github.com/rust-lang/rust/pull/111543/) as `invalid_from_utf8_unchecked` and `invalid_from_utf8` - [Uplift `clippy::cast_ref_to_mut` lint](https://github.com/rust-lang/rust/pull/111567/) -- [Uplift `clippy::cmp_nan` lint](https://github.com/rust-lang/rust/pull/111818/) +- [Uplift `clippy::cmp_nan` lint](https://github.com/rust-lang/rust/pull/111818/) as `invalid_nan_comparisons` - [resolve: Remove artificial import ambiguity errors](https://github.com/rust-lang/rust/pull/112086/) - [Don't require associated types with Self: Sized bounds in `dyn Trait` objects](https://github.com/rust-lang/rust/pull/112319/) From b295d3e55e5a719a215710bb678de4e3a7f1420f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 29 Aug 2023 15:30:15 +0200 Subject: [PATCH 13/73] Add `fmease` to rustdoc review rotations --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index 7aaf90d49a7a1..4b4af9b640e5c 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -626,6 +626,7 @@ rustdoc = [ "@jsha", "@GuillaumeGomez", "@notriddle", + "@fmease", ] docs = [ "@ehuss", From 456007af125d3822285135659ea5ea0b67084b66 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Tue, 29 Aug 2023 19:29:14 +0200 Subject: [PATCH 14/73] Emit error instead of ICE when optimized MIR is missing Closes 51388. --- compiler/rustc_monomorphize/messages.ftl | 4 ++++ compiler/rustc_monomorphize/src/collector.rs | 8 ++++++-- compiler/rustc_monomorphize/src/errors.rs | 10 +++++++++- tests/ui/rmeta/auxiliary/rmeta-meta.rs | 4 ++++ tests/ui/rmeta/no_optitimized_mir.rs | 11 +++++++++++ tests/ui/rmeta/no_optitimized_mir.stderr | 10 ++++++++++ 6 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 tests/ui/rmeta/no_optitimized_mir.rs create mode 100644 tests/ui/rmeta/no_optitimized_mir.stderr diff --git a/compiler/rustc_monomorphize/messages.ftl b/compiler/rustc_monomorphize/messages.ftl index fdd47e6f79bd8..2b7d9bd341393 100644 --- a/compiler/rustc_monomorphize/messages.ftl +++ b/compiler/rustc_monomorphize/messages.ftl @@ -14,6 +14,10 @@ monomorphize_large_assignments = .label = value moved from here .note = The current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +monomorphize_no_optimized_mir = + missing optimized MIR for an item in the crate `{$crate_name}` + .note = missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?) + monomorphize_recursion_limit = reached the recursion limit while instantiating `{$shrunk}` .note = `{$def_path_str}` defined here diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index f917e52109a83..dfe534d5b656a 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -192,7 +192,8 @@ use rustc_target::abi::Size; use std::path::PathBuf; use crate::errors::{ - EncounteredErrorWhileInstantiating, LargeAssignmentsLint, RecursionLimit, TypeLengthLimit, + EncounteredErrorWhileInstantiating, LargeAssignmentsLint, NoOptimizedMir, RecursionLimit, + TypeLengthLimit, }; #[derive(PartialEq)] @@ -950,7 +951,10 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) -> } if !tcx.is_mir_available(def_id) { - bug!("no MIR available for {:?}", def_id); + tcx.sess.emit_fatal(NoOptimizedMir { + span: tcx.def_span(def_id), + crate_name: tcx.crate_name(def_id.krate), + }); } true diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index 495a73490a217..fdcc95f137f76 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -4,7 +4,7 @@ use crate::fluent_generated as fluent; use rustc_errors::ErrorGuaranteed; use rustc_errors::IntoDiagnostic; use rustc_macros::{Diagnostic, LintDiagnostic}; -use rustc_span::Span; +use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] #[diag(monomorphize_recursion_limit)] @@ -33,6 +33,14 @@ pub struct TypeLengthLimit { pub type_length: usize, } +#[derive(Diagnostic)] +#[diag(monomorphize_no_optimized_mir)] +pub struct NoOptimizedMir { + #[note] + pub span: Span, + pub crate_name: Symbol, +} + pub struct UnusedGenericParamsHint { pub span: Span, pub param_spans: Vec, diff --git a/tests/ui/rmeta/auxiliary/rmeta-meta.rs b/tests/ui/rmeta/auxiliary/rmeta-meta.rs index 6d8ed95bd3863..6d43504952729 100644 --- a/tests/ui/rmeta/auxiliary/rmeta-meta.rs +++ b/tests/ui/rmeta/auxiliary/rmeta-meta.rs @@ -6,3 +6,7 @@ pub struct Foo { pub field: i32, } + +pub fn missing_optimized_mir() { + println!("indeed"); +} diff --git a/tests/ui/rmeta/no_optitimized_mir.rs b/tests/ui/rmeta/no_optitimized_mir.rs new file mode 100644 index 0000000000000..c503005f16baf --- /dev/null +++ b/tests/ui/rmeta/no_optitimized_mir.rs @@ -0,0 +1,11 @@ +// aux-build:rmeta-meta.rs +// no-prefer-dynamic +// build-fail + +// Check that we do not ICE when we need optimized MIR but it is missing. + +extern crate rmeta_meta; + +fn main() { + rmeta_meta::missing_optimized_mir(); +} diff --git a/tests/ui/rmeta/no_optitimized_mir.stderr b/tests/ui/rmeta/no_optitimized_mir.stderr new file mode 100644 index 0000000000000..a17024c5310d1 --- /dev/null +++ b/tests/ui/rmeta/no_optitimized_mir.stderr @@ -0,0 +1,10 @@ +error: missing optimized MIR for an item in the crate `rmeta_meta` + | +note: missing optimized MIR for this item (was the crate `rmeta_meta` compiled with `--emit=metadata`?) + --> $DIR/auxiliary/rmeta-meta.rs:10:1 + | +LL | pub fn missing_optimized_mir() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From 695068903034e326fa2d58bee8314bef903ce54f Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 1 Sep 2023 19:12:37 +0300 Subject: [PATCH 15/73] remove some unused crate deps --- Cargo.lock | 4 ---- compiler/rustc_query_impl/Cargo.toml | 1 - compiler/rustc_traits/Cargo.toml | 3 --- 3 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84a668b5188ce..bdbafb8623bb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4228,7 +4228,6 @@ dependencies = [ "measureme", "memoffset", "rustc-rayon-core", - "rustc_ast", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -4437,15 +4436,12 @@ dependencies = [ name = "rustc_traits" version = "0.0.0" dependencies = [ - "rustc_ast", "rustc_data_structures", "rustc_hir", "rustc_infer", "rustc_middle", "rustc_span", - "rustc_target", "rustc_trait_selection", - "smallvec", "tracing", ] diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index ac697a3ae3e99..a44dd5ede2fd2 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -9,7 +9,6 @@ edition = "2021" [dependencies] field-offset = "0.3.5" measureme = "10.0.0" -rustc_ast = { path = "../rustc_ast" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_hir = { path = "../rustc_hir" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 37e00c0e4bcff..0cdc978a3d022 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -8,9 +8,6 @@ tracing = "0.1" rustc_middle = { path = "../rustc_middle" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_hir = { path = "../rustc_hir" } -rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -rustc_target = { path = "../rustc_target" } -smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From 6cec91d6470eebcc6dd16e15eaca09d39769a8e5 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 19 Aug 2023 09:01:16 +0000 Subject: [PATCH 16/73] Support debuginfo for custom MIR. --- .../rustc_mir_build/src/build/custom/parse.rs | 57 ++++++++++++++- .../src/build/custom/parse/instruction.rs | 2 +- library/core/src/intrinsics/mir.rs | 30 +++++--- .../custom/debuginfo.numbered.built.after.mir | 11 +++ .../custom/debuginfo.pointee.built.after.mir | 10 +++ tests/mir-opt/building/custom/debuginfo.rs | 71 +++++++++++++++++++ .../debuginfo.structured.built.after.mir | 10 +++ .../custom/debuginfo.variant.built.after.mir | 10 +++ .../debuginfo.variant_deref.built.after.mir | 11 +++ 9 files changed, 201 insertions(+), 11 deletions(-) create mode 100644 tests/mir-opt/building/custom/debuginfo.numbered.built.after.mir create mode 100644 tests/mir-opt/building/custom/debuginfo.pointee.built.after.mir create mode 100644 tests/mir-opt/building/custom/debuginfo.rs create mode 100644 tests/mir-opt/building/custom/debuginfo.structured.built.after.mir create mode 100644 tests/mir-opt/building/custom/debuginfo.variant.built.after.mir create mode 100644 tests/mir-opt/building/custom/debuginfo.variant_deref.built.after.mir diff --git a/compiler/rustc_mir_build/src/build/custom/parse.rs b/compiler/rustc_mir_build/src/build/custom/parse.rs index 60c4a041696bc..f83c62fd580b8 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse.rs @@ -1,5 +1,6 @@ use rustc_index::IndexSlice; -use rustc_middle::{mir::*, thir::*, ty::Ty}; +use rustc_middle::ty::{self, Ty}; +use rustc_middle::{mir::*, thir::*}; use rustc_span::Span; use super::{PResult, ParseCtxt, ParseError}; @@ -159,6 +160,14 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { ); self.parse_local_decls(local_decls.iter().copied())?; + let (debuginfo, rest) = parse_by_kind!(self, rest, _, "body with debuginfo", + ExprKind::Block { block } => { + let block = &self.thir[*block]; + (&block.stmts, block.expr.unwrap()) + }, + ); + self.parse_debuginfo(debuginfo.iter().copied())?; + let block_defs = parse_by_kind!(self, rest, _, "body with block defs", ExprKind::Block { block } => &self.thir[*block].stmts, ); @@ -195,6 +204,52 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { Ok(()) } + fn parse_debuginfo(&mut self, stmts: impl Iterator) -> PResult<()> { + for stmt in stmts { + let stmt = &self.thir[stmt]; + let expr = match stmt.kind { + StmtKind::Let { span, .. } => { + return Err(ParseError { + span, + item_description: format!("{:?}", stmt), + expected: "debuginfo".to_string(), + }); + } + StmtKind::Expr { expr, .. } => expr, + }; + let span = self.thir[expr].span; + let (name, operand) = parse_by_kind!(self, expr, _, "debuginfo", + @call("mir_debuginfo", args) => { + (args[0], args[1]) + }, + ); + let name = parse_by_kind!(self, name, _, "debuginfo", + ExprKind::Literal { lit, neg: false } => lit, + ); + let Some(name) = name.node.str() else { + return Err(ParseError { + span, + item_description: format!("{:?}", name), + expected: "string".to_string(), + }); + }; + let operand = self.parse_operand(operand)?; + let value = match operand { + Operand::Constant(c) => VarDebugInfoContents::Const(*c), + Operand::Copy(p) | Operand::Move(p) => VarDebugInfoContents::Place(p), + }; + let dbginfo = VarDebugInfo { + name, + source_info: SourceInfo { span, scope: self.source_scope }, + argument_index: None, + value, + }; + self.body.var_debug_info.push(dbginfo); + } + + Ok(()) + } + fn parse_let_statement(&mut self, stmt_id: StmtId) -> PResult<(LocalVarId, Ty<'tcx>, Span)> { let pattern = match &self.thir[stmt_id].kind { StmtKind::Let { pattern, .. } => pattern, diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs index 26662f5de459f..da5f2b1bcc99c 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs @@ -204,7 +204,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { ) } - fn parse_operand(&self, expr_id: ExprId) -> PResult> { + pub fn parse_operand(&self, expr_id: ExprId) -> PResult> { parse_by_kind!(self, expr_id, expr, "operand", @call("mir_move", args) => self.parse_place(args[0]).map(Operand::Move), @call("mir_static", args) => self.parse_static(args[0]), diff --git a/library/core/src/intrinsics/mir.rs b/library/core/src/intrinsics/mir.rs index b99346b6ba608..02c6f0295fc64 100644 --- a/library/core/src/intrinsics/mir.rs +++ b/library/core/src/intrinsics/mir.rs @@ -361,6 +361,11 @@ define!( #[doc(hidden)] fn __internal_make_place(place: T) -> *mut T ); +define!( + "mir_debuginfo", + #[doc(hidden)] + fn __debuginfo(name: &'static str, s: T) +); /// Macro for generating custom MIR. /// @@ -371,6 +376,7 @@ pub macro mir { ( $(type RET = $ret_ty:ty ;)? $(let $local_decl:ident $(: $local_decl_ty:ty)? ;)* + $(debug $dbg_name:ident => $dbg_data:expr ;)* { $($entry:tt)* @@ -394,26 +400,32 @@ pub macro mir { $( let $local_decl $(: $local_decl_ty)? ; )* - ::core::intrinsics::mir::__internal_extract_let!($($entry)*); $( ::core::intrinsics::mir::__internal_extract_let!($($block)*); )* { - // Finally, the contents of the basic blocks - ::core::intrinsics::mir::__internal_remove_let!({ - {} - { $($entry)* } - }); + // Now debuginfo $( + __debuginfo(stringify!($dbg_name), $dbg_data); + )* + + { + // Finally, the contents of the basic blocks ::core::intrinsics::mir::__internal_remove_let!({ {} - { $($block)* } + { $($entry)* } }); - )* + $( + ::core::intrinsics::mir::__internal_remove_let!({ + {} + { $($block)* } + }); + )* - RET + RET + } } } }} diff --git a/tests/mir-opt/building/custom/debuginfo.numbered.built.after.mir b/tests/mir-opt/building/custom/debuginfo.numbered.built.after.mir new file mode 100644 index 0000000000000..d863925371812 --- /dev/null +++ b/tests/mir-opt/building/custom/debuginfo.numbered.built.after.mir @@ -0,0 +1,11 @@ +// MIR for `numbered` after built + +fn numbered(_1: (u32, i32)) -> () { + debug first => (_1.0: u32); + debug second => (_1.0: u32); + let mut _0: (); + + bb0: { + return; + } +} diff --git a/tests/mir-opt/building/custom/debuginfo.pointee.built.after.mir b/tests/mir-opt/building/custom/debuginfo.pointee.built.after.mir new file mode 100644 index 0000000000000..86cced6f801f4 --- /dev/null +++ b/tests/mir-opt/building/custom/debuginfo.pointee.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `pointee` after built + +fn pointee(_1: &mut Option) -> () { + debug foo => (((*_1) as variant#1).0: i32); + let mut _0: (); + + bb0: { + return; + } +} diff --git a/tests/mir-opt/building/custom/debuginfo.rs b/tests/mir-opt/building/custom/debuginfo.rs new file mode 100644 index 0000000000000..bfdc3d3eacd44 --- /dev/null +++ b/tests/mir-opt/building/custom/debuginfo.rs @@ -0,0 +1,71 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR debuginfo.pointee.built.after.mir +#[custom_mir(dialect = "built")] +fn pointee(opt: &mut Option) { + mir!( + debug foo => Field::(Variant(*opt, 1), 0); + { + Return() + } + ) +} + +// EMIT_MIR debuginfo.numbered.built.after.mir +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn numbered(i: (u32, i32)) { + mir!( + debug first => i.0; + debug second => i.0; + { + Return() + } + ) +} + +struct S { x: f32 } + +// EMIT_MIR debuginfo.structured.built.after.mir +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn structured(i: S) { + mir!( + debug x => i.x; + { + Return() + } + ) +} + +// EMIT_MIR debuginfo.variant.built.after.mir +#[custom_mir(dialect = "built")] +fn variant(opt: Option) { + mir!( + debug inner => Field::(Variant(opt, 1), 0); + { + Return() + } + ) +} + +// EMIT_MIR debuginfo.variant_deref.built.after.mir +#[custom_mir(dialect = "built")] +fn variant_deref(opt: Option<&i32>) { + mir!( + debug pointer => Field::<&i32>(Variant(opt, 1), 0); + debug deref => *Field::<&i32>(Variant(opt, 1), 0); + { + Return() + } + ) +} + +fn main() { + numbered((5, 6)); + structured(S { x: 5. }); + variant(Some(5)); + variant_deref(Some(&5)); + pointee(&mut Some(5)); +} diff --git a/tests/mir-opt/building/custom/debuginfo.structured.built.after.mir b/tests/mir-opt/building/custom/debuginfo.structured.built.after.mir new file mode 100644 index 0000000000000..d122b6bfe29a4 --- /dev/null +++ b/tests/mir-opt/building/custom/debuginfo.structured.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `structured` after built + +fn structured(_1: S) -> () { + debug x => (_1.0: f32); + let mut _0: (); + + bb0: { + return; + } +} diff --git a/tests/mir-opt/building/custom/debuginfo.variant.built.after.mir b/tests/mir-opt/building/custom/debuginfo.variant.built.after.mir new file mode 100644 index 0000000000000..d173723fd8922 --- /dev/null +++ b/tests/mir-opt/building/custom/debuginfo.variant.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `variant` after built + +fn variant(_1: Option) -> () { + debug inner => ((_1 as variant#1).0: i32); + let mut _0: (); + + bb0: { + return; + } +} diff --git a/tests/mir-opt/building/custom/debuginfo.variant_deref.built.after.mir b/tests/mir-opt/building/custom/debuginfo.variant_deref.built.after.mir new file mode 100644 index 0000000000000..37d5d1b2dfc0b --- /dev/null +++ b/tests/mir-opt/building/custom/debuginfo.variant_deref.built.after.mir @@ -0,0 +1,11 @@ +// MIR for `variant_deref` after built + +fn variant_deref(_1: Option<&i32>) -> () { + debug pointer => ((_1 as variant#1).0: &i32); + debug deref => (*((_1 as variant#1).0: &i32)); + let mut _0: (); + + bb0: { + return; + } +} From 905fd1ba17617c273f7ff04fbb23e7253ccd77c4 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 20 Aug 2023 16:50:08 +0000 Subject: [PATCH 17/73] Support bootstrap. --- library/core/src/intrinsics/mir.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/core/src/intrinsics/mir.rs b/library/core/src/intrinsics/mir.rs index 02c6f0295fc64..cab195dad9b05 100644 --- a/library/core/src/intrinsics/mir.rs +++ b/library/core/src/intrinsics/mir.rs @@ -12,7 +12,8 @@ //! //! Typical usage will look like this: //! -//! ```rust +#![cfg_attr(bootstrap, doc = "```rust,ignore")] +#![cfg_attr(not(bootstrap), doc = "```rust")] //! #![feature(core_intrinsics, custom_mir)] //! #![allow(internal_features)] //! @@ -62,7 +63,8 @@ //! //! # Examples //! -//! ```rust +#![cfg_attr(bootstrap, doc = "```rust,ignore")] +#![cfg_attr(not(bootstrap), doc = "```rust")] //! #![feature(core_intrinsics, custom_mir)] //! #![allow(internal_features)] //! @@ -317,7 +319,8 @@ define!( /// /// # Examples /// - /// ```rust + #[cfg_attr(bootstrap, doc = "```rust,ignore")] + #[cfg_attr(not(bootstrap), doc = "```rust")] /// #![allow(internal_features)] /// #![feature(custom_mir, core_intrinsics)] /// From cfd7ab3a3e115b4c5a6e2deb849dae337a0eaae1 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Fri, 1 Sep 2023 20:39:41 +0300 Subject: [PATCH 18/73] bump pretty_assertions to 1.4 Removes the duplicated dependency(syn 1.0.102) from bootstrap dependency tree Signed-off-by: onur-ozkan --- src/bootstrap/Cargo.lock | 40 ++++------------------------------------ src/bootstrap/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index ecb58a0e9a5f6..5291f68f4208f 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -142,7 +142,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.8", + "syn", ] [[package]] @@ -228,16 +228,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctor" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" -dependencies = [ - "quote", - "syn 1.0.102", -] - [[package]] name = "diff" version = "0.1.12" @@ -502,15 +492,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] - [[package]] name = "pkg-config" version = "0.3.25" @@ -519,13 +500,11 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ - "ctor", "diff", - "output_vt100", "yansi", ] @@ -657,7 +636,7 @@ checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn", ] [[package]] @@ -682,17 +661,6 @@ dependencies = [ "digest", ] -[[package]] -name = "syn" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.8" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 74b9a23fa4e17..9bf26948af3aa 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -78,7 +78,7 @@ features = [ ] [dev-dependencies] -pretty_assertions = "1.2" +pretty_assertions = "1.4" [features] build-metrics = ["sysinfo"] From 2a5a6bcb82abf9ae604c2f889b3c8733fcdb6b68 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Fri, 1 Sep 2023 20:55:22 +0300 Subject: [PATCH 19/73] bump hermit-abi from yanked version(0.3.1) to 0.3.2 Signed-off-by: onur-ozkan --- src/bootstrap/Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 5291f68f4208f..f5220e361b34a 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -340,9 +340,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -374,7 +374,7 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys", ] From c5d0f6c05cbdab02b803c8a72ec8accc01b83e07 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 29 Aug 2023 21:50:01 +0000 Subject: [PATCH 20/73] Don't manually walk through param indices when adding implicit Sized and ConstParamHasTy --- .../rustc_hir_analysis/src/astconv/mod.rs | 73 +++++--- .../src/collect/predicates_of.rs | 34 +--- .../src/collect/resolve_bound_vars.rs | 167 +++++++++--------- 3 files changed, 145 insertions(+), 129 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 7a6856fb1f4b7..90f64e18632a1 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -2205,27 +2205,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { err.span_note(span, format!("type parameter `{name}` defined here")); } }); - - match tcx.named_bound_var(hir_id) { - Some(rbv::ResolvedArg::LateBound(debruijn, index, _)) => { - let name = - tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id.expect_local())); - let br = ty::BoundTy { - var: ty::BoundVar::from_u32(index), - kind: ty::BoundTyKind::Param(def_id, name), - }; - Ty::new_bound(tcx, debruijn, br) - } - Some(rbv::ResolvedArg::EarlyBound(_)) => { - let def_id = def_id.expect_local(); - let item_def_id = tcx.hir().ty_param_owner(def_id); - let generics = tcx.generics_of(item_def_id); - let index = generics.param_def_id_to_index[&def_id.to_def_id()]; - Ty::new_param(tcx, index, tcx.hir().ty_param_name(def_id)) - } - Some(rbv::ResolvedArg::Error(guar)) => Ty::new_error(tcx, guar), - arg => bug!("unexpected bound var resolution for {hir_id:?}: {arg:?}"), - } + self.hir_id_to_bound_ty(hir_id) } Res::SelfTyParam { .. } => { // `Self` in trait or type alias. @@ -2394,6 +2374,57 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } } + // Converts a hir id corresponding to a type parameter to + // a early-bound `ty::Param` or late-bound `ty::Bound`. + pub(crate) fn hir_id_to_bound_ty(&self, hir_id: hir::HirId) -> Ty<'tcx> { + let tcx = self.tcx(); + match tcx.named_bound_var(hir_id) { + Some(rbv::ResolvedArg::LateBound(debruijn, index, def_id)) => { + let name = tcx.item_name(def_id); + let br = ty::BoundTy { + var: ty::BoundVar::from_u32(index), + kind: ty::BoundTyKind::Param(def_id, name), + }; + Ty::new_bound(tcx, debruijn, br) + } + Some(rbv::ResolvedArg::EarlyBound(def_id)) => { + let def_id = def_id.expect_local(); + let item_def_id = tcx.hir().ty_param_owner(def_id); + let generics = tcx.generics_of(item_def_id); + let index = generics.param_def_id_to_index[&def_id.to_def_id()]; + Ty::new_param(tcx, index, tcx.hir().ty_param_name(def_id)) + } + Some(rbv::ResolvedArg::Error(guar)) => Ty::new_error(tcx, guar), + arg => bug!("unexpected bound var resolution for {hir_id:?}: {arg:?}"), + } + } + + // Converts a hir id corresponding to a const parameter to + // a early-bound `ConstKind::Param` or late-bound `ConstKind::Bound`. + pub(crate) fn hir_id_to_bound_const( + &self, + hir_id: hir::HirId, + param_ty: Ty<'tcx>, + ) -> Const<'tcx> { + let tcx = self.tcx(); + match tcx.named_bound_var(hir_id) { + Some(rbv::ResolvedArg::EarlyBound(def_id)) => { + // Find the name and index of the const parameter by indexing the generics of + // the parent item and construct a `ParamConst`. + let item_def_id = tcx.parent(def_id); + let generics = tcx.generics_of(item_def_id); + let index = generics.param_def_id_to_index[&def_id]; + let name = tcx.item_name(def_id); + ty::Const::new_param(tcx, ty::ParamConst::new(index, name), param_ty) + } + Some(rbv::ResolvedArg::LateBound(debruijn, index, _)) => { + ty::Const::new_bound(tcx, debruijn, ty::BoundVar::from_u32(index), param_ty) + } + Some(rbv::ResolvedArg::Error(guar)) => ty::Const::new_error(tcx, guar, param_ty), + arg => bug!("unexpected bound var resolution for {:?}: {arg:?}", hir_id), + } + } + /// Parses the programmer's textual representation of a type into our /// internal notion of a type. pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> { diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 495e663666cb9..1298c08608716 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -162,8 +162,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen }; let generics = tcx.generics_of(def_id); - let parent_count = generics.parent_count as u32; - let has_own_self = generics.has_self && parent_count == 0; // Below we'll consider the bounds on the type parameters (including `Self`) // and the explicit where-clauses, but to get the full set of predicates @@ -189,17 +187,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen predicates.insert((trait_ref.to_predicate(tcx), tcx.def_span(def_id))); } - // Collect the region predicates that were declared inline as - // well. In the case of parameters declared on a fn or method, we - // have to be careful to only iterate over early-bound regions. - let mut index = parent_count - + has_own_self as u32 - + super::early_bound_lifetimes_from_generics(tcx, ast_generics).count() as u32; - - trace!(?predicates); - trace!(?ast_generics); - trace!(?generics); - // Collect the predicates that were written inline by the user on each // type parameter (e.g., ``). Also add `ConstArgHasType` predicates // for each const parameter. @@ -208,10 +195,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen // We already dealt with early bound lifetimes above. GenericParamKind::Lifetime { .. } => (), GenericParamKind::Type { .. } => { - let name = param.name.ident().name; - let param_ty = ty::ParamTy::new(index, name).to_ty(tcx); - index += 1; - + let param_ty = icx.astconv().hir_id_to_bound_ty(param.hir_id); let mut bounds = Bounds::default(); // Params are implicitly sized unless a `?Sized` bound is found icx.astconv().add_implicitly_sized( @@ -225,23 +209,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen predicates.extend(bounds.clauses()); trace!(?predicates); } - GenericParamKind::Const { .. } => { - let name = param.name.ident().name; - let param_const = ty::ParamConst::new(index, name); - + hir::GenericParamKind::Const { .. } => { let ct_ty = tcx .type_of(param.def_id.to_def_id()) .no_bound_vars() .expect("const parameters cannot be generic"); - - let ct = ty::Const::new_param(tcx, param_const, ct_ty); - + let ct = icx.astconv().hir_id_to_bound_const(param.hir_id, ct_ty); predicates.insert(( ty::ClauseKind::ConstArgHasType(ct, ct_ty).to_predicate(tcx), param.span, )); - - index += 1; } } } @@ -252,8 +229,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen match predicate { hir::WherePredicate::BoundPredicate(bound_pred) => { let ty = icx.to_ty(bound_pred.bounded_ty); - let bound_vars = icx.tcx.late_bound_vars(bound_pred.hir_id); - + let bound_vars = tcx.late_bound_vars(bound_pred.hir_id); // Keep the type around in a dummy predicate, in case of no bounds. // That way, `where Ty:` is not a complete noop (see #53696) and `Ty` // is still checked for WF. @@ -296,7 +272,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen _ => bug!(), }; let pred = ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2)) - .to_predicate(icx.tcx); + .to_predicate(tcx); (pred, span) })) } diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 6dd0c840de632..2bee272772538 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -849,6 +849,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) { let scope = Scope::TraitRefBoundary { s: self.scope }; self.with(scope, |this| { + walk_list!(this, visit_generic_param, generics.params); for param in generics.params { match param.kind { GenericParamKind::Lifetime { .. } => {} @@ -865,90 +866,86 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { } } } - for predicate in generics.predicates { - match predicate { - &hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate { - hir_id, - bounded_ty, - bounds, - bound_generic_params, - origin, - .. - }) => { - let (bound_vars, binders): (FxIndexMap, Vec<_>) = - bound_generic_params - .iter() - .enumerate() - .map(|(late_bound_idx, param)| { - let pair = ResolvedArg::late(late_bound_idx as u32, param); - let r = late_arg_as_bound_arg(this.tcx, &pair.1, param); - (pair, r) - }) - .unzip(); - this.record_late_bound_vars(hir_id, binders.clone()); - // Even if there are no lifetimes defined here, we still wrap it in a binder - // scope. If there happens to be a nested poly trait ref (an error), that - // will be `Concatenating` anyways, so we don't have to worry about the depth - // being wrong. - let scope = Scope::Binder { - hir_id, - bound_vars, - s: this.scope, - scope_type: BinderScopeType::Normal, - where_bound_origin: Some(origin), - }; - this.with(scope, |this| { - this.visit_ty(&bounded_ty); - walk_list!(this, visit_param_bound, bounds); + walk_list!(this, visit_where_predicate, generics.predicates); + }) + } + + fn visit_where_predicate(&mut self, predicate: &'tcx hir::WherePredicate<'tcx>) { + match predicate { + &hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate { + hir_id, + bounded_ty, + bounds, + bound_generic_params, + origin, + .. + }) => { + let (bound_vars, binders): (FxIndexMap, Vec<_>) = + bound_generic_params + .iter() + .enumerate() + .map(|(late_bound_idx, param)| { + let pair = ResolvedArg::late(late_bound_idx as u32, param); + let r = late_arg_as_bound_arg(self.tcx, &pair.1, param); + (pair, r) }) - } - &hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate { - lifetime, - bounds, - .. - }) => { - this.visit_lifetime(lifetime); - walk_list!(this, visit_param_bound, bounds); - - if lifetime.res != hir::LifetimeName::Static { - for bound in bounds { - let hir::GenericBound::Outlives(lt) = bound else { - continue; - }; - if lt.res != hir::LifetimeName::Static { - continue; - } - this.insert_lifetime(lt, ResolvedArg::StaticLifetime); - this.tcx.struct_span_lint_hir( - lint::builtin::UNUSED_LIFETIMES, - lifetime.hir_id, - lifetime.ident.span, - format!( - "unnecessary lifetime parameter `{}`", - lifetime.ident - ), - |lint| { - let help = format!( - "you can use the `'static` lifetime directly, in place of `{}`", - lifetime.ident, - ); - lint.help(help) - }, - ); - } + .unzip(); + self.record_late_bound_vars(hir_id, binders.clone()); + // Even if there are no lifetimes defined here, we still wrap it in a binder + // scope. If there happens to be a nested poly trait ref (an error), that + // will be `Concatenating` anyways, so we don't have to worry about the depth + // being wrong. + let scope = Scope::Binder { + hir_id, + bound_vars, + s: self.scope, + scope_type: BinderScopeType::Normal, + where_bound_origin: Some(origin), + }; + self.with(scope, |this| { + walk_list!(this, visit_generic_param, bound_generic_params); + this.visit_ty(&bounded_ty); + walk_list!(this, visit_param_bound, bounds); + }) + } + &hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate { + lifetime, + bounds, + .. + }) => { + self.visit_lifetime(lifetime); + walk_list!(self, visit_param_bound, bounds); + + if lifetime.res != hir::LifetimeName::Static { + for bound in bounds { + let hir::GenericBound::Outlives(lt) = bound else { + continue; + }; + if lt.res != hir::LifetimeName::Static { + continue; } - } - &hir::WherePredicate::EqPredicate(hir::WhereEqPredicate { - lhs_ty, - rhs_ty, - .. - }) => { - this.visit_ty(lhs_ty); - this.visit_ty(rhs_ty); + self.insert_lifetime(lt, ResolvedArg::StaticLifetime); + self.tcx.struct_span_lint_hir( + lint::builtin::UNUSED_LIFETIMES, + lifetime.hir_id, + lifetime.ident.span, + format!("unnecessary lifetime parameter `{}`", lifetime.ident), + |lint| { + let help = format!( + "you can use the `'static` lifetime directly, in place of `{}`", + lifetime.ident, + ); + lint.help(help) + }, + ); } } } - }) + &hir::WherePredicate::EqPredicate(hir::WhereEqPredicate { lhs_ty, rhs_ty, .. }) => { + self.visit_ty(lhs_ty); + self.visit_ty(rhs_ty); + } + } } fn visit_param_bound(&mut self, bound: &'tcx hir::GenericBound<'tcx>) { @@ -986,6 +983,18 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { intravisit::walk_anon_const(this, c); }); } + + fn visit_generic_param(&mut self, p: &'tcx GenericParam<'tcx>) { + match p.kind { + GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => { + self.resolve_type_ref(p.def_id, p.hir_id); + } + GenericParamKind::Lifetime { .. } => { + // No need to resolve lifetime params, we don't use them for things + // like implicit `?Sized` or const-param-has-ty predicates. + } + } + } } fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: LocalDefId) -> ObjectLifetimeDefault { From 7a6b52bf0d29b614df0e9528798462ad8ab53d7e Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 2 Sep 2023 04:33:58 +0000 Subject: [PATCH 21/73] RPITITs are considered object-safe, they're always on Self:Sized methods --- .../src/solve/assembly/structural_traits.rs | 6 +++++ .../src/traits/select/confirmation.rs | 3 +++ .../impl-trait/in-trait/issue-102140.stderr | 6 ++++- .../in-trait/object-safety-sized.rs | 23 +++++++++++++++++++ tests/ui/impl-trait/in-trait/object-safety.rs | 1 - .../impl-trait/in-trait/object-safety.stderr | 17 +------------- 6 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 tests/ui/impl-trait/in-trait/object-safety-sized.rs diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs index c47767101a466..60f5084adc1ba 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -354,6 +354,12 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>( // FIXME(associated_const_equality): Also add associated consts to // the requirements here. if item.kind == ty::AssocKind::Type { + // RPITITs are not checked here, since they are not (currently) object-safe + // and cannot be named from a non-`Self: Sized` method. + if item.is_impl_trait_in_trait() { + continue; + } + requirements .extend(tcx.item_bounds(item.def_id).iter_instantiated(tcx, trait_ref.args)); } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 8a24f96743a6a..f2b546c3956c5 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -535,6 +535,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let assoc_types: Vec<_> = tcx .associated_items(trait_predicate.def_id()) .in_definition_order() + // RPITITs are not checked here, since they are not (currently) object-safe + // and cannot be named from a non-`Self: Sized` method. + .filter(|item| !item.is_impl_trait_in_trait()) .filter_map( |item| if item.kind == ty::AssocKind::Type { Some(item.def_id) } else { None }, ) diff --git a/tests/ui/impl-trait/in-trait/issue-102140.stderr b/tests/ui/impl-trait/in-trait/issue-102140.stderr index 5d55b9fa4f999..18bb63745d7a5 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102140.stderr @@ -6,7 +6,11 @@ LL | MyTrait::foo(&self) | | | required by a bound introduced by this call | - = help: the trait `MyTrait` is implemented for `Outer` +help: consider removing the leading `&`-reference + | +LL - MyTrait::foo(&self) +LL + MyTrait::foo(self) + | error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied --> $DIR/issue-102140.rs:23:9 diff --git a/tests/ui/impl-trait/in-trait/object-safety-sized.rs b/tests/ui/impl-trait/in-trait/object-safety-sized.rs new file mode 100644 index 0000000000000..f221cfbb17665 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/object-safety-sized.rs @@ -0,0 +1,23 @@ +// check-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +#![feature(return_position_impl_trait_in_trait)] + +fn main() { + let vec: Vec> = Vec::new(); + + for i in vec { + i.fn_2(); + } +} + +trait OtherTrait {} + +trait Trait { + fn fn_1(&self) -> impl OtherTrait + where + Self: Sized; + + fn fn_2(&self) -> bool; +} diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs index 9a231e59b09bf..dd35b9a2d8a75 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.rs +++ b/tests/ui/impl-trait/in-trait/object-safety.rs @@ -19,5 +19,4 @@ fn main() { //~| ERROR the trait `Foo` cannot be made into an object let s = i.baz(); //~^ ERROR the trait `Foo` cannot be made into an object - //~| ERROR the trait `Foo` cannot be made into an object } diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr index 0170dc5d0fc85..4a3b3b11465a1 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -13,21 +13,6 @@ LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:15 - | -LL | let s = i.baz(); - | ^^^ `Foo` cannot be made into an object - | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/object-safety.rs:7:22 - | -LL | trait Foo { - | --- this trait cannot be made into an object... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:20:13 | @@ -59,6 +44,6 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait = note: required for the cast from `Box` to `Box` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0038`. From 07fc6441327a02dd8aa8497b1e4e890f1801e8cf Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 2 Sep 2023 05:06:21 +0000 Subject: [PATCH 22/73] Do not require associated types with Self: Sized to uphold bounds when confirming object candidate --- .../src/solve/assembly/structural_traits.rs | 6 ++--- .../src/traits/select/confirmation.rs | 6 ++--- tests/ui/impl-trait/in-trait/object-safety.rs | 1 + .../impl-trait/in-trait/object-safety.stderr | 17 ++++++++++++- .../assoc_type_bounds_sized_used.rs | 6 ++--- .../assoc_type_bounds_sized_used.stderr | 21 +++------------- .../call-when-assoc-ty-is-sized.rs | 25 +++++++++++++++++++ 7 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 tests/ui/object-safety/call-when-assoc-ty-is-sized.rs diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs index 60f5084adc1ba..b61e02ba76106 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -354,9 +354,9 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>( // FIXME(associated_const_equality): Also add associated consts to // the requirements here. if item.kind == ty::AssocKind::Type { - // RPITITs are not checked here, since they are not (currently) object-safe - // and cannot be named from a non-`Self: Sized` method. - if item.is_impl_trait_in_trait() { + // associated types that require `Self: Sized` do not show up in the built-in + // implementation of `Trait for dyn Trait`, and can be dropped here. + if tcx.generics_require_sized_self(item.def_id) { continue; } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index f2b546c3956c5..eadac70057cd8 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -535,9 +535,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let assoc_types: Vec<_> = tcx .associated_items(trait_predicate.def_id()) .in_definition_order() - // RPITITs are not checked here, since they are not (currently) object-safe - // and cannot be named from a non-`Self: Sized` method. - .filter(|item| !item.is_impl_trait_in_trait()) + // Associated types that require `Self: Sized` do not show up in the built-in + // implementation of `Trait for dyn Trait`, and can be dropped here. + .filter(|item| !tcx.generics_require_sized_self(item.def_id)) .filter_map( |item| if item.kind == ty::AssocKind::Type { Some(item.def_id) } else { None }, ) diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs index dd35b9a2d8a75..9a231e59b09bf 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.rs +++ b/tests/ui/impl-trait/in-trait/object-safety.rs @@ -19,4 +19,5 @@ fn main() { //~| ERROR the trait `Foo` cannot be made into an object let s = i.baz(); //~^ ERROR the trait `Foo` cannot be made into an object + //~| ERROR the trait `Foo` cannot be made into an object } diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr index 4a3b3b11465a1..0170dc5d0fc85 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -13,6 +13,21 @@ LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:20:15 + | +LL | let s = i.baz(); + | ^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-safety.rs:7:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:20:13 | @@ -44,6 +59,6 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait = note: required for the cast from `Box` to `Box` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.rs b/tests/ui/object-safety/assoc_type_bounds_sized_used.rs index cf5345b1c1dca..d59fc1712ea7e 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_used.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.rs @@ -1,6 +1,5 @@ -//! This test checks that even if some associated types have -//! `where Self: Sized` bounds, those without still need to be -//! mentioned in trait objects. +//! This test checks that associated types with `Self: Sized` cannot be projected +//! from a `dyn Trait`. trait Bop { type Bar: Default @@ -16,5 +15,4 @@ fn bop() { fn main() { bop::(); - //~^ ERROR: the size for values of type `dyn Bop` cannot be known at compilation time } diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr index 6b5bc3603491e..224d33fb2da18 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr @@ -1,5 +1,5 @@ error[E0599]: the function or associated item `default` exists for associated type `::Bar`, but its trait bounds were not satisfied - --> $DIR/assoc_type_bounds_sized_used.rs:12:30 + --> $DIR/assoc_type_bounds_sized_used.rs:11:30 | LL | let _ = ::Bar::default(); | ^^^^^^^ function or associated item cannot be called on `::Bar` due to unsatisfied trait bounds @@ -13,7 +13,7 @@ LL | fn bop() where T: Sized { | ++++++++++++++ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:12:14 + --> $DIR/assoc_type_bounds_sized_used.rs:11:14 | LL | fn bop() { | - this type parameter needs to be `Sized` @@ -21,7 +21,7 @@ LL | let _ = ::Bar::default(); | ^ doesn't have a size known at compile-time | note: required by a bound in `Bop::Bar` - --> $DIR/assoc_type_bounds_sized_used.rs:8:15 + --> $DIR/assoc_type_bounds_sized_used.rs:7:15 | LL | type Bar: Default | --- required by a bound in this associated type @@ -34,20 +34,7 @@ LL - fn bop() { LL + fn bop() { | -error[E0277]: the size for values of type `dyn Bop` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:18:11 - | -LL | bop::(); - | ^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Bop` -note: required by a bound in `bop` - --> $DIR/assoc_type_bounds_sized_used.rs:11:11 - | -LL | fn bop() { - | ^^^ required by this bound in `bop` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs b/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs new file mode 100644 index 0000000000000..0b30a88fdd42c --- /dev/null +++ b/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs @@ -0,0 +1,25 @@ +// check-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +trait Foo { + type Bar<'a> + where + Self: Sized; + + fn test(&self); +} + +impl Foo for () { + type Bar<'a> = () where Self: Sized; + + fn test(&self) {} +} + +fn test(x: &dyn Foo) { + x.test(); +} + +fn main() { + test(&()); +} From cb7d020fb65c090cd086cbdabf1f3e0b8a721bca Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Sat, 2 Sep 2023 01:53:06 -0400 Subject: [PATCH 23/73] add stable provenance --- compiler/rustc_smir/src/rustc_internal/mod.rs | 17 ++++++++++++++++- compiler/rustc_smir/src/rustc_smir/alloc.rs | 3 +-- compiler/rustc_smir/src/rustc_smir/mod.rs | 5 +++-- compiler/rustc_smir/src/stable_mir/mod.rs | 4 ++++ compiler/rustc_smir/src/stable_mir/ty.rs | 6 ++++-- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 5334a75dc0649..34db35e40ad4c 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -14,6 +14,7 @@ use crate::{ }; use rustc_driver::{Callbacks, Compilation, RunCompiler}; use rustc_interface::{interface, Queries}; +use rustc_middle::mir::interpret::AllocId; use rustc_middle::ty::TyCtxt; use rustc_session::EarlyErrorHandler; pub use rustc_span::def_id::{CrateNum, DefId}; @@ -134,6 +135,10 @@ impl<'tcx> Tables<'tcx> { stable_mir::ty::ImplDef(self.create_def_id(did)) } + pub fn prov(&mut self, aid: AllocId) -> stable_mir::ty::Prov { + stable_mir::ty::Prov(self.create_alloc_id(aid)) + } + fn create_def_id(&mut self, did: DefId) -> stable_mir::DefId { // FIXME: this becomes inefficient when we have too many ids for (i, &d) in self.def_ids.iter().enumerate() { @@ -145,6 +150,16 @@ impl<'tcx> Tables<'tcx> { self.def_ids.push(did); stable_mir::DefId(id) } + + fn create_alloc_id(&mut self, aid: AllocId) -> stable_mir::AllocId { + // FIXME: this becomes inefficient when we have too many ids + if let Some(i) = self.alloc_ids.iter().position(|a| *a == aid) { + return stable_mir::AllocId(i); + }; + let id = self.def_ids.len(); + self.alloc_ids.push(aid); + stable_mir::AllocId(id) + } } pub fn crate_num(item: &stable_mir::Crate) -> CrateNum { @@ -152,7 +167,7 @@ pub fn crate_num(item: &stable_mir::Crate) -> CrateNum { } pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) { - crate::stable_mir::run(Tables { tcx, def_ids: vec![], types: vec![] }, f); + crate::stable_mir::run(Tables { tcx, def_ids: vec![], alloc_ids: vec![], types: vec![] }, f); } /// A type that provides internal information but that can still be used for debug purpose. diff --git a/compiler/rustc_smir/src/rustc_smir/alloc.rs b/compiler/rustc_smir/src/rustc_smir/alloc.rs index 33c75250adcd6..166c8bda9e10a 100644 --- a/compiler/rustc_smir/src/rustc_smir/alloc.rs +++ b/compiler/rustc_smir/src/rustc_smir/alloc.rs @@ -1,7 +1,6 @@ use rustc_middle::mir::interpret::{alloc_range, AllocRange, ConstValue, Pointer}; use crate::{ - rustc_internal::opaque, rustc_smir::{Stable, Tables}, stable_mir::mir::Mutability, stable_mir::ty::{Allocation, ProvenanceMap}, @@ -113,7 +112,7 @@ pub(super) fn allocation_filter<'tcx>( .iter() .filter(|a| a.0 >= alloc_range.start && a.0 <= alloc_range.end()) { - ptrs.push((offset.bytes_usize() - alloc_range.start.bytes_usize(), opaque(prov))); + ptrs.push((offset.bytes_usize() - alloc_range.start.bytes_usize(), tables.prov(*prov))); } Allocation { bytes: bytes, diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index d36835d37f54b..822a6e4865862 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -1,5 +1,5 @@ //! Module that implements what will become the rustc side of Stable MIR. -//! + //! This module is responsible for building Stable MIR components from internal components. //! //! This module is not intended to be invoked directly by users. It will eventually @@ -12,7 +12,7 @@ use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx} use crate::stable_mir::ty::{FloatTy, GenericParamDef, IntTy, Movability, RigidTy, TyKind, UintTy}; use crate::stable_mir::{self, Context}; use rustc_hir as hir; -use rustc_middle::mir::interpret::alloc_range; +use rustc_middle::mir::interpret::{alloc_range, AllocId}; use rustc_middle::mir::{self, ConstantKind}; use rustc_middle::ty::{self, Ty, TyCtxt, Variance}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -125,6 +125,7 @@ impl<'tcx> Context for Tables<'tcx> { pub struct Tables<'tcx> { pub tcx: TyCtxt<'tcx>, pub def_ids: Vec, + pub alloc_ids: Vec, pub types: Vec>, } diff --git a/compiler/rustc_smir/src/stable_mir/mod.rs b/compiler/rustc_smir/src/stable_mir/mod.rs index 1b8346281757d..8344dc954d2fb 100644 --- a/compiler/rustc_smir/src/stable_mir/mod.rs +++ b/compiler/rustc_smir/src/stable_mir/mod.rs @@ -31,6 +31,10 @@ pub type CrateNum = usize; #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct DefId(pub(crate) usize); +/// A unique identification number for each provenance +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct AllocId(pub(crate) usize); + /// A list of crate items. pub type CrateItems = Vec; diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index d49f3243777ff..1db6b1e3d28eb 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -1,4 +1,4 @@ -use super::{mir::Mutability, mir::Safety, with, DefId}; +use super::{mir::Mutability, mir::Safety, with, AllocId, DefId}; use crate::rustc_internal::Opaque; #[derive(Copy, Clone, Debug)] @@ -260,7 +260,9 @@ pub struct BoundTy { pub type Bytes = Vec>; pub type Size = usize; -pub type Prov = Opaque; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Prov(pub(crate) AllocId); pub type Align = u64; pub type Promoted = u32; pub type InitMaskMaterialized = Vec; From f686bd89494b21819e78cc4f89ebcd0e448d8809 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sat, 2 Sep 2023 19:11:54 -0400 Subject: [PATCH 24/73] Take `&mut Results` in `ResultsVisitor` --- compiler/rustc_borrowck/src/lib.rs | 6 +++--- .../rustc_mir_dataflow/src/framework/graphviz.rs | 12 ++++++------ compiler/rustc_mir_dataflow/src/framework/visitor.rs | 12 ++++++------ .../rustc_mir_transform/src/dataflow_const_prop.rs | 6 +++--- compiler/rustc_mir_transform/src/generator.rs | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 770c180ff2c59..8115c61e89d30 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -603,7 +603,7 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro fn visit_statement_before_primary_effect( &mut self, - _results: &R, + _results: &mut R, flow_state: &Flows<'cx, 'tcx>, stmt: &'cx Statement<'tcx>, location: Location, @@ -673,7 +673,7 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro fn visit_terminator_before_primary_effect( &mut self, - _results: &R, + _results: &mut R, flow_state: &Flows<'cx, 'tcx>, term: &'cx Terminator<'tcx>, loc: Location, @@ -784,7 +784,7 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro fn visit_terminator_after_primary_effect( &mut self, - _results: &R, + _results: &mut R, flow_state: &Flows<'cx, 'tcx>, term: &'cx Terminator<'tcx>, loc: Location, diff --git a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs index 1421d9b45cda6..bdddaaebca41d 100644 --- a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs +++ b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs @@ -538,7 +538,7 @@ where fn visit_block_start( &mut self, - _results: &Results<'tcx, A>, + _results: &mut Results<'tcx, A>, state: &Self::FlowState, _block_data: &mir::BasicBlockData<'tcx>, _block: BasicBlock, @@ -550,7 +550,7 @@ where fn visit_block_end( &mut self, - _results: &Results<'tcx, A>, + _results: &mut Results<'tcx, A>, state: &Self::FlowState, _block_data: &mir::BasicBlockData<'tcx>, _block: BasicBlock, @@ -562,7 +562,7 @@ where fn visit_statement_before_primary_effect( &mut self, - results: &Results<'tcx, A>, + results: &mut Results<'tcx, A>, state: &Self::FlowState, _statement: &mir::Statement<'tcx>, _location: Location, @@ -575,7 +575,7 @@ where fn visit_statement_after_primary_effect( &mut self, - results: &Results<'tcx, A>, + results: &mut Results<'tcx, A>, state: &Self::FlowState, _statement: &mir::Statement<'tcx>, _location: Location, @@ -586,7 +586,7 @@ where fn visit_terminator_before_primary_effect( &mut self, - results: &Results<'tcx, A>, + results: &mut Results<'tcx, A>, state: &Self::FlowState, _terminator: &mir::Terminator<'tcx>, _location: Location, @@ -599,7 +599,7 @@ where fn visit_terminator_after_primary_effect( &mut self, - results: &Results<'tcx, A>, + results: &mut Results<'tcx, A>, state: &Self::FlowState, _terminator: &mir::Terminator<'tcx>, _location: Location, diff --git a/compiler/rustc_mir_dataflow/src/framework/visitor.rs b/compiler/rustc_mir_dataflow/src/framework/visitor.rs index 76a729827813e..3cfa7cc1c02fd 100644 --- a/compiler/rustc_mir_dataflow/src/framework/visitor.rs +++ b/compiler/rustc_mir_dataflow/src/framework/visitor.rs @@ -35,7 +35,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> { fn visit_block_start( &mut self, - _results: &R, + _results: &mut R, _state: &Self::FlowState, _block_data: &'mir mir::BasicBlockData<'tcx>, _block: BasicBlock, @@ -46,7 +46,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> { /// its `statement_effect`. fn visit_statement_before_primary_effect( &mut self, - _results: &R, + _results: &mut R, _state: &Self::FlowState, _statement: &'mir mir::Statement<'tcx>, _location: Location, @@ -57,7 +57,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> { /// statement applied to `state`. fn visit_statement_after_primary_effect( &mut self, - _results: &R, + _results: &mut R, _state: &Self::FlowState, _statement: &'mir mir::Statement<'tcx>, _location: Location, @@ -68,7 +68,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> { /// its `terminator_effect`. fn visit_terminator_before_primary_effect( &mut self, - _results: &R, + _results: &mut R, _state: &Self::FlowState, _terminator: &'mir mir::Terminator<'tcx>, _location: Location, @@ -81,7 +81,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> { /// The `call_return_effect` (if one exists) will *not* be applied to `state`. fn visit_terminator_after_primary_effect( &mut self, - _results: &R, + _results: &mut R, _state: &Self::FlowState, _terminator: &'mir mir::Terminator<'tcx>, _location: Location, @@ -90,7 +90,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> { fn visit_block_end( &mut self, - _results: &R, + _results: &mut R, _state: &Self::FlowState, _block_data: &'mir mir::BasicBlockData<'tcx>, _block: BasicBlock, diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 3a1ef3e7d64a9..d4c9163b5718b 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -401,7 +401,7 @@ impl<'mir, 'tcx> fn visit_statement_before_primary_effect( &mut self, - results: &Results<'tcx, ValueAnalysisWrapper>>, + results: &mut Results<'tcx, ValueAnalysisWrapper>>, state: &Self::FlowState, statement: &'mir Statement<'tcx>, location: Location, @@ -417,7 +417,7 @@ impl<'mir, 'tcx> fn visit_statement_after_primary_effect( &mut self, - results: &Results<'tcx, ValueAnalysisWrapper>>, + results: &mut Results<'tcx, ValueAnalysisWrapper>>, state: &Self::FlowState, statement: &'mir Statement<'tcx>, location: Location, @@ -443,7 +443,7 @@ impl<'mir, 'tcx> fn visit_terminator_before_primary_effect( &mut self, - results: &Results<'tcx, ValueAnalysisWrapper>>, + results: &mut Results<'tcx, ValueAnalysisWrapper>>, state: &Self::FlowState, terminator: &'mir Terminator<'tcx>, location: Location, diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index 1e7161189c3a4..eae83448c46f3 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -814,7 +814,7 @@ impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R> fn visit_statement_before_primary_effect( &mut self, - _results: &R, + _results: &mut R, state: &Self::FlowState, _statement: &'mir Statement<'tcx>, loc: Location, @@ -824,7 +824,7 @@ impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R> fn visit_terminator_before_primary_effect( &mut self, - _results: &R, + _results: &mut R, state: &Self::FlowState, _terminator: &'mir Terminator<'tcx>, loc: Location, From d9af418223e26df77923a2fbe82a6c2c7d5fa5a7 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 2 Sep 2023 20:45:52 -0400 Subject: [PATCH 25/73] Add another renamed Clippy lint to release notes --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 5431df06d50d7..c5ac070b317b3 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -11,7 +11,7 @@ Language - [Stabilize inline asm for LoongArch64](https://github.com/rust-lang/rust/pull/111235/) - [Uplift `clippy::undropped_manually_drops` lint](https://github.com/rust-lang/rust/pull/111530/) - [Uplift `clippy::invalid_utf8_in_unchecked` lint](https://github.com/rust-lang/rust/pull/111543/) as `invalid_from_utf8_unchecked` and `invalid_from_utf8` -- [Uplift `clippy::cast_ref_to_mut` lint](https://github.com/rust-lang/rust/pull/111567/) +- [Uplift `clippy::cast_ref_to_mut` lint](https://github.com/rust-lang/rust/pull/111567/) as `invalid_reference_casting` - [Uplift `clippy::cmp_nan` lint](https://github.com/rust-lang/rust/pull/111818/) as `invalid_nan_comparisons` - [resolve: Remove artificial import ambiguity errors](https://github.com/rust-lang/rust/pull/112086/) - [Don't require associated types with Self: Sized bounds in `dyn Trait` objects](https://github.com/rust-lang/rust/pull/112319/) From b1e32eaab24d09f17346b716730589f87f2f2a32 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Sat, 2 Sep 2023 19:26:10 -0600 Subject: [PATCH 26/73] rustdoc: update comment in search.js for #107629 --- src/librustdoc/html/static/js/search.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 42088e7355440..82ea3e5c0c5be 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -2486,18 +2486,25 @@ ${item.displayPath}${name}\ let crateSize = 0; /** - * The raw search data for a given crate. `n`, `t`, `d`, and `q`, `i`, and `f` - * are arrays with the same length. n[i] contains the name of an item. - * t[i] contains the type of that item (as a string of characters that represent an - * offset in `itemTypes`). d[i] contains the description of that item. + * The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f` + * are arrays with the same length. `q`, `a`, and `c` use a sparse + * representation for compactness. * - * q[i] contains the full path of the item, or an empty string indicating - * "same as q[i-1]". + * `n[i]` contains the name of an item. * - * i[i] contains an item's parent, usually a module. For compactness, + * `t[i]` contains the type of that item + * (as a string of characters that represent an offset in `itemTypes`). + * + * `d[i]` contains the description of that item. + * + * `q` contains the full paths of the items. For compactness, it is a set of + * (index, path) pairs used to create a map. If a given index `i` is + * not present, this indicates "same as the last index present". + * + * `i[i]` contains an item's parent, usually a module. For compactness, * it is a set of indexes into the `p` array. * - * f[i] contains function signatures, or `0` if the item isn't a function. + * `f[i]` contains function signatures, or `0` if the item isn't a function. * Functions are themselves encoded as arrays. The first item is a list of * types representing the function's inputs, and the second list item is a list * of types representing the function's output. Tuples are flattened. @@ -2511,6 +2518,8 @@ ${item.displayPath}${name}\ * * `p` is a list of path/type pairs. It is used for parents and function parameters. * + * `c` is an array of item indices that are deprecated. + * * @type {{ * doc: string, * a: Object, From 10f491756876d378f2e1d7fa84bee1410b480212 Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Sun, 3 Sep 2023 08:21:18 +0530 Subject: [PATCH 27/73] Emit unused doc comment warnings for pat and expr fields --- compiler/rustc_lint/src/builtin.rs | 14 +++++++++ .../unused/unused-doc-comments-edge-cases.rs | 26 ++++++++++++++++ .../unused-doc-comments-edge-cases.stderr | 30 ++++++++++++++++--- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 4b6917fdfdd09..de228bdb85030 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1001,8 +1001,22 @@ impl EarlyLintPass for UnusedDocComment { warn_if_doc(cx, arm_span, "match arms", &arm.attrs); } + fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat) { + if let ast::PatKind::Struct(_, _, fields, _) = &pat.kind { + for field in fields { + warn_if_doc(cx, field.span, "pattern fields", &field.attrs); + } + } + } + fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) { warn_if_doc(cx, expr.span, "expressions", &expr.attrs); + + if let ExprKind::Struct(s) = &expr.kind { + for field in &s.fields { + warn_if_doc(cx, field.span, "expression fields", &field.attrs); + } + } } fn check_generic_param(&mut self, cx: &EarlyContext<'_>, param: &ast::GenericParam) { diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs b/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs index 54d86c31fb4fb..ba32fb566e83b 100644 --- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs +++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs @@ -26,6 +26,32 @@ fn doc_comment_on_expr(num: u8) -> bool { num == 3 } +fn doc_comment_on_expr_field() -> bool { + struct S { foo: i32 } + + let x = S { + /// useless doc comment + //~^ ERROR: unused doc comment + foo: 3 + }; + + true +} + +fn doc_comment_on_pat_field() -> bool { + struct S { foo: i32 } + + let S { + /// useless doc comment + //~^ ERROR: unused doc comment + foo + } = S { + foo: 3 + }; + + true +} + fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {} //~^ ERROR: unused doc comment diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr index 078b780d8b9bf..b5aa6215797d6 100644 --- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr +++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr @@ -42,7 +42,29 @@ LL | num == 3 = help: use `//` for a plain comment error: unused doc comment - --> $DIR/unused-doc-comments-edge-cases.rs:29:27 + --> $DIR/unused-doc-comments-edge-cases.rs:33:9 + | +LL | /// useless doc comment + | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | foo: 3 + | ------ rustdoc does not generate documentation for expression fields + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/unused-doc-comments-edge-cases.rs:45:9 + | +LL | /// useless doc comment + | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | foo + | --- rustdoc does not generate documentation for pattern fields + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/unused-doc-comments-edge-cases.rs:55:27 | LL | fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {} | ^^^^^^^^^^^^ - rustdoc does not generate documentation for generic parameters @@ -50,7 +72,7 @@ LL | fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {} = help: use `//` for a plain comment error: unused doc comment - --> $DIR/unused-doc-comments-edge-cases.rs:33:5 + --> $DIR/unused-doc-comments-edge-cases.rs:59:5 | LL | /// unused doc comment | ^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +85,7 @@ LL | | } = help: use `//` for a plain comment error: unused doc comment - --> $DIR/unused-doc-comments-edge-cases.rs:40:1 + --> $DIR/unused-doc-comments-edge-cases.rs:66:1 | LL | /// unused doc comment | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +111,7 @@ help: you might have meant to return this value LL | return true; | ++++++ + -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors Some errors have detailed explanations: E0308, E0658. For more information about an error, try `rustc --explain E0308`. From a0a71732f92919f80b96a24612501020e32ca2a7 Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Sun, 3 Sep 2023 08:38:17 +0530 Subject: [PATCH 28/73] Fix code that now emits unused doc comment warning for expr field --- compiler/rustc_mir_build/src/thir/pattern/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index c08fe54c39c4c..7736183027f40 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -555,8 +555,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { subpattern: pattern, ascription: Ascription { annotation, - /// Note that use `Contravariant` here. See the - /// `variance` field documentation for details. + // Note that use `Contravariant` here. See the + // `variance` field documentation for details. variance: ty::Variance::Contravariant, }, }, From 00c251134d49383b6d69d8707886ab1114aa0c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 3 Sep 2023 05:10:58 +0200 Subject: [PATCH 29/73] Outline panicking code for `RefCell::borrow` and `RefCell::borrow_mut` --- library/core/src/cell.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 28950a43d2d07..20dce6516bf68 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -753,6 +753,22 @@ impl Display for BorrowMutError { } } +// This ensures the panicking code is outlined from `borrow_mut` for `RefCell`. +#[inline(never)] +#[track_caller] +#[cold] +fn panic_already_borrowed(err: BorrowMutError) -> ! { + panic!("already borrowed: {:?}", err) +} + +// This ensures the panicking code is outlined from `borrow` for `RefCell`. +#[inline(never)] +#[track_caller] +#[cold] +fn panic_already_mutably_borrowed(err: BorrowError) -> ! { + panic!("already mutably borrowed: {:?}", err) +} + // Positive values represent the number of `Ref` active. Negative values // represent the number of `RefMut` active. Multiple `RefMut`s can only be // active at a time if they refer to distinct, nonoverlapping components of a @@ -934,7 +950,10 @@ impl RefCell { #[inline] #[track_caller] pub fn borrow(&self) -> Ref<'_, T> { - self.try_borrow().expect("already mutably borrowed") + match self.try_borrow() { + Ok(b) => b, + Err(err) => panic_already_mutably_borrowed(err), + } } /// Immutably borrows the wrapped value, returning an error if the value is currently mutably @@ -1027,7 +1046,10 @@ impl RefCell { #[inline] #[track_caller] pub fn borrow_mut(&self) -> RefMut<'_, T> { - self.try_borrow_mut().expect("already borrowed") + match self.try_borrow_mut() { + Ok(b) => b, + Err(err) => panic_already_borrowed(err), + } } /// Mutably borrows the wrapped value, returning an error if the value is currently borrowed. From 789451b43a068b10b7073b8a3194c1c2128b48b2 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 3 Sep 2023 08:15:25 +0200 Subject: [PATCH 30/73] Allow `large_assignments` for Box/Arc/Rc initialization Does the `stop linting in box/arc initialization` task of 83518. --- compiler/rustc_monomorphize/src/collector.rs | 101 ++++++++++++++++-- .../async-await/large_moves.attribute.stderr | 22 +++- .../ui/async-await/large_moves.option.stderr | 22 +++- tests/ui/async-await/large_moves.rs | 18 ++++ 4 files changed, 147 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index bf88360a8c1f9..77f1942331845 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -179,8 +179,8 @@ use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{ - self, GenericParamDefKind, Instance, InstanceDef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, - VtblEntry, + self, AssocKind, GenericParamDefKind, Instance, InstanceDef, Ty, TyCtxt, TypeFoldable, + TypeVisitableExt, VtblEntry, }; use rustc_middle::ty::{GenericArgKind, GenericArgs}; use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, mir::visit::TyContext}; @@ -188,6 +188,7 @@ use rustc_session::config::EntryFnType; use rustc_session::lint::builtin::LARGE_ASSIGNMENTS; use rustc_session::Limit; use rustc_span::source_map::{dummy_spanned, respan, Span, Spanned, DUMMY_SP}; +use rustc_span::symbol::{sym, Ident}; use rustc_target::abi::Size; use std::path::PathBuf; @@ -431,7 +432,7 @@ fn collect_items_rec<'tcx>( hir::InlineAsmOperand::SymFn { anon_const } => { let fn_ty = tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id); - visit_fn_use(tcx, fn_ty, false, *op_sp, &mut used_items); + visit_fn_use(tcx, fn_ty, false, *op_sp, &mut used_items, &[]); } hir::InlineAsmOperand::SymStatic { path: _, def_id } => { let instance = Instance::mono(tcx, *def_id); @@ -592,6 +593,11 @@ struct MirUsedCollector<'a, 'tcx> { instance: Instance<'tcx>, /// Spans for move size lints already emitted. Helps avoid duplicate lints. move_size_spans: Vec, + /// If true, we should temporarily skip move size checks, because we are + /// processing an operand to a `skip_move_check_fns` function call. + skip_move_size_check: bool, + /// Set of functions for which it is OK to move large data into. + skip_move_check_fns: Vec, } impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> { @@ -690,7 +696,14 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { ) => { let fn_ty = operand.ty(self.body, self.tcx); let fn_ty = self.monomorphize(fn_ty); - visit_fn_use(self.tcx, fn_ty, false, span, &mut self.output); + visit_fn_use( + self.tcx, + fn_ty, + false, + span, + &mut self.output, + &self.skip_move_check_fns, + ); } mir::Rvalue::Cast( mir::CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_)), @@ -789,7 +802,14 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { mir::TerminatorKind::Call { ref func, .. } => { let callee_ty = func.ty(self.body, tcx); let callee_ty = self.monomorphize(callee_ty); - visit_fn_use(self.tcx, callee_ty, true, source, &mut self.output) + self.skip_move_size_check = visit_fn_use( + self.tcx, + callee_ty, + true, + source, + &mut self.output, + &self.skip_move_check_fns, + ) } mir::TerminatorKind::Drop { ref place, .. } => { let ty = place.ty(self.body, self.tcx).ty; @@ -801,7 +821,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { match *op { mir::InlineAsmOperand::SymFn { ref value } => { let fn_ty = self.monomorphize(value.literal.ty()); - visit_fn_use(self.tcx, fn_ty, false, source, &mut self.output); + visit_fn_use(self.tcx, fn_ty, false, source, &mut self.output, &[]); } mir::InlineAsmOperand::SymStatic { def_id } => { let instance = Instance::mono(self.tcx, def_id); @@ -840,12 +860,13 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { } self.super_terminator(terminator, location); + self.skip_move_size_check = false; } fn visit_operand(&mut self, operand: &mir::Operand<'tcx>, location: Location) { self.super_operand(operand, location); let move_size_limit = self.tcx.move_size_limit().0; - if move_size_limit > 0 { + if move_size_limit > 0 && !self.skip_move_size_check { self.check_move_size(move_size_limit, operand, location); } } @@ -876,8 +897,11 @@ fn visit_fn_use<'tcx>( is_direct_call: bool, source: Span, output: &mut MonoItems<'tcx>, -) { + skip_move_check_fns: &[DefId], +) -> bool { + let mut skip_move_size_check = false; if let ty::FnDef(def_id, args) = *ty.kind() { + skip_move_size_check = skip_move_check_fns.contains(&def_id); let instance = if is_direct_call { ty::Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args) } else { @@ -888,6 +912,7 @@ fn visit_fn_use<'tcx>( }; visit_instance_use(tcx, instance, is_direct_call, source, output); } + skip_move_size_check } fn visit_instance_use<'tcx>( @@ -1365,6 +1390,31 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt } } +fn add_assoc_fn<'tcx>( + tcx: TyCtxt<'tcx>, + def_id: Option, + fn_ident: Ident, + skip_move_check_fns: &mut Vec, +) { + if let Some(def_id) = def_id.and_then(|def_id| assoc_fn_of_type(tcx, def_id, fn_ident)) { + skip_move_check_fns.push(def_id); + } +} + +fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option { + for impl_def_id in tcx.inherent_impls(def_id) { + if let Some(new) = tcx.associated_items(impl_def_id).find_by_name_and_kind( + tcx, + fn_ident, + AssocKind::Fn, + def_id, + ) { + return Some(new.def_id); + } + } + return None; +} + /// Scans the MIR in order to find function calls, closures, and drop-glue. #[instrument(skip(tcx, output), level = "debug")] fn collect_used_items<'tcx>( @@ -1373,8 +1423,39 @@ fn collect_used_items<'tcx>( output: &mut MonoItems<'tcx>, ) { let body = tcx.instance_mir(instance.def); - MirUsedCollector { tcx, body: &body, output, instance, move_size_spans: vec![] } - .visit_body(&body); + + let mut skip_move_check_fns = vec![]; + if tcx.move_size_limit().0 > 0 { + add_assoc_fn( + tcx, + tcx.lang_items().owned_box(), + Ident::from_str("new"), + &mut skip_move_check_fns, + ); + add_assoc_fn( + tcx, + tcx.get_diagnostic_item(sym::Arc), + Ident::from_str("new"), + &mut skip_move_check_fns, + ); + add_assoc_fn( + tcx, + tcx.get_diagnostic_item(sym::Rc), + Ident::from_str("new"), + &mut skip_move_check_fns, + ); + } + + MirUsedCollector { + tcx, + body: &body, + output, + instance, + move_size_spans: vec![], + skip_move_size_check: false, + skip_move_check_fns, + } + .visit_body(&body); } #[instrument(skip(tcx, output), level = "debug")] diff --git a/tests/ui/async-await/large_moves.attribute.stderr b/tests/ui/async-await/large_moves.attribute.stderr index ef9fd78ffe362..1d1999462cedd 100644 --- a/tests/ui/async-await/large_moves.attribute.stderr +++ b/tests/ui/async-await/large_moves.attribute.stderr @@ -1,5 +1,5 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:19:14 + --> $DIR/large_moves.rs:21:14 | LL | let z = (x, 42); | ^ value moved from here @@ -12,12 +12,28 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 10024 bytes - --> $DIR/large_moves.rs:20:13 + --> $DIR/large_moves.rs:22:13 | LL | let a = z.0; | ^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -error: aborting due to 2 previous errors +error: moving 9999 bytes + --> $DIR/large_moves.rs:27:13 + | +LL | let _ = NotBox::new([0; 9999]); + | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: moving 9999 bytes + --> $DIR/large_moves.rs:41:13 + | +LL | data, + | ^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 4 previous errors diff --git a/tests/ui/async-await/large_moves.option.stderr b/tests/ui/async-await/large_moves.option.stderr index ef9fd78ffe362..1d1999462cedd 100644 --- a/tests/ui/async-await/large_moves.option.stderr +++ b/tests/ui/async-await/large_moves.option.stderr @@ -1,5 +1,5 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:19:14 + --> $DIR/large_moves.rs:21:14 | LL | let z = (x, 42); | ^ value moved from here @@ -12,12 +12,28 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 10024 bytes - --> $DIR/large_moves.rs:20:13 + --> $DIR/large_moves.rs:22:13 | LL | let a = z.0; | ^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -error: aborting due to 2 previous errors +error: moving 9999 bytes + --> $DIR/large_moves.rs:27:13 + | +LL | let _ = NotBox::new([0; 9999]); + | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: moving 9999 bytes + --> $DIR/large_moves.rs:41:13 + | +LL | data, + | ^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 4 previous errors diff --git a/tests/ui/async-await/large_moves.rs b/tests/ui/async-await/large_moves.rs index faf6c66c6124e..62b1210469410 100644 --- a/tests/ui/async-await/large_moves.rs +++ b/tests/ui/async-await/large_moves.rs @@ -9,6 +9,8 @@ // edition:2018 // compile-flags: -Zmir-opt-level=0 +use std::{sync::Arc, rc::Rc}; + fn main() { let x = async { let y = [0; 9999]; @@ -19,8 +21,24 @@ fn main() { let z = (x, 42); //~ ERROR large_assignments let a = z.0; //~ ERROR large_assignments let b = z.1; + let _ = Arc::new([0; 9999]); // OK! + let _ = Box::new([0; 9999]); // OK! + let _ = Rc::new([0; 9999]); // OK! + let _ = NotBox::new([0; 9999]); //~ ERROR large_assignments } async fn thing(y: &[u8]) { dbg!(y); } + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + Self { + data, //~ ERROR large_assignments + } + } +} From 56df6b81898efcdf4d486eb9baa16e1273f3c08e Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Sun, 3 Sep 2023 12:35:03 +0530 Subject: [PATCH 31/73] Move RawOsError defination to sys Signed-off-by: Ayush Singh --- library/std/src/io/error.rs | 2 +- library/std/src/io/error/repr_bitpacked.rs | 3 --- library/std/src/sys/mod.rs | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index d6fce4ee78f5e..ea10bb8636c3d 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -102,7 +102,7 @@ enum ErrorData { /// /// [`into`]: Into::into #[unstable(feature = "raw_os_error_ty", issue = "107792")] -pub type RawOsError = i32; +pub type RawOsError = sys::RawOsError; // `#[repr(align(4))]` is probably redundant, it should have that value or // higher already. We include it just because repr_bitpacked.rs's encoding diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index f94f88bac417e..6e7366b36355f 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -374,9 +374,6 @@ static_assert!((TAG_MASK + 1).is_power_of_two()); static_assert!(align_of::() >= TAG_MASK + 1); static_assert!(align_of::() >= TAG_MASK + 1); -// `RawOsError` must be an alias for `i32`. -const _: fn(RawOsError) -> i32 = |os| os; - static_assert!(@usize_eq: TAG_MASK & TAG_SIMPLE_MESSAGE, TAG_SIMPLE_MESSAGE); static_assert!(@usize_eq: TAG_MASK & TAG_CUSTOM, TAG_CUSTOM); static_assert!(@usize_eq: TAG_MASK & TAG_OS, TAG_OS); diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index beea3f23c2dff..63bd783746b1b 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -110,3 +110,5 @@ pub fn log_wrapper f64>(n: f64, log_fn: F) -> f64 { pub fn log_wrapper f64>(n: f64, log_fn: F) -> f64 { log_fn(n) } + +pub type RawOsError = i32; From 7e648f0d7209b6a985475a4cc4a1a02fce10bd86 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Sep 2023 12:46:56 +0200 Subject: [PATCH 32/73] Use named arguments in `code-color.goml` GUI test --- tests/rustdoc-gui/code-color.goml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/rustdoc-gui/code-color.goml b/tests/rustdoc-gui/code-color.goml index 833fa05db42b4..cfc997d65179f 100644 --- a/tests/rustdoc-gui/code-color.goml +++ b/tests/rustdoc-gui/code-color.goml @@ -19,6 +19,18 @@ define-function: ( }, ) -call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)")) -call-function: ("check-colors", ("dark", "rgb(221, 221, 221)", "rgb(221, 221, 221)")) -call-function: ("check-colors", ("light", "rgb(0, 0, 0)", "rgb(0, 0, 0)")) +call-function: ("check-colors", { + "theme": "ayu", + "doc_code_color": "rgb(230, 225, 207)", + "doc_inline_code_color": "rgb(255, 180, 84)", +}) +call-function: ("check-colors", { + "theme": "dark", + "doc_code_color": "rgb(221, 221, 221)", + "doc_inline_code_color": "rgb(221, 221, 221)", +}) +call-function: ("check-colors", { + "theme": "light", + "doc_code_color": "rgb(0, 0, 0)", + "doc_inline_code_color": "rgb(0, 0, 0)", +}) From 8e5dff1d382098cb1d9e547c0c2dc92c7fd4b547 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Sep 2023 12:49:22 +0200 Subject: [PATCH 33/73] Migrate GUI colors test to original CSS color format --- tests/rustdoc-gui/code-color.goml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/rustdoc-gui/code-color.goml b/tests/rustdoc-gui/code-color.goml index cfc997d65179f..92bdfb25b001c 100644 --- a/tests/rustdoc-gui/code-color.goml +++ b/tests/rustdoc-gui/code-color.goml @@ -21,16 +21,16 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "doc_code_color": "rgb(230, 225, 207)", - "doc_inline_code_color": "rgb(255, 180, 84)", + "doc_code_color": "#e6e1cf", + "doc_inline_code_color": "#ffb454", }) call-function: ("check-colors", { "theme": "dark", - "doc_code_color": "rgb(221, 221, 221)", - "doc_inline_code_color": "rgb(221, 221, 221)", + "doc_code_color": "#ddd", + "doc_inline_code_color": "#ddd", }) call-function: ("check-colors", { "theme": "light", - "doc_code_color": "rgb(0, 0, 0)", - "doc_inline_code_color": "rgb(0, 0, 0)", + "doc_code_color": "black", + "doc_inline_code_color": "black", }) From d87b87d10e630eb0fb9cd0bf11c70ee869f077b7 Mon Sep 17 00:00:00 2001 From: Sebastian Toh Date: Sun, 3 Sep 2023 19:55:11 +0800 Subject: [PATCH 34/73] Improve clarity of diagnostic message on non-exhaustive matches --- compiler/rustc_mir_build/src/thir/pattern/check_match.rs | 4 ++-- .../2229_closure_analysis/match/non-exhaustive-match.stderr | 2 +- tests/ui/match/match_non_exhaustive.stderr | 2 +- .../pattern/usefulness/issue-105479-str-non-exhaustiveness.rs | 2 +- .../usefulness/issue-105479-str-non-exhaustiveness.stderr | 2 +- tests/ui/pattern/usefulness/issue-30240.stderr | 4 ++-- .../ui/pattern/usefulness/nested-non-exhaustive-enums.stderr | 2 +- tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 38c24e0ab5ee3..95dced644e161 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -741,10 +741,10 @@ fn non_exhaustive_match<'p, 'tcx>( } } else if ty == cx.tcx.types.str_ { err.note(format!( - "`{ty}` cannot be matched exhaustively, so a wildcard `_` is necessary", + "`&str` cannot be matched exhaustively, so a wildcard `_` is necessary", )); } else if cx.is_foreign_non_exhaustive_enum(ty) { - err.note(format!("`{ty}` is marked as non-exhaustive")); + err.note(format!("`{ty}` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively")); } } } diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index fddd769c3dfc3..0807f4590298f 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -46,7 +46,7 @@ note: `E2` defined here LL | pub enum E2 { A, B } | ^^^^^^^^^^^ = note: the matched value is of type `E2` - = note: `E2` is marked as non-exhaustive + = note: `E2` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; diff --git a/tests/ui/match/match_non_exhaustive.stderr b/tests/ui/match/match_non_exhaustive.stderr index d07e284e299bb..7b8bdfe0053ae 100644 --- a/tests/ui/match/match_non_exhaustive.stderr +++ b/tests/ui/match/match_non_exhaustive.stderr @@ -46,7 +46,7 @@ note: `E2` defined here LL | pub enum E2 { A, B } | ^^^^^^^^^^^ = note: the matched value is of type `E2` - = note: `E2` is marked as non-exhaustive + = note: `E2` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | match e2 { E2::A => (), E2::B => (), _ => todo!() }; diff --git a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs index faf37b07513f6..0ee7856c6803a 100644 --- a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs +++ b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.rs @@ -5,7 +5,7 @@ fn main() { //~^ ERROR non-exhaustive patterns: `(&_, _)` not covered [E0004] //~| NOTE pattern `(&_, _)` not covered //~| NOTE the matched value is of type `(&str, &str)` - //~| NOTE `str` cannot be matched exhaustively, so a wildcard `_` is necessary + //~| NOTE `&str` cannot be matched exhaustively, so a wildcard `_` is necessary ("a", "b") => {} ("c", "d") => {} } diff --git a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr index 5c09b3bada6b9..771fc320a13f6 100644 --- a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr +++ b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr @@ -5,7 +5,7 @@ LL | match (a, b) { | ^^^^^^ pattern `(&_, _)` not covered | = note: the matched value is of type `(&str, &str)` - = note: `str` cannot be matched exhaustively, so a wildcard `_` is necessary + = note: `&str` cannot be matched exhaustively, so a wildcard `_` is necessary help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ ("c", "d") => {}, diff --git a/tests/ui/pattern/usefulness/issue-30240.stderr b/tests/ui/pattern/usefulness/issue-30240.stderr index 736ab34e16468..da8bbdffbf6d5 100644 --- a/tests/ui/pattern/usefulness/issue-30240.stderr +++ b/tests/ui/pattern/usefulness/issue-30240.stderr @@ -5,7 +5,7 @@ LL | match "world" { | ^^^^^^^ pattern `&_` not covered | = note: the matched value is of type `&str` - = note: `str` cannot be matched exhaustively, so a wildcard `_` is necessary + = note: `&str` cannot be matched exhaustively, so a wildcard `_` is necessary help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ "hello" => {}, @@ -19,7 +19,7 @@ LL | match "world" { | ^^^^^^^ pattern `&_` not covered | = note: the matched value is of type `&str` - = note: `str` cannot be matched exhaustively, so a wildcard `_` is necessary + = note: `&str` cannot be matched exhaustively, so a wildcard `_` is necessary help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ "hello" => {}, diff --git a/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr index ae81f307fde34..9fbd871db7c9d 100644 --- a/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr +++ b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr @@ -10,7 +10,7 @@ note: `Option` defined here | = note: not covered = note: the matched value is of type `Option` - = note: `NonExhaustiveEnum` is marked as non-exhaustive + = note: `NonExhaustiveEnum` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ None => {}, diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr index 50209e18bd173..4e7f3098ab482 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr @@ -29,7 +29,7 @@ note: `NonExhaustiveEnum` defined here LL | pub enum NonExhaustiveEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type `NonExhaustiveEnum` - = note: `NonExhaustiveEnum` is marked as non-exhaustive + = note: `NonExhaustiveEnum` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ NonExhaustiveEnum::Struct { .. } => "third", From 258ace613da6b8c90ba4995738cb13791388c4bb Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 3 Sep 2023 10:15:35 +0000 Subject: [PATCH 35/73] Use relative positions inside a SourceFile. --- .../src/debuginfo/line_info.rs | 7 +- .../src/debuginfo/create_scope_map.rs | 4 +- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 2 +- compiler/rustc_metadata/src/rmeta/decoder.rs | 24 ++- .../rustc_middle/src/query/on_disk_cache.rs | 5 +- .../rustc_mir_transform/src/coverage/mod.rs | 33 ++-- compiler/rustc_parse/src/lib.rs | 2 +- .../src/ich/impls_syntax.rs | 40 +---- .../rustc_span/src/analyze_source_file.rs | 48 ++--- .../src/analyze_source_file/tests.rs | 29 +--- .../rustc_span/src/caching_source_map_view.rs | 15 +- compiler/rustc_span/src/lib.rs | 164 +++++++++++------- compiler/rustc_span/src/source_map.rs | 72 +++----- compiler/rustc_span/src/source_map/tests.rs | 7 +- compiler/rustc_span/src/tests.rs | 28 ++- src/librustdoc/html/sources.rs | 2 +- src/librustdoc/scrape_examples.rs | 2 +- .../src/undocumented_unsafe_blocks.rs | 4 +- src/tools/clippy/clippy_utils/src/source.rs | 8 +- src/tools/rustfmt/src/parse/session.rs | 2 +- 20 files changed, 217 insertions(+), 281 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs index 50bc7a127af09..998263de584fc 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs @@ -82,12 +82,9 @@ impl DebugContext { match tcx.sess.source_map().lookup_line(span.lo()) { Ok(SourceFileAndLine { sf: file, line }) => { let line_pos = file.lines(|lines| lines[line]); + let col = file.relative_position(span.lo()) - line_pos; - ( - file, - u64::try_from(line).unwrap() + 1, - u64::from((span.lo() - line_pos).to_u32()) + 1, - ) + (file, u64::try_from(line).unwrap() + 1, u64::from(col.to_u32()) + 1) } Err(file) => (file, 0, 0), } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs index d174a3593b999..ebf4ee4164fda 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs @@ -68,7 +68,7 @@ fn make_mir_scope<'ll, 'tcx>( let file = cx.sess().source_map().lookup_source_file(mir.span.lo()); debug_context.scopes[scope] = DebugScope { file_start_pos: file.start_pos, - file_end_pos: file.end_pos, + file_end_pos: file.end_position(), ..debug_context.scopes[scope] }; instantiated.insert(scope); @@ -120,7 +120,7 @@ fn make_mir_scope<'ll, 'tcx>( dbg_scope, inlined_at: inlined_at.or(parent_scope.inlined_at), file_start_pos: loc.file.start_pos, - file_end_pos: loc.file.end_pos, + file_end_pos: loc.file.end_position(), }; instantiated.insert(scope); } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 40714a0afe91c..2301f66dc28dd 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -267,7 +267,7 @@ impl CodegenCx<'_, '_> { // Use 1-based indexing. let line = (line + 1) as u32; - let col = (pos - line_pos).to_u32() + 1; + let col = (file.relative_position(pos) - line_pos).to_u32() + 1; (file, line, col) } diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 43c1d321f81f9..5ecf8005292ec 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1501,11 +1501,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { // We can't reuse an existing SourceFile, so allocate a new one // containing the information we need. + let original_end_pos = source_file_to_import.end_position(); let rustc_span::SourceFile { mut name, src_hash, - start_pos, - end_pos, + start_pos: original_start_pos, + source_len, lines, multibyte_chars, non_narrow_chars, @@ -1547,35 +1548,32 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { // on `try_to_translate_virtual_to_real`). try_to_translate_virtual_to_real(&mut name); - let source_length = (end_pos - start_pos).to_usize(); - let local_version = sess.source_map().new_imported_source_file( name, src_hash, name_hash, - source_length, + source_len.to_usize(), self.cnum, lines, multibyte_chars, non_narrow_chars, normalized_pos, - start_pos, source_file_index, ); debug!( "CrateMetaData::imported_source_files alloc \ - source_file {:?} original (start_pos {:?} end_pos {:?}) \ - translated (start_pos {:?} end_pos {:?})", + source_file {:?} original (start_pos {:?} source_len {:?}) \ + translated (start_pos {:?} source_len {:?})", local_version.name, - start_pos, - end_pos, + original_start_pos, + source_len, local_version.start_pos, - local_version.end_pos + local_version.source_len ); ImportedSourceFile { - original_start_pos: start_pos, - original_end_pos: end_pos, + original_start_pos, + original_end_pos, translated_source_file: local_version, } }) diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index 995b2140f61d5..64853bd9612ca 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -22,7 +22,7 @@ use rustc_span::hygiene::{ ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextData, }; use rustc_span::source_map::{SourceMap, StableSourceFileId}; -use rustc_span::{BytePos, ExpnData, ExpnHash, Pos, SourceFile, Span}; +use rustc_span::{BytePos, ExpnData, ExpnHash, Pos, RelativeBytePos, SourceFile, Span}; use rustc_span::{CachingSourceMapView, Symbol}; use std::collections::hash_map::Entry; use std::io; @@ -688,11 +688,12 @@ impl<'a, 'tcx> Decodable> for Span { let file_lo_index = SourceFileIndex::decode(decoder); let line_lo = usize::decode(decoder); - let col_lo = BytePos::decode(decoder); + let col_lo = RelativeBytePos::decode(decoder); let len = BytePos::decode(decoder); let file_lo = decoder.file_index_to_file(file_lo_index); let lo = file_lo.lines(|lines| lines[line_lo - 1] + col_lo); + let lo = file_lo.absolute_position(lo); let hi = lo + len; Span::new(lo, hi, ctxt, parent) diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index 8c9eae508b4ae..d0b28eb2f5d80 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -28,7 +28,7 @@ use rustc_middle::mir::{ use rustc_middle::ty::TyCtxt; use rustc_span::def_id::DefId; use rustc_span::source_map::SourceMap; -use rustc_span::{CharPos, ExpnKind, Pos, SourceFile, Span, Symbol}; +use rustc_span::{ExpnKind, SourceFile, Span, Symbol}; /// A simple error message wrapper for `coverage::Error`s. #[derive(Debug)] @@ -314,8 +314,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { }; graphviz_data.add_bcb_coverage_span_with_counter(bcb, &covspan, &counter_kind); - let code_region = - make_code_region(source_map, file_name, &self.source_file, span, body_span); + let code_region = make_code_region(source_map, file_name, span, body_span); inject_statement( self.mir_body, @@ -510,40 +509,36 @@ fn inject_intermediate_expression(mir_body: &mut mir::Body<'_>, expression: Cove fn make_code_region( source_map: &SourceMap, file_name: Symbol, - source_file: &Lrc, span: Span, body_span: Span, ) -> CodeRegion { debug!( - "Called make_code_region(file_name={}, source_file={:?}, span={}, body_span={})", + "Called make_code_region(file_name={}, span={}, body_span={})", file_name, - source_file, source_map.span_to_diagnostic_string(span), source_map.span_to_diagnostic_string(body_span) ); - let (start_line, mut start_col) = source_file.lookup_file_pos(span.lo()); - let (end_line, end_col) = if span.hi() == span.lo() { - let (end_line, mut end_col) = (start_line, start_col); + let (file, mut start_line, mut start_col, mut end_line, mut end_col) = + source_map.span_to_location_info(span); + if span.hi() == span.lo() { // Extend an empty span by one character so the region will be counted. - let CharPos(char_pos) = start_col; if span.hi() == body_span.hi() { - start_col = CharPos(char_pos.saturating_sub(1)); + start_col = start_col.saturating_sub(1); } else { - end_col = CharPos(char_pos + 1); + end_col = start_col + 1; } - (end_line, end_col) - } else { - source_file.lookup_file_pos(span.hi()) }; - let start_line = source_map.doctest_offset_line(&source_file.name, start_line); - let end_line = source_map.doctest_offset_line(&source_file.name, end_line); + if let Some(file) = file { + start_line = source_map.doctest_offset_line(&file.name, start_line); + end_line = source_map.doctest_offset_line(&file.name, end_line); + } CodeRegion { file_name, start_line: start_line as u32, - start_col: start_col.to_u32() + 1, + start_col: start_col as u32, end_line: end_line as u32, - end_col: end_col.to_u32() + 1, + end_col: end_col as u32, } } diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 598adbe798595..c012a86633299 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -132,7 +132,7 @@ fn maybe_source_file_to_parser( sess: &ParseSess, source_file: Lrc, ) -> Result, Vec> { - let end_pos = source_file.end_pos; + let end_pos = source_file.end_position(); let stream = maybe_file_to_stream(sess, source_file, None)?; let mut parser = stream_to_parser(sess, stream, None); if parser.token == token::Eof { diff --git a/compiler/rustc_query_system/src/ich/impls_syntax.rs b/compiler/rustc_query_system/src/ich/impls_syntax.rs index e673d5b8c6ee9..f2b13f95def29 100644 --- a/compiler/rustc_query_system/src/ich/impls_syntax.rs +++ b/compiler/rustc_query_system/src/ich/impls_syntax.rs @@ -5,7 +5,7 @@ use crate::ich::StableHashingContext; use rustc_ast as ast; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_span::{BytePos, NormalizedPos, SourceFile}; +use rustc_span::SourceFile; use std::assert_matches::assert_matches; use smallvec::SmallVec; @@ -67,8 +67,8 @@ impl<'a> HashStable> for SourceFile { src: _, ref src_hash, external_src: _, - start_pos, - end_pos: _, + start_pos: _, + source_len: _, lines: _, ref multibyte_chars, ref non_narrow_chars, @@ -85,56 +85,30 @@ impl<'a> HashStable> for SourceFile { // We only hash the relative position within this source_file lines.len().hash_stable(hcx, hasher); for &line in lines.iter() { - stable_byte_pos(line, start_pos).hash_stable(hcx, hasher); + line.hash_stable(hcx, hasher); } }); // We only hash the relative position within this source_file multibyte_chars.len().hash_stable(hcx, hasher); for &char_pos in multibyte_chars.iter() { - stable_multibyte_char(char_pos, start_pos).hash_stable(hcx, hasher); + char_pos.hash_stable(hcx, hasher); } non_narrow_chars.len().hash_stable(hcx, hasher); for &char_pos in non_narrow_chars.iter() { - stable_non_narrow_char(char_pos, start_pos).hash_stable(hcx, hasher); + char_pos.hash_stable(hcx, hasher); } normalized_pos.len().hash_stable(hcx, hasher); for &char_pos in normalized_pos.iter() { - stable_normalized_pos(char_pos, start_pos).hash_stable(hcx, hasher); + char_pos.hash_stable(hcx, hasher); } cnum.hash_stable(hcx, hasher); } } -fn stable_byte_pos(pos: BytePos, source_file_start: BytePos) -> u32 { - pos.0 - source_file_start.0 -} - -fn stable_multibyte_char(mbc: rustc_span::MultiByteChar, source_file_start: BytePos) -> (u32, u32) { - let rustc_span::MultiByteChar { pos, bytes } = mbc; - - (pos.0 - source_file_start.0, bytes as u32) -} - -fn stable_non_narrow_char( - swc: rustc_span::NonNarrowChar, - source_file_start: BytePos, -) -> (u32, u32) { - let pos = swc.pos(); - let width = swc.width(); - - (pos.0 - source_file_start.0, width as u32) -} - -fn stable_normalized_pos(np: NormalizedPos, source_file_start: BytePos) -> (u32, u32) { - let NormalizedPos { pos, diff } = np; - - (pos.0 - source_file_start.0, diff) -} - impl<'tcx> HashStable> for rustc_feature::Features { fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { // Unfortunately we cannot exhaustively list fields here, since the diff --git a/compiler/rustc_span/src/analyze_source_file.rs b/compiler/rustc_span/src/analyze_source_file.rs index 26cd54210d0bb..450d5455ff938 100644 --- a/compiler/rustc_span/src/analyze_source_file.rs +++ b/compiler/rustc_span/src/analyze_source_file.rs @@ -11,26 +11,19 @@ mod tests; /// is detected at runtime. pub fn analyze_source_file( src: &str, - source_file_start_pos: BytePos, -) -> (Vec, Vec, Vec) { - let mut lines = vec![source_file_start_pos]; +) -> (Vec, Vec, Vec) { + let mut lines = vec![RelativeBytePos::from_u32(0)]; let mut multi_byte_chars = vec![]; let mut non_narrow_chars = vec![]; // Calls the right implementation, depending on hardware support available. - analyze_source_file_dispatch( - src, - source_file_start_pos, - &mut lines, - &mut multi_byte_chars, - &mut non_narrow_chars, - ); + analyze_source_file_dispatch(src, &mut lines, &mut multi_byte_chars, &mut non_narrow_chars); // The code above optimistically registers a new line *after* each \n // it encounters. If that point is already outside the source_file, remove // it again. if let Some(&last_line_start) = lines.last() { - let source_file_end = source_file_start_pos + BytePos::from_usize(src.len()); + let source_file_end = RelativeBytePos::from_usize(src.len()); assert!(source_file_end >= last_line_start); if last_line_start == source_file_end { lines.pop(); @@ -43,14 +36,12 @@ pub fn analyze_source_file( cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { fn analyze_source_file_dispatch(src: &str, - source_file_start_pos: BytePos, - lines: &mut Vec, + lines: &mut Vec, multi_byte_chars: &mut Vec, non_narrow_chars: &mut Vec) { if is_x86_feature_detected!("sse2") { unsafe { analyze_source_file_sse2(src, - source_file_start_pos, lines, multi_byte_chars, non_narrow_chars); @@ -58,7 +49,7 @@ cfg_if::cfg_if! { } else { analyze_source_file_generic(src, src.len(), - source_file_start_pos, + RelativeBytePos::from_u32(0), lines, multi_byte_chars, non_narrow_chars); @@ -72,8 +63,7 @@ cfg_if::cfg_if! { /// SSE2 intrinsics to quickly find all newlines. #[target_feature(enable = "sse2")] unsafe fn analyze_source_file_sse2(src: &str, - output_offset: BytePos, - lines: &mut Vec, + lines: &mut Vec, multi_byte_chars: &mut Vec, non_narrow_chars: &mut Vec) { #[cfg(target_arch = "x86")] @@ -129,8 +119,7 @@ cfg_if::cfg_if! { if control_char_mask == newlines_mask { // All control characters are newlines, record them let mut newlines_mask = 0xFFFF0000 | newlines_mask as u32; - let output_offset = output_offset + - BytePos::from_usize(chunk_index * CHUNK_SIZE + 1); + let output_offset = RelativeBytePos::from_usize(chunk_index * CHUNK_SIZE + 1); loop { let index = newlines_mask.trailing_zeros(); @@ -140,7 +129,7 @@ cfg_if::cfg_if! { break } - lines.push(BytePos(index) + output_offset); + lines.push(RelativeBytePos(index) + output_offset); // Clear the bit, so we can find the next one. newlines_mask &= (!1) << index; @@ -165,7 +154,7 @@ cfg_if::cfg_if! { intra_chunk_offset = analyze_source_file_generic( &src[scan_start .. ], CHUNK_SIZE - intra_chunk_offset, - BytePos::from_usize(scan_start) + output_offset, + RelativeBytePos::from_usize(scan_start), lines, multi_byte_chars, non_narrow_chars @@ -177,7 +166,7 @@ cfg_if::cfg_if! { if tail_start < src.len() { analyze_source_file_generic(&src[tail_start ..], src.len() - tail_start, - output_offset + BytePos::from_usize(tail_start), + RelativeBytePos::from_usize(tail_start), lines, multi_byte_chars, non_narrow_chars); @@ -187,13 +176,12 @@ cfg_if::cfg_if! { // The target (or compiler version) does not support SSE2 ... fn analyze_source_file_dispatch(src: &str, - source_file_start_pos: BytePos, - lines: &mut Vec, + lines: &mut Vec, multi_byte_chars: &mut Vec, non_narrow_chars: &mut Vec) { analyze_source_file_generic(src, src.len(), - source_file_start_pos, + RelativeBytePos::from_u32(0), lines, multi_byte_chars, non_narrow_chars); @@ -207,8 +195,8 @@ cfg_if::cfg_if! { fn analyze_source_file_generic( src: &str, scan_len: usize, - output_offset: BytePos, - lines: &mut Vec, + output_offset: RelativeBytePos, + lines: &mut Vec, multi_byte_chars: &mut Vec, non_narrow_chars: &mut Vec, ) -> usize { @@ -230,11 +218,11 @@ fn analyze_source_file_generic( // This is an ASCII control character, it could be one of the cases // that are interesting to us. - let pos = BytePos::from_usize(i) + output_offset; + let pos = RelativeBytePos::from_usize(i) + output_offset; match byte { b'\n' => { - lines.push(pos + BytePos(1)); + lines.push(pos + RelativeBytePos(1)); } b'\t' => { non_narrow_chars.push(NonNarrowChar::Tab(pos)); @@ -250,7 +238,7 @@ fn analyze_source_file_generic( let c = src[i..].chars().next().unwrap(); char_len = c.len_utf8(); - let pos = BytePos::from_usize(i) + output_offset; + let pos = RelativeBytePos::from_usize(i) + output_offset; if char_len > 1 { assert!((2..=4).contains(&char_len)); diff --git a/compiler/rustc_span/src/analyze_source_file/tests.rs b/compiler/rustc_span/src/analyze_source_file/tests.rs index 66aefc9a787fd..0c77d080c17a0 100644 --- a/compiler/rustc_span/src/analyze_source_file/tests.rs +++ b/compiler/rustc_span/src/analyze_source_file/tests.rs @@ -3,29 +3,28 @@ use super::*; macro_rules! test { (case: $test_name:ident, text: $text:expr, - source_file_start_pos: $source_file_start_pos:expr, lines: $lines:expr, multi_byte_chars: $multi_byte_chars:expr, non_narrow_chars: $non_narrow_chars:expr,) => { #[test] fn $test_name() { - let (lines, multi_byte_chars, non_narrow_chars) = - analyze_source_file($text, BytePos($source_file_start_pos)); + let (lines, multi_byte_chars, non_narrow_chars) = analyze_source_file($text); - let expected_lines: Vec = $lines.into_iter().map(BytePos).collect(); + let expected_lines: Vec = + $lines.into_iter().map(RelativeBytePos).collect(); assert_eq!(lines, expected_lines); let expected_mbcs: Vec = $multi_byte_chars .into_iter() - .map(|(pos, bytes)| MultiByteChar { pos: BytePos(pos), bytes }) + .map(|(pos, bytes)| MultiByteChar { pos: RelativeBytePos(pos), bytes }) .collect(); assert_eq!(multi_byte_chars, expected_mbcs); let expected_nncs: Vec = $non_narrow_chars .into_iter() - .map(|(pos, width)| NonNarrowChar::new(BytePos(pos), width)) + .map(|(pos, width)| NonNarrowChar::new(RelativeBytePos(pos), width)) .collect(); assert_eq!(non_narrow_chars, expected_nncs); @@ -36,7 +35,6 @@ macro_rules! test { test!( case: empty_text, text: "", - source_file_start_pos: 0, lines: vec![], multi_byte_chars: vec![], non_narrow_chars: vec![], @@ -45,7 +43,6 @@ test!( test!( case: newlines_short, text: "a\nc", - source_file_start_pos: 0, lines: vec![0, 2], multi_byte_chars: vec![], non_narrow_chars: vec![], @@ -54,7 +51,6 @@ test!( test!( case: newlines_long, text: "012345678\nabcdef012345678\na", - source_file_start_pos: 0, lines: vec![0, 10, 26], multi_byte_chars: vec![], non_narrow_chars: vec![], @@ -63,7 +59,6 @@ test!( test!( case: newline_and_multi_byte_char_in_same_chunk, text: "01234β789\nbcdef0123456789abcdef", - source_file_start_pos: 0, lines: vec![0, 11], multi_byte_chars: vec![(5, 2)], non_narrow_chars: vec![], @@ -72,7 +67,6 @@ test!( test!( case: newline_and_control_char_in_same_chunk, text: "01234\u{07}6789\nbcdef0123456789abcdef", - source_file_start_pos: 0, lines: vec![0, 11], multi_byte_chars: vec![], non_narrow_chars: vec![(5, 0)], @@ -81,7 +75,6 @@ test!( test!( case: multi_byte_char_short, text: "aβc", - source_file_start_pos: 0, lines: vec![0], multi_byte_chars: vec![(1, 2)], non_narrow_chars: vec![], @@ -90,7 +83,6 @@ test!( test!( case: multi_byte_char_long, text: "0123456789abcΔf012345β", - source_file_start_pos: 0, lines: vec![0], multi_byte_chars: vec![(13, 2), (22, 2)], non_narrow_chars: vec![], @@ -99,7 +91,6 @@ test!( test!( case: multi_byte_char_across_chunk_boundary, text: "0123456789abcdeΔ123456789abcdef01234", - source_file_start_pos: 0, lines: vec![0], multi_byte_chars: vec![(15, 2)], non_narrow_chars: vec![], @@ -108,7 +99,6 @@ test!( test!( case: multi_byte_char_across_chunk_boundary_tail, text: "0123456789abcdeΔ....", - source_file_start_pos: 0, lines: vec![0], multi_byte_chars: vec![(15, 2)], non_narrow_chars: vec![], @@ -117,7 +107,6 @@ test!( test!( case: non_narrow_short, text: "0\t2", - source_file_start_pos: 0, lines: vec![0], multi_byte_chars: vec![], non_narrow_chars: vec![(1, 4)], @@ -126,7 +115,6 @@ test!( test!( case: non_narrow_long, text: "01\t3456789abcdef01234567\u{07}9", - source_file_start_pos: 0, lines: vec![0], multi_byte_chars: vec![], non_narrow_chars: vec![(2, 4), (24, 0)], @@ -135,8 +123,7 @@ test!( test!( case: output_offset_all, text: "01\t345\n789abcΔf01234567\u{07}9\nbcΔf", - source_file_start_pos: 1000, - lines: vec![0 + 1000, 7 + 1000, 27 + 1000], - multi_byte_chars: vec![(13 + 1000, 2), (29 + 1000, 2)], - non_narrow_chars: vec![(2 + 1000, 4), (24 + 1000, 0)], + lines: vec![0, 7, 27], + multi_byte_chars: vec![(13, 2), (29, 2)], + non_narrow_chars: vec![(2, 4), (24, 0)], ); diff --git a/compiler/rustc_span/src/caching_source_map_view.rs b/compiler/rustc_span/src/caching_source_map_view.rs index 886112769a977..fbfc5c22fcb34 100644 --- a/compiler/rustc_span/src/caching_source_map_view.rs +++ b/compiler/rustc_span/src/caching_source_map_view.rs @@ -1,5 +1,5 @@ use crate::source_map::SourceMap; -use crate::{BytePos, SourceFile, SpanData}; +use crate::{BytePos, Pos, RelativeBytePos, SourceFile, SpanData}; use rustc_data_structures::sync::Lrc; use std::ops::Range; @@ -37,6 +37,7 @@ impl CacheEntry { self.file_index = file_idx; } + let pos = self.file.relative_position(pos); let line_index = self.file.lookup_line(pos).unwrap(); let line_bounds = self.file.line_bounds(line_index); self.line_number = line_index + 1; @@ -79,7 +80,7 @@ impl<'sm> CachingSourceMapView<'sm> { pub fn byte_pos_to_line_and_col( &mut self, pos: BytePos, - ) -> Option<(Lrc, usize, BytePos)> { + ) -> Option<(Lrc, usize, RelativeBytePos)> { self.time_stamp += 1; // Check if the position is in one of the cached lines @@ -88,11 +89,8 @@ impl<'sm> CachingSourceMapView<'sm> { let cache_entry = &mut self.line_cache[cache_idx as usize]; cache_entry.touch(self.time_stamp); - return Some(( - cache_entry.file.clone(), - cache_entry.line_number, - pos - cache_entry.line.start, - )); + let col = RelativeBytePos(pos.to_u32() - cache_entry.line.start.to_u32()); + return Some((cache_entry.file.clone(), cache_entry.line_number, col)); } // No cache hit ... @@ -108,7 +106,8 @@ impl<'sm> CachingSourceMapView<'sm> { let cache_entry = &mut self.line_cache[oldest]; cache_entry.update(new_file_and_idx, pos, self.time_stamp); - Some((cache_entry.file.clone(), cache_entry.line_number, pos - cache_entry.line.start)) + let col = RelativeBytePos(pos.to_u32() - cache_entry.line.start.to_u32()); + Some((cache_entry.file.clone(), cache_entry.line_number, col)) } pub fn span_data_to_lines_and_cols( diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 62fe49fe2a218..b1cde3093efc6 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1107,27 +1107,27 @@ impl fmt::Debug for SpanData { } /// Identifies an offset of a multi-byte character in a `SourceFile`. -#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)] pub struct MultiByteChar { /// The absolute offset of the character in the `SourceMap`. - pub pos: BytePos, + pub pos: RelativeBytePos, /// The number of bytes, `>= 2`. pub bytes: u8, } /// Identifies an offset of a non-narrow character in a `SourceFile`. -#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)] pub enum NonNarrowChar { /// Represents a zero-width character. - ZeroWidth(BytePos), + ZeroWidth(RelativeBytePos), /// Represents a wide (full-width) character. - Wide(BytePos), + Wide(RelativeBytePos), /// Represents a tab character, represented visually with a width of 4 characters. - Tab(BytePos), + Tab(RelativeBytePos), } impl NonNarrowChar { - fn new(pos: BytePos, width: usize) -> Self { + fn new(pos: RelativeBytePos, width: usize) -> Self { match width { 0 => NonNarrowChar::ZeroWidth(pos), 2 => NonNarrowChar::Wide(pos), @@ -1137,7 +1137,7 @@ impl NonNarrowChar { } /// Returns the absolute offset of the character in the `SourceMap`. - pub fn pos(&self) -> BytePos { + pub fn pos(&self) -> RelativeBytePos { match *self { NonNarrowChar::ZeroWidth(p) | NonNarrowChar::Wide(p) | NonNarrowChar::Tab(p) => p, } @@ -1153,10 +1153,10 @@ impl NonNarrowChar { } } -impl Add for NonNarrowChar { +impl Add for NonNarrowChar { type Output = Self; - fn add(self, rhs: BytePos) -> Self { + fn add(self, rhs: RelativeBytePos) -> Self { match self { NonNarrowChar::ZeroWidth(pos) => NonNarrowChar::ZeroWidth(pos + rhs), NonNarrowChar::Wide(pos) => NonNarrowChar::Wide(pos + rhs), @@ -1165,10 +1165,10 @@ impl Add for NonNarrowChar { } } -impl Sub for NonNarrowChar { +impl Sub for NonNarrowChar { type Output = Self; - fn sub(self, rhs: BytePos) -> Self { + fn sub(self, rhs: RelativeBytePos) -> Self { match self { NonNarrowChar::ZeroWidth(pos) => NonNarrowChar::ZeroWidth(pos - rhs), NonNarrowChar::Wide(pos) => NonNarrowChar::Wide(pos - rhs), @@ -1178,10 +1178,10 @@ impl Sub for NonNarrowChar { } /// Identifies an offset of a character that was normalized away from `SourceFile`. -#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)] pub struct NormalizedPos { /// The absolute offset of the character in the `SourceMap`. - pub pos: BytePos, + pub pos: RelativeBytePos, /// The difference between original and normalized string at position. pub diff: u32, } @@ -1293,7 +1293,7 @@ impl SourceFileHash { #[derive(Clone)] pub enum SourceFileLines { /// The source file lines, in decoded (random-access) form. - Lines(Vec), + Lines(Vec), /// The source file lines, in undecoded difference list form. Diffs(SourceFileDiffs), @@ -1317,7 +1317,7 @@ pub struct SourceFileDiffs { /// Position of the first line. Note that this is always encoded as a /// `BytePos` because it is often much larger than any of the /// differences. - line_start: BytePos, + line_start: RelativeBytePos, /// Always 1, 2, or 4. Always as small as possible, while being big /// enough to hold the length of the longest line in the source file. @@ -1352,7 +1352,7 @@ pub struct SourceFile { /// The start position of this source in the `SourceMap`. pub start_pos: BytePos, /// The end position of this source in the `SourceMap`. - pub end_pos: BytePos, + pub source_len: RelativeBytePos, /// Locations of lines beginnings in the source code. pub lines: Lock, /// Locations of multi-byte characters in the source code. @@ -1375,7 +1375,7 @@ impl Clone for SourceFile { src_hash: self.src_hash, external_src: Lock::new(self.external_src.borrow().clone()), start_pos: self.start_pos, - end_pos: self.end_pos, + source_len: self.source_len, lines: Lock::new(self.lines.borrow().clone()), multibyte_chars: self.multibyte_chars.clone(), non_narrow_chars: self.non_narrow_chars.clone(), @@ -1390,8 +1390,8 @@ impl Encodable for SourceFile { fn encode(&self, s: &mut S) { self.name.encode(s); self.src_hash.encode(s); - self.start_pos.encode(s); - self.end_pos.encode(s); + // Do not encode `start_pos` as it's global state for this session. + self.source_len.encode(s); // We are always in `Lines` form by the time we reach here. assert!(self.lines.borrow().is_lines()); @@ -1465,8 +1465,7 @@ impl Decodable for SourceFile { fn decode(d: &mut D) -> SourceFile { let name: FileName = Decodable::decode(d); let src_hash: SourceFileHash = Decodable::decode(d); - let start_pos: BytePos = Decodable::decode(d); - let end_pos: BytePos = Decodable::decode(d); + let source_len: RelativeBytePos = Decodable::decode(d); let lines = { let num_lines: u32 = Decodable::decode(d); if num_lines > 0 { @@ -1474,7 +1473,7 @@ impl Decodable for SourceFile { let bytes_per_diff = d.read_u8() as usize; // Read the first element. - let line_start: BytePos = Decodable::decode(d); + let line_start: RelativeBytePos = Decodable::decode(d); // Read the difference list. let num_diffs = num_lines as usize - 1; @@ -1496,8 +1495,8 @@ impl Decodable for SourceFile { let cnum: CrateNum = Decodable::decode(d); SourceFile { name, - start_pos, - end_pos, + start_pos: BytePos::from_u32(0), + source_len, src: None, src_hash, // Unused - the metadata decoder will construct @@ -1520,34 +1519,29 @@ impl fmt::Debug for SourceFile { } impl SourceFile { - pub fn new( - name: FileName, - mut src: String, - start_pos: BytePos, - hash_kind: SourceFileHashAlgorithm, - ) -> Self { + pub fn new(name: FileName, mut src: String, hash_kind: SourceFileHashAlgorithm) -> Self { // Compute the file hash before any normalization. let src_hash = SourceFileHash::new(hash_kind, &src); - let normalized_pos = normalize_src(&mut src, start_pos); + let normalized_pos = normalize_src(&mut src); let name_hash = { let mut hasher: StableHasher = StableHasher::new(); name.hash(&mut hasher); hasher.finish() }; - let end_pos = start_pos.to_usize() + src.len(); - assert!(end_pos <= u32::MAX as usize); + let source_len = src.len(); + assert!(source_len <= u32::MAX as usize); let (lines, multibyte_chars, non_narrow_chars) = - analyze_source_file::analyze_source_file(&src, start_pos); + analyze_source_file::analyze_source_file(&src); SourceFile { name, src: Some(Lrc::new(src)), src_hash, external_src: Lock::new(ExternalSource::Unneeded), - start_pos, - end_pos: Pos::from_usize(end_pos), + start_pos: BytePos::from_u32(0), + source_len: RelativeBytePos::from_usize(source_len), lines: Lock::new(SourceFileLines::Lines(lines)), multibyte_chars, non_narrow_chars, @@ -1559,7 +1553,7 @@ impl SourceFile { pub fn lines(&self, f: F) -> R where - F: FnOnce(&[BytePos]) -> R, + F: FnOnce(&[RelativeBytePos]) -> R, { let mut guard = self.lines.borrow_mut(); match &*guard { @@ -1579,7 +1573,7 @@ impl SourceFile { match bytes_per_diff { 1 => { lines.extend(raw_diffs.into_iter().map(|&diff| { - line_start = line_start + BytePos(diff as u32); + line_start = line_start + RelativeBytePos(diff as u32); line_start })); } @@ -1588,7 +1582,7 @@ impl SourceFile { let pos = bytes_per_diff * i; let bytes = [raw_diffs[pos], raw_diffs[pos + 1]]; let diff = u16::from_le_bytes(bytes); - line_start = line_start + BytePos(diff as u32); + line_start = line_start + RelativeBytePos(diff as u32); line_start })); } @@ -1602,7 +1596,7 @@ impl SourceFile { raw_diffs[pos + 3], ]; let diff = u32::from_le_bytes(bytes); - line_start = line_start + BytePos(diff); + line_start = line_start + RelativeBytePos(diff); line_start })); } @@ -1617,8 +1611,10 @@ impl SourceFile { /// Returns the `BytePos` of the beginning of the current line. pub fn line_begin_pos(&self, pos: BytePos) -> BytePos { + let pos = self.relative_position(pos); let line_index = self.lookup_line(pos).unwrap(); - self.lines(|lines| lines[line_index]) + let line_start_pos = self.lines(|lines| lines[line_index]); + self.absolute_position(line_start_pos) } /// Add externally loaded source. @@ -1643,7 +1639,7 @@ impl SourceFile { if let Some(mut src) = src { // The src_hash needs to be computed on the pre-normalized src. if self.src_hash.matches(&src) { - normalize_src(&mut src, BytePos::from_usize(0)); + normalize_src(&mut src); *src_kind = ExternalSourceKind::Present(Lrc::new(src)); return true; } @@ -1676,8 +1672,7 @@ impl SourceFile { let begin = { let line = self.lines(|lines| lines.get(line_number).copied())?; - let begin: BytePos = line - self.start_pos; - begin.to_usize() + line.to_usize() }; if let Some(ref src) = self.src { @@ -1703,25 +1698,41 @@ impl SourceFile { self.lines(|lines| lines.len()) } + #[inline] + pub fn absolute_position(&self, pos: RelativeBytePos) -> BytePos { + BytePos::from_u32(pos.to_u32() + self.start_pos.to_u32()) + } + + #[inline] + pub fn relative_position(&self, pos: BytePos) -> RelativeBytePos { + RelativeBytePos::from_u32(pos.to_u32() - self.start_pos.to_u32()) + } + + #[inline] + pub fn end_position(&self) -> BytePos { + self.absolute_position(self.source_len) + } + /// Finds the line containing the given position. The return value is the /// index into the `lines` array of this `SourceFile`, not the 1-based line /// number. If the source_file is empty or the position is located before the /// first line, `None` is returned. - pub fn lookup_line(&self, pos: BytePos) -> Option { + pub fn lookup_line(&self, pos: RelativeBytePos) -> Option { self.lines(|lines| lines.partition_point(|x| x <= &pos).checked_sub(1)) } pub fn line_bounds(&self, line_index: usize) -> Range { if self.is_empty() { - return self.start_pos..self.end_pos; + return self.start_pos..self.start_pos; } self.lines(|lines| { assert!(line_index < lines.len()); if line_index == (lines.len() - 1) { - lines[line_index]..self.end_pos + self.absolute_position(lines[line_index])..self.end_position() } else { - lines[line_index]..lines[line_index + 1] + self.absolute_position(lines[line_index]) + ..self.absolute_position(lines[line_index + 1]) } }) } @@ -1732,17 +1743,19 @@ impl SourceFile { /// returns true still contain one byte position according to this function. #[inline] pub fn contains(&self, byte_pos: BytePos) -> bool { - byte_pos >= self.start_pos && byte_pos <= self.end_pos + byte_pos >= self.start_pos && byte_pos <= self.end_position() } #[inline] pub fn is_empty(&self) -> bool { - self.start_pos == self.end_pos + self.source_len.to_u32() == 0 } /// Calculates the original byte position relative to the start of the file /// based on the given byte position. - pub fn original_relative_byte_pos(&self, pos: BytePos) -> BytePos { + pub fn original_relative_byte_pos(&self, pos: BytePos) -> RelativeBytePos { + let pos = self.relative_position(pos); + // Diff before any records is 0. Otherwise use the previously recorded // diff as that applies to the following characters until a new diff // is recorded. @@ -1752,7 +1765,7 @@ impl SourceFile { Err(i) => self.normalized_pos[i - 1].diff, }; - BytePos::from_u32(pos.0 - self.start_pos.0 + diff) + RelativeBytePos::from_u32(pos.0 + diff) } /// Calculates a normalized byte position from a byte offset relative to the @@ -1778,7 +1791,7 @@ impl SourceFile { } /// Converts an absolute `BytePos` to a `CharPos` relative to the `SourceFile`. - pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos { + fn bytepos_to_file_charpos(&self, bpos: RelativeBytePos) -> CharPos { // The number of extra bytes due to multibyte chars in the `SourceFile`. let mut total_extra_bytes = 0; @@ -1796,13 +1809,13 @@ impl SourceFile { } } - assert!(self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()); - CharPos(bpos.to_usize() - self.start_pos.to_usize() - total_extra_bytes as usize) + assert!(total_extra_bytes <= bpos.to_u32()); + CharPos(bpos.to_usize() - total_extra_bytes as usize) } /// Looks up the file's (1-based) line number and (0-based `CharPos`) column offset, for a /// given `BytePos`. - pub fn lookup_file_pos(&self, pos: BytePos) -> (usize, CharPos) { + fn lookup_file_pos(&self, pos: RelativeBytePos) -> (usize, CharPos) { let chpos = self.bytepos_to_file_charpos(pos); match self.lookup_line(pos) { Some(a) => { @@ -1823,6 +1836,7 @@ impl SourceFile { /// Looks up the file's (1-based) line number, (0-based `CharPos`) column offset, and (0-based) /// column offset when displayed, for a given `BytePos`. pub fn lookup_file_pos_with_col_display(&self, pos: BytePos) -> (usize, CharPos, usize) { + let pos = self.relative_position(pos); let (line, col_or_chpos) = self.lookup_file_pos(pos); if line > 0 { let col = col_or_chpos; @@ -1861,16 +1875,10 @@ impl SourceFile { } /// Normalizes the source code and records the normalizations. -fn normalize_src(src: &mut String, start_pos: BytePos) -> Vec { +fn normalize_src(src: &mut String) -> Vec { let mut normalized_pos = vec![]; remove_bom(src, &mut normalized_pos); normalize_newlines(src, &mut normalized_pos); - - // Offset all the positions by start_pos to match the final file positions. - for np in &mut normalized_pos { - np.pos.0 += start_pos.0; - } - normalized_pos } @@ -1878,7 +1886,7 @@ fn normalize_src(src: &mut String, start_pos: BytePos) -> Vec { fn remove_bom(src: &mut String, normalized_pos: &mut Vec) { if src.starts_with('\u{feff}') { src.drain(..3); - normalized_pos.push(NormalizedPos { pos: BytePos(0), diff: 3 }); + normalized_pos.push(NormalizedPos { pos: RelativeBytePos(0), diff: 3 }); } } @@ -1913,7 +1921,7 @@ fn normalize_newlines(src: &mut String, normalized_pos: &mut Vec) cursor += idx - gap_len; gap_len += 1; normalized_pos.push(NormalizedPos { - pos: BytePos::from_usize(cursor + 1), + pos: RelativeBytePos::from_usize(cursor + 1), diff: original_gap + gap_len as u32, }); } @@ -2015,6 +2023,12 @@ impl_pos! { #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] pub struct BytePos(pub u32); + /// A byte offset relative to file beginning. + /// + /// Keep this small (currently 32-bits), as AST contains a lot of them. + #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] + pub struct RelativeBytePos(pub u32); + /// A character offset. /// /// Because of multibyte UTF-8 characters, a byte offset @@ -2036,6 +2050,24 @@ impl Decodable for BytePos { } } +impl HashStable for RelativeBytePos { + fn hash_stable(&self, hcx: &mut H, hasher: &mut StableHasher) { + self.0.hash_stable(hcx, hasher); + } +} + +impl Encodable for RelativeBytePos { + fn encode(&self, s: &mut S) { + s.emit_u32(self.0); + } +} + +impl Decodable for RelativeBytePos { + fn decode(d: &mut D) -> RelativeBytePos { + RelativeBytePos(d.read_u32()) + } +} + // _____________________________________________________________________________ // Loc, SourceFileAndLine, SourceFileAndBytePos // diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 1cff021ba4109..07483280f41d0 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -314,21 +314,18 @@ impl SourceMap { let lrc_sf = match self.source_file_by_stable_id(file_id) { Some(lrc_sf) => lrc_sf, None => { - let start_pos = self.allocate_address_space(src.len())?; - - let source_file = Lrc::new(SourceFile::new( - filename, - src, - Pos::from_usize(start_pos), - self.hash_kind, - )); + let mut source_file = SourceFile::new(filename, src, self.hash_kind); // Let's make sure the file_id we generated above actually matches // the ID we generate for the SourceFile we just created. debug_assert_eq!(StableSourceFileId::new(&source_file), file_id); + let start_pos = self.allocate_address_space(source_file.source_len.to_usize())?; + source_file.start_pos = BytePos::from_usize(start_pos); + let mut files = self.files.borrow_mut(); + let source_file = Lrc::new(source_file); files.source_files.push(source_file.clone()); files.stable_id_to_source_file.insert(file_id, source_file.clone()); @@ -350,48 +347,16 @@ impl SourceMap { source_len: usize, cnum: CrateNum, file_local_lines: Lock, - mut file_local_multibyte_chars: Vec, - mut file_local_non_narrow_chars: Vec, - mut file_local_normalized_pos: Vec, - original_start_pos: BytePos, + multibyte_chars: Vec, + non_narrow_chars: Vec, + normalized_pos: Vec, metadata_index: u32, ) -> Lrc { let start_pos = self .allocate_address_space(source_len) .expect("not enough address space for imported source file"); - let end_pos = Pos::from_usize(start_pos + source_len); - let start_pos = Pos::from_usize(start_pos); - - // Translate these positions into the new global frame of reference, - // now that the offset of the SourceFile is known. - // - // These are all unsigned values. `original_start_pos` may be larger or - // smaller than `start_pos`, but `pos` is always larger than both. - // Therefore, `(pos - original_start_pos) + start_pos` won't overflow - // but `start_pos - original_start_pos` might. So we use the former - // form rather than pre-computing the offset into a local variable. The - // compiler backend can optimize away the repeated computations in a - // way that won't trigger overflow checks. - match &mut *file_local_lines.borrow_mut() { - SourceFileLines::Lines(lines) => { - for pos in lines { - *pos = (*pos - original_start_pos) + start_pos; - } - } - SourceFileLines::Diffs(SourceFileDiffs { line_start, .. }) => { - *line_start = (*line_start - original_start_pos) + start_pos; - } - } - for mbc in &mut file_local_multibyte_chars { - mbc.pos = (mbc.pos - original_start_pos) + start_pos; - } - for swc in &mut file_local_non_narrow_chars { - *swc = (*swc - original_start_pos) + start_pos; - } - for nc in &mut file_local_normalized_pos { - nc.pos = (nc.pos - original_start_pos) + start_pos; - } + let source_len = RelativeBytePos::from_usize(source_len); let source_file = Lrc::new(SourceFile { name: filename, @@ -401,12 +366,12 @@ impl SourceMap { kind: ExternalSourceKind::AbsentOk, metadata_index, }), - start_pos, - end_pos, + start_pos: BytePos::from_usize(start_pos), + source_len, lines: file_local_lines, - multibyte_chars: file_local_multibyte_chars, - non_narrow_chars: file_local_non_narrow_chars, - normalized_pos: file_local_normalized_pos, + multibyte_chars, + non_narrow_chars, + normalized_pos, name_hash, cnum, }); @@ -452,6 +417,7 @@ impl SourceMap { pub fn lookup_line(&self, pos: BytePos) -> Result> { let f = self.lookup_source_file(pos); + let pos = f.relative_position(pos); match f.lookup_line(pos) { Some(line) => Ok(SourceFileAndLine { sf: f, line }), None => Err(f), @@ -547,7 +513,9 @@ impl SourceMap { return true; } let f = (*self.files.borrow().source_files)[lo].clone(); - f.lookup_line(sp.lo()) != f.lookup_line(sp.hi()) + let lo = f.relative_position(sp.lo()); + let hi = f.relative_position(sp.hi()); + f.lookup_line(lo) != f.lookup_line(hi) } #[instrument(skip(self), level = "trace")] @@ -627,7 +595,7 @@ impl SourceMap { let start_index = local_begin.pos.to_usize(); let end_index = local_end.pos.to_usize(); - let source_len = (local_begin.sf.end_pos - local_begin.sf.start_pos).to_usize(); + let source_len = local_begin.sf.source_len.to_usize(); if start_index > end_index || end_index > source_len { return Err(SpanSnippetError::MalformedForSourcemap(MalformedSourceMapPositions { @@ -1034,7 +1002,7 @@ impl SourceMap { return 1; } - let source_len = (local_begin.sf.end_pos - local_begin.sf.start_pos).to_usize(); + let source_len = local_begin.sf.source_len.to_usize(); debug!("source_len=`{:?}`", source_len); // Ensure indexes are also not malformed. if start_index > end_index || end_index > source_len - 1 { diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs index 686b3b00d7047..d5cb3dac55cf6 100644 --- a/compiler/rustc_span/src/source_map/tests.rs +++ b/compiler/rustc_span/src/source_map/tests.rs @@ -50,6 +50,7 @@ impl SourceMap { fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos { let idx = self.lookup_source_file_idx(bpos); let sf = &(*self.files.borrow().source_files)[idx]; + let bpos = sf.relative_position(bpos); sf.bytepos_to_file_charpos(bpos) } } @@ -230,8 +231,7 @@ fn t10() { let SourceFile { name, src_hash, - start_pos, - end_pos, + source_len, lines, multibyte_chars, non_narrow_chars, @@ -244,13 +244,12 @@ fn t10() { name, src_hash, name_hash, - (end_pos - start_pos).to_usize(), + source_len.to_usize(), CrateNum::new(0), lines, multibyte_chars, non_narrow_chars, normalized_pos, - start_pos, 0, ); diff --git a/compiler/rustc_span/src/tests.rs b/compiler/rustc_span/src/tests.rs index a242ad6d1d730..3b69295bb93c7 100644 --- a/compiler/rustc_span/src/tests.rs +++ b/compiler/rustc_span/src/tests.rs @@ -3,24 +3,22 @@ use super::*; #[test] fn test_lookup_line() { let source = "abcdefghijklm\nabcdefghij\n...".to_owned(); - let sf = SourceFile::new( - FileName::Anon(Hash64::ZERO), - source, - BytePos(3), - SourceFileHashAlgorithm::Sha256, - ); - sf.lines(|lines| assert_eq!(lines, &[BytePos(3), BytePos(17), BytePos(28)])); + let mut sf = + SourceFile::new(FileName::Anon(Hash64::ZERO), source, SourceFileHashAlgorithm::Sha256); + sf.start_pos = BytePos(3); + sf.lines(|lines| { + assert_eq!(lines, &[RelativeBytePos(0), RelativeBytePos(14), RelativeBytePos(25)]) + }); - assert_eq!(sf.lookup_line(BytePos(0)), None); - assert_eq!(sf.lookup_line(BytePos(3)), Some(0)); - assert_eq!(sf.lookup_line(BytePos(4)), Some(0)); + assert_eq!(sf.lookup_line(RelativeBytePos(0)), Some(0)); + assert_eq!(sf.lookup_line(RelativeBytePos(1)), Some(0)); - assert_eq!(sf.lookup_line(BytePos(16)), Some(0)); - assert_eq!(sf.lookup_line(BytePos(17)), Some(1)); - assert_eq!(sf.lookup_line(BytePos(18)), Some(1)); + assert_eq!(sf.lookup_line(RelativeBytePos(13)), Some(0)); + assert_eq!(sf.lookup_line(RelativeBytePos(14)), Some(1)); + assert_eq!(sf.lookup_line(RelativeBytePos(15)), Some(1)); - assert_eq!(sf.lookup_line(BytePos(28)), Some(2)); - assert_eq!(sf.lookup_line(BytePos(29)), Some(2)); + assert_eq!(sf.lookup_line(RelativeBytePos(25)), Some(2)); + assert_eq!(sf.lookup_line(RelativeBytePos(26)), Some(2)); } #[test] diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index c4a1ebbec02ea..1d6eafe51b95d 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -134,7 +134,7 @@ impl DocVisitor for SourceCollector<'_, '_> { let filename = span.filename(sess); let span = span.inner(); let pos = sess.source_map().lookup_source_file(span.lo()); - let file_span = span.with_lo(pos.start_pos).with_hi(pos.end_pos); + let file_span = span.with_lo(pos.start_pos).with_hi(pos.end_position()); // If it turns out that we couldn't read this file, then we probably // can't read any of the files (generating html output from json or // something like that), so just don't include sources for the diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index 534c6eebbdd57..dd52deef6724e 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -73,7 +73,7 @@ pub(crate) struct SyntaxRange { impl SyntaxRange { fn new(span: rustc_span::Span, file: &SourceFile) -> Option { let get_pos = |bytepos: BytePos| file.original_relative_byte_pos(bytepos).0; - let get_line = |bytepos: BytePos| file.lookup_line(bytepos); + let get_line = |bytepos: BytePos| file.lookup_line(file.relative_position(bytepos)); Some(SyntaxRange { byte_span: (get_pos(span.lo()), get_pos(span.hi())), diff --git a/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs b/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs index f2ef602012f73..7956bf126223a 100644 --- a/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -12,7 +12,7 @@ use rustc_lexer::{tokenize, TokenKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use rustc_span::{BytePos, Pos, Span, SyntaxContext}; +use rustc_span::{BytePos, RelativeBytePos,Pos, Span, SyntaxContext}; declare_clippy_lint! { /// ### What it does @@ -688,7 +688,7 @@ fn span_in_body_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool { } /// Checks if the given text has a safety comment for the immediately proceeding line. -fn text_has_safety_comment(src: &str, line_starts: &[BytePos], offset: usize) -> Option { +fn text_has_safety_comment(src: &str, line_starts: &[RelativeBytePos], offset: usize) -> Option { let mut lines = line_starts .array_windows::<2>() .rev() diff --git a/src/tools/clippy/clippy_utils/src/source.rs b/src/tools/clippy/clippy_utils/src/source.rs index dc4ee72568176..03416d35ba452 100644 --- a/src/tools/clippy/clippy_utils/src/source.rs +++ b/src/tools/clippy/clippy_utils/src/source.rs @@ -8,7 +8,7 @@ use rustc_hir::{BlockCheckMode, Expr, ExprKind, UnsafeSource}; use rustc_lint::{LateContext, LintContext}; use rustc_session::Session; use rustc_span::source_map::{original_sp, SourceMap}; -use rustc_span::{hygiene, BytePos, Pos, SourceFile, Span, SpanData, SyntaxContext, DUMMY_SP}; +use rustc_span::{hygiene, BytePos, SourceFileAndLine, Pos, SourceFile, Span, SpanData, SyntaxContext, DUMMY_SP}; use std::borrow::Cow; use std::ops::Range; @@ -117,9 +117,9 @@ fn first_char_in_first_line(cx: &T, span: Span) -> Option(cx: &T, span: Span) -> Span { let span = original_sp(span, DUMMY_SP); - let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap(); - let line_no = source_map_and_line.line; - let line_start = source_map_and_line.sf.lines(|lines| lines[line_no]); + let SourceFileAndLine { sf, line } = cx.sess().source_map().lookup_line(span.lo()).unwrap(); + let line_start = sf.lines(|lines| lines[line]); + let line_start = sf.absolute_position(line_start); span.with_lo(line_start) } diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index d815d69d6bab5..3f94bb2993373 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -268,7 +268,7 @@ impl ParseSess { let source_file = self.parse_sess.source_map().lookup_char_pos(span.lo()).file; SnippetProvider::new( source_file.start_pos, - source_file.end_pos, + source_file.end_position(), Lrc::clone(source_file.src.as_ref().unwrap()), ) } From 642251b71f8395f7dd24e04c9d2b1716d3963112 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 2 Sep 2023 19:50:33 -0400 Subject: [PATCH 36/73] Use std::io::Error::is_interrupted everywhere --- library/std/src/io/buffered/bufwriter.rs | 2 +- library/std/src/io/copy.rs | 11 ++++++----- library/std/src/io/mod.rs | 2 +- library/std/src/os/unix/fs.rs | 4 ++-- library/std/src/os/wasi/fs.rs | 4 ++-- library/std/src/sys/hermit/mod.rs | 2 +- library/std/src/sys/hermit/net.rs | 2 +- library/std/src/sys/unix/fs.rs | 2 +- library/std/src/sys/unix/mod.rs | 2 +- library/std/src/sys/unix/net.rs | 2 +- library/std/src/sys/unix/process/process_unix.rs | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/std/src/io/buffered/bufwriter.rs index 0f04f29111793..95ba82e1e0755 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/std/src/io/buffered/bufwriter.rs @@ -237,7 +237,7 @@ impl BufWriter { )); } Ok(n) => guard.consume(n), - Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } diff --git a/library/std/src/io/copy.rs b/library/std/src/io/copy.rs index 3322940d2452f..57d226a3771e5 100644 --- a/library/std/src/io/copy.rs +++ b/library/std/src/io/copy.rs @@ -1,4 +1,4 @@ -use super::{BorrowedBuf, BufReader, BufWriter, ErrorKind, Read, Result, Write, DEFAULT_BUF_SIZE}; +use super::{BorrowedBuf, BufReader, BufWriter, Read, Result, Write, DEFAULT_BUF_SIZE}; use crate::alloc::Allocator; use crate::cmp; use crate::collections::VecDeque; @@ -30,6 +30,7 @@ mod tests; /// /// [`read`]: Read::read /// [`write`]: Write::write +/// [`ErrorKind::Interrupted`]: crate::io::ErrorKind::Interrupted /// /// # Examples /// @@ -163,7 +164,7 @@ where // from adding I: Read match self.read(&mut []) { Ok(_) => {} - Err(e) if e.kind() == ErrorKind::Interrupted => continue, + Err(e) if e.is_interrupted() => continue, Err(e) => return Err(e), } let buf = self.buffer(); @@ -243,7 +244,7 @@ impl BufferedWriterSpec for BufWriter { // Read again if the buffer still has enough capacity, as BufWriter itself would do // This will occur if the reader returns short reads } - Err(ref e) if e.kind() == ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } else { @@ -275,7 +276,7 @@ impl BufferedWriterSpec for Vec { let mut buf: BorrowedBuf<'_> = self.spare_capacity_mut().into(); match reader.read_buf(buf.unfilled()) { Ok(()) => {} - Err(e) if e.kind() == ErrorKind::Interrupted => continue, + Err(e) if e.is_interrupted() => continue, Err(e) => return Err(e), }; @@ -307,7 +308,7 @@ fn stack_buffer_copy( loop { match reader.read_buf(buf.unfilled()) { Ok(()) => {} - Err(e) if e.kind() == ErrorKind::Interrupted => continue, + Err(e) if e.is_interrupted() => continue, Err(e) => return Err(e), }; diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index e89843b570323..eca64fb6063d5 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1647,7 +1647,7 @@ pub trait Write { )); } Ok(n) => IoSlice::advance_slices(&mut bufs, n), - Err(ref e) if e.kind() == ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } diff --git a/library/std/src/os/unix/fs.rs b/library/std/src/os/unix/fs.rs index 029de8fbf7602..b6dc1a062ed82 100644 --- a/library/std/src/os/unix/fs.rs +++ b/library/std/src/os/unix/fs.rs @@ -123,7 +123,7 @@ pub trait FileExt { buf = &mut tmp[n..]; offset += n as u64; } - Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } @@ -258,7 +258,7 @@ pub trait FileExt { buf = &buf[n..]; offset += n as u64 } - Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } diff --git a/library/std/src/os/wasi/fs.rs b/library/std/src/os/wasi/fs.rs index 160c8f1eca251..3da8c835511ac 100644 --- a/library/std/src/os/wasi/fs.rs +++ b/library/std/src/os/wasi/fs.rs @@ -82,7 +82,7 @@ pub trait FileExt { buf = &mut tmp[n..]; offset += n as u64; } - Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } @@ -162,7 +162,7 @@ pub trait FileExt { buf = &buf[n..]; offset += n as u64 } - Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => return Err(e), } } diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs index c7cb8466705cb..594cea0becc62 100644 --- a/library/std/src/sys/hermit/mod.rs +++ b/library/std/src/sys/hermit/mod.rs @@ -196,7 +196,7 @@ where { loop { match cvt(f()) { - Err(ref e) if e.kind() == ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} other => return other, } } diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index 8c2d489d6a362..3cea6f43fe6a9 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -108,7 +108,7 @@ impl Socket { match unsafe { netc::poll(&mut pollfd, 1, timeout) } { -1 => { let err = io::Error::last_os_error(); - if err.kind() != io::ErrorKind::Interrupted { + if !err.is_interrupted() { return Err(err); } } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index a5604c92a80ba..61ea87a5b0cec 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -792,7 +792,7 @@ impl Drop for Dir { fn drop(&mut self) { let r = unsafe { libc::closedir(self.0) }; assert!( - r == 0 || crate::io::Error::last_os_error().kind() == crate::io::ErrorKind::Interrupted, + r == 0 || crate::io::Error::last_os_error().is_interrupted(), "unexpected error during closedir: {:?}", crate::io::Error::last_os_error() ); diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 6d74390331495..692d3ab7cc970 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -320,7 +320,7 @@ where { loop { match cvt(f()) { - Err(ref e) if e.kind() == ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} other => return other, } } diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 7258c222a6c19..ade8c75a65713 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -184,7 +184,7 @@ impl Socket { match unsafe { libc::poll(&mut pollfd, 1, timeout) } { -1 => { let err = io::Error::last_os_error(); - if err.kind() != io::ErrorKind::Interrupted { + if !err.is_interrupted() { return Err(err); } } diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 3963e7f52d552..75b5406450195 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -165,7 +165,7 @@ impl Command { assert!(p.wait().is_ok(), "wait() should either return Ok or panic"); return Err(Error::from_raw_os_error(errno)); } - Err(ref e) if e.kind() == ErrorKind::Interrupted => {} + Err(ref e) if e.is_interrupted() => {} Err(e) => { assert!(p.wait().is_ok(), "wait() should either return Ok or panic"); panic!("the CLOEXEC pipe failed: {e:?}") From 548ba13265c702cf98a163fc11e5bc04c57d2121 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 3 Sep 2023 12:45:23 +0000 Subject: [PATCH 37/73] Register the file while computing its start position. --- compiler/rustc_metadata/src/rmeta/decoder.rs | 2 +- compiler/rustc_span/src/lib.rs | 14 ++-- compiler/rustc_span/src/source_map.rs | 69 +++++++++----------- compiler/rustc_span/src/source_map/tests.rs | 2 +- compiler/rustc_span/src/tests.rs | 3 +- 5 files changed, 44 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 5ecf8005292ec..7fd3c0f494a11 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1552,7 +1552,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { name, src_hash, name_hash, - source_len.to_usize(), + source_len.to_u32(), self.cnum, lines, multibyte_chars, diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index b1cde3093efc6..34714957aefe1 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1519,7 +1519,11 @@ impl fmt::Debug for SourceFile { } impl SourceFile { - pub fn new(name: FileName, mut src: String, hash_kind: SourceFileHashAlgorithm) -> Self { + pub fn new( + name: FileName, + mut src: String, + hash_kind: SourceFileHashAlgorithm, + ) -> Result { // Compute the file hash before any normalization. let src_hash = SourceFileHash::new(hash_kind, &src); let normalized_pos = normalize_src(&mut src); @@ -1530,25 +1534,25 @@ impl SourceFile { hasher.finish() }; let source_len = src.len(); - assert!(source_len <= u32::MAX as usize); + let source_len = u32::try_from(source_len).map_err(|_| OffsetOverflowError)?; let (lines, multibyte_chars, non_narrow_chars) = analyze_source_file::analyze_source_file(&src); - SourceFile { + Ok(SourceFile { name, src: Some(Lrc::new(src)), src_hash, external_src: Lock::new(ExternalSource::Unneeded), start_pos: BytePos::from_u32(0), - source_len: RelativeBytePos::from_usize(source_len), + source_len: RelativeBytePos::from_u32(source_len), lines: Lock::new(SourceFileLines::Lines(lines)), multibyte_chars, non_narrow_chars, normalized_pos, name_hash, cnum: LOCAL_CRATE, - } + }) } pub fn lines(&self, f: F) -> R diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 07483280f41d0..2290f9c7c6fb7 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -267,10 +267,13 @@ impl SourceMap { self.files.borrow().stable_id_to_source_file.get(&stable_id).cloned() } - fn allocate_address_space(&self, size: usize) -> Result { - let size = u32::try_from(size).map_err(|_| OffsetOverflowError)?; + fn register_source_file( + &self, + mut file: SourceFile, + ) -> Result, OffsetOverflowError> { + let size = file.source_len.to_u32(); - loop { + let start_pos = loop { let current = self.used_address_space.load(Ordering::Relaxed); let next = current .checked_add(size) @@ -284,9 +287,20 @@ impl SourceMap { .compare_exchange(current, next, Ordering::Relaxed, Ordering::Relaxed) .is_ok() { - return Ok(usize::try_from(current).unwrap()); + break usize::try_from(current).unwrap(); } - } + }; + + file.start_pos = BytePos::from_usize(start_pos); + let file_id = StableSourceFileId::new(&file); + + let mut files = self.files.borrow_mut(); + + let file = Lrc::new(file); + files.source_files.push(file.clone()); + files.stable_id_to_source_file.insert(file_id, file.clone()); + + Ok(file) } /// Creates a new `SourceFile`. @@ -310,29 +324,18 @@ impl SourceMap { let (filename, _) = self.path_mapping.map_filename_prefix(&filename); let file_id = StableSourceFileId::new_from_name(&filename, LOCAL_CRATE); - - let lrc_sf = match self.source_file_by_stable_id(file_id) { - Some(lrc_sf) => lrc_sf, + match self.source_file_by_stable_id(file_id) { + Some(lrc_sf) => Ok(lrc_sf), None => { - let mut source_file = SourceFile::new(filename, src, self.hash_kind); + let source_file = SourceFile::new(filename, src, self.hash_kind)?; // Let's make sure the file_id we generated above actually matches // the ID we generate for the SourceFile we just created. debug_assert_eq!(StableSourceFileId::new(&source_file), file_id); - let start_pos = self.allocate_address_space(source_file.source_len.to_usize())?; - source_file.start_pos = BytePos::from_usize(start_pos); - - let mut files = self.files.borrow_mut(); - - let source_file = Lrc::new(source_file); - files.source_files.push(source_file.clone()); - files.stable_id_to_source_file.insert(file_id, source_file.clone()); - - source_file + self.register_source_file(source_file) } - }; - Ok(lrc_sf) + } } /// Allocates a new `SourceFile` representing a source file from an external @@ -344,7 +347,7 @@ impl SourceMap { filename: FileName, src_hash: SourceFileHash, name_hash: Hash128, - source_len: usize, + source_len: u32, cnum: CrateNum, file_local_lines: Lock, multibyte_chars: Vec, @@ -352,13 +355,9 @@ impl SourceMap { normalized_pos: Vec, metadata_index: u32, ) -> Lrc { - let start_pos = self - .allocate_address_space(source_len) - .expect("not enough address space for imported source file"); + let source_len = RelativeBytePos::from_u32(source_len); - let source_len = RelativeBytePos::from_usize(source_len); - - let source_file = Lrc::new(SourceFile { + let source_file = SourceFile { name: filename, src: None, src_hash, @@ -366,7 +365,7 @@ impl SourceMap { kind: ExternalSourceKind::AbsentOk, metadata_index, }), - start_pos: BytePos::from_usize(start_pos), + start_pos: BytePos(0), source_len, lines: file_local_lines, multibyte_chars, @@ -374,16 +373,10 @@ impl SourceMap { normalized_pos, name_hash, cnum, - }); - - let mut files = self.files.borrow_mut(); - - files.source_files.push(source_file.clone()); - files - .stable_id_to_source_file - .insert(StableSourceFileId::new(&source_file), source_file.clone()); + }; - source_file + self.register_source_file(source_file) + .expect("not enough address space for imported source file") } /// If there is a doctest offset, applies it to the line. diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs index d5cb3dac55cf6..7689e6afac56b 100644 --- a/compiler/rustc_span/src/source_map/tests.rs +++ b/compiler/rustc_span/src/source_map/tests.rs @@ -244,7 +244,7 @@ fn t10() { name, src_hash, name_hash, - source_len.to_usize(), + source_len.to_u32(), CrateNum::new(0), lines, multibyte_chars, diff --git a/compiler/rustc_span/src/tests.rs b/compiler/rustc_span/src/tests.rs index 3b69295bb93c7..a980ee8d9e070 100644 --- a/compiler/rustc_span/src/tests.rs +++ b/compiler/rustc_span/src/tests.rs @@ -4,7 +4,8 @@ use super::*; fn test_lookup_line() { let source = "abcdefghijklm\nabcdefghij\n...".to_owned(); let mut sf = - SourceFile::new(FileName::Anon(Hash64::ZERO), source, SourceFileHashAlgorithm::Sha256); + SourceFile::new(FileName::Anon(Hash64::ZERO), source, SourceFileHashAlgorithm::Sha256) + .unwrap(); sf.start_pos = BytePos(3); sf.lines(|lines| { assert_eq!(lines, &[RelativeBytePos(0), RelativeBytePos(14), RelativeBytePos(25)]) From 4a87a44451424e4c2369d4f12af4843a4c85f881 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 3 Sep 2023 12:51:15 +0000 Subject: [PATCH 38/73] Compute address space from previous file. --- compiler/rustc_span/src/source_map.rs | 38 +++++++-------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 2290f9c7c6fb7..50c30a079b457 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -14,13 +14,10 @@ pub use crate::*; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{Hash128, Hash64, StableHasher}; -use rustc_data_structures::sync::{ - AtomicU32, IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock, -}; +use rustc_data_structures::sync::{IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock}; use std::cmp; use std::hash::Hash; use std::path::{self, Path, PathBuf}; -use std::sync::atomic::Ordering; use std::fs; use std::io; @@ -187,9 +184,6 @@ pub(super) struct SourceMapFiles { } pub struct SourceMap { - /// The address space below this value is currently used by the files in the source map. - used_address_space: AtomicU32, - files: RwLock, file_loader: IntoDynSyncSend>, // This is used to apply the file path remapping as specified via @@ -215,7 +209,6 @@ impl SourceMap { hash_kind: SourceFileHashAlgorithm, ) -> SourceMap { SourceMap { - used_address_space: AtomicU32::new(0), files: Default::default(), file_loader: IntoDynSyncSend(file_loader), path_mapping, @@ -271,31 +264,18 @@ impl SourceMap { &self, mut file: SourceFile, ) -> Result, OffsetOverflowError> { - let size = file.source_len.to_u32(); - - let start_pos = loop { - let current = self.used_address_space.load(Ordering::Relaxed); - let next = current - .checked_add(size) - // Add one so there is some space between files. This lets us distinguish - // positions in the `SourceMap`, even in the presence of zero-length files. - .and_then(|next| next.checked_add(1)) - .ok_or(OffsetOverflowError)?; - - if self - .used_address_space - .compare_exchange(current, next, Ordering::Relaxed, Ordering::Relaxed) - .is_ok() - { - break usize::try_from(current).unwrap(); - } - }; - - file.start_pos = BytePos::from_usize(start_pos); let file_id = StableSourceFileId::new(&file); let mut files = self.files.borrow_mut(); + file.start_pos = BytePos(if let Some(last_file) = files.source_files.last() { + // Add one so there is some space between files. This lets us distinguish + // positions in the `SourceMap`, even in the presence of zero-length files. + last_file.end_position().0.checked_add(1).ok_or(OffsetOverflowError)? + } else { + 0 + }); + let file = Lrc::new(file); files.source_files.push(file.clone()); files.stable_id_to_source_file.insert(file_id, file.clone()); From 8ae337e12895348ee8ad58eb000c529f2f856452 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 3 Sep 2023 14:34:40 +0000 Subject: [PATCH 39/73] Fix clippy. --- .../src/undocumented_unsafe_blocks.rs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs b/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs index 7956bf126223a..a1ea3a495eb6a 100644 --- a/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -12,7 +12,7 @@ use rustc_lexer::{tokenize, TokenKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use rustc_span::{BytePos, RelativeBytePos,Pos, Span, SyntaxContext}; +use rustc_span::{BytePos, Pos, RelativeBytePos, Span, SyntaxContext}; declare_clippy_lint! { /// ### What it does @@ -514,7 +514,7 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> HasSaf match text_has_safety_comment( src, &lines[comment_start_line.line + 1..=unsafe_line.line], - unsafe_line.sf.start_pos.to_usize(), + unsafe_line.sf.start_pos, ) { Some(b) => HasSafetyComment::Yes(b), None => HasSafetyComment::No, @@ -558,7 +558,7 @@ fn stmt_has_safety_comment(cx: &LateContext<'_>, span: Span, hir_id: HirId) -> H match text_has_safety_comment( src, &lines[comment_start_line.line + 1..=unsafe_line.line], - unsafe_line.sf.start_pos.to_usize(), + unsafe_line.sf.start_pos, ) { Some(b) => HasSafetyComment::Yes(b), None => HasSafetyComment::No, @@ -619,7 +619,7 @@ fn span_from_macro_expansion_has_safety_comment(cx: &LateContext<'_>, span: Span match text_has_safety_comment( src, &lines[macro_line.line + 1..=unsafe_line.line], - unsafe_line.sf.start_pos.to_usize(), + unsafe_line.sf.start_pos, ) { Some(b) => HasSafetyComment::Yes(b), None => HasSafetyComment::No, @@ -675,7 +675,7 @@ fn span_in_body_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool { body_line.line < unsafe_line.line && text_has_safety_comment( src, &lines[body_line.line + 1..=unsafe_line.line], - unsafe_line.sf.start_pos.to_usize(), + unsafe_line.sf.start_pos, ).is_some() }) } else { @@ -688,13 +688,13 @@ fn span_in_body_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool { } /// Checks if the given text has a safety comment for the immediately proceeding line. -fn text_has_safety_comment(src: &str, line_starts: &[RelativeBytePos], offset: usize) -> Option { +fn text_has_safety_comment(src: &str, line_starts: &[RelativeBytePos], start_pos: BytePos) -> Option { let mut lines = line_starts .array_windows::<2>() .rev() .map_while(|[start, end]| { - let start = start.to_usize() - offset; - let end = end.to_usize() - offset; + let start = start.to_usize(); + let end = end.to_usize(); let text = src.get(start..end)?; let trimmed = text.trim_start(); Some((start + (text.len() - trimmed.len()), trimmed)) @@ -709,9 +709,7 @@ fn text_has_safety_comment(src: &str, line_starts: &[RelativeBytePos], offset: u let (mut line, mut line_start) = (line, line_start); loop { if line.to_ascii_uppercase().contains("SAFETY:") { - return Some(BytePos( - u32::try_from(line_start).unwrap() + u32::try_from(offset).unwrap(), - )); + return Some(start_pos + BytePos(u32::try_from(line_start).unwrap())); } match lines.next() { Some((s, x)) if x.starts_with("//") => (line, line_start) = (x, s), @@ -724,15 +722,13 @@ fn text_has_safety_comment(src: &str, line_starts: &[RelativeBytePos], offset: u let (mut line_start, mut line) = (line_start, line); loop { if line.starts_with("/*") { - let src = &src[line_start..line_starts.last().unwrap().to_usize() - offset]; + let src = &src[line_start..line_starts.last().unwrap().to_usize()]; let mut tokens = tokenize(src); return (src[..tokens.next().unwrap().len as usize] .to_ascii_uppercase() .contains("SAFETY:") && tokens.all(|t| t.kind == TokenKind::Whitespace)) - .then_some(BytePos( - u32::try_from(line_start).unwrap() + u32::try_from(offset).unwrap(), - )); + .then_some(start_pos + BytePos(u32::try_from(line_start).unwrap())); } match lines.next() { Some(x) => (line_start, line) = x, From a8b0e44e86c944350b2064f5c0f297346bf0c32c Mon Sep 17 00:00:00 2001 From: Fulgen301 Date: Sun, 3 Sep 2023 17:04:42 +0200 Subject: [PATCH 40/73] Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of size_of --- library/std/src/sys/windows/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/windows/process.rs b/library/std/src/sys/windows/process.rs index 6f46da1748a70..84a75d213052f 100644 --- a/library/std/src/sys/windows/process.rs +++ b/library/std/src/sys/windows/process.rs @@ -352,7 +352,7 @@ impl Command { }; si_ptr = &mut si_ex as *mut _ as _; } else { - si.cb = mem::size_of:: as c::DWORD; + si.cb = mem::size_of::() as c::DWORD; si_ptr = &mut si as *mut _ as _; } From ec0975dd6bdd2afb2cbe3373ba3da98ec8ef453b Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 3 Sep 2023 17:10:42 +0200 Subject: [PATCH 41/73] Don't forget to normalize the translated message --- compiler/rustc_errors/src/emitter.rs | 8 +++++++- .../const-eval/const_panic-normalize-tabs-115498.rs | 5 +++++ .../const_panic-normalize-tabs-115498.stderr | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs create mode 100644 tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 0cae06881b174..fd8c283bde4b7 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2346,7 +2346,13 @@ impl FileWithAnnotatedLines { } let label = label.as_ref().map(|m| { - emitter.translate_message(m, args).map_err(Report::new).unwrap().to_string() + normalize_whitespace( + &emitter + .translate_message(m, &args) + .map_err(Report::new) + .unwrap() + .to_string(), + ) }); if lo.line != hi.line { diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs new file mode 100644 index 0000000000000..0bf2f0e6669d7 --- /dev/null +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs @@ -0,0 +1,5 @@ +#![crate_type = "lib"] + +struct Bug([u8; panic!{"\t"}]); +//~^ ERROR evaluation of constant value failed +//~| NOTE: in this expansion of panic! diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr new file mode 100644 index 0000000000000..82c63dd176d4d --- /dev/null +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr @@ -0,0 +1,11 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const_panic-normalize-tabs-115498.rs:3:17 + | +LL | struct Bug([u8; panic!{"\t"}]); + | ^^^^^^^^^^^^ the evaluated program panicked at ' ', $DIR/const_panic-normalize-tabs-115498.rs:3:17 + | + = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. From 8c667febbd77547dddd8d4170541b1c43626b9f6 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 3 Sep 2023 19:43:51 +0000 Subject: [PATCH 42/73] Don't ICE on associated type projection without feature gate --- .../src/solve/project_goals.rs | 16 +++++++++++++- .../dont-ice-on-assoc-projection.rs | 19 +++++++++++++++++ .../dont-ice-on-assoc-projection.stderr | 21 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/ui/traits/new-solver/dont-ice-on-assoc-projection.rs create mode 100644 tests/ui/traits/new-solver/dont-ice-on-assoc-projection.stderr diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs index e47e228774e07..df094af4f1f1a 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs @@ -244,7 +244,21 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> { // Finally we construct the actual value of the associated type. let term = match assoc_def.item.kind { ty::AssocKind::Type => tcx.type_of(assoc_def.item.def_id).map_bound(|ty| ty.into()), - ty::AssocKind::Const => bug!("associated const projection is not supported yet"), + ty::AssocKind::Const => { + if tcx.features().associated_const_equality { + bug!("associated const projection is not supported yet") + } else { + ty::EarlyBinder::bind( + ty::Const::new_error_with_message( + tcx, + tcx.type_of(assoc_def.item.def_id).instantiate_identity(), + DUMMY_SP, + "associated const projection is not supported yet", + ) + .into(), + ) + } + } ty::AssocKind::Fn => unreachable!("we should never project to a fn"), }; diff --git a/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.rs b/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.rs new file mode 100644 index 0000000000000..b9798c79d5e1b --- /dev/null +++ b/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.rs @@ -0,0 +1,19 @@ +// compile-flags: -Ztrait-solver=next-coherence + +// Makes sure we don't ICE on associated const projection when the feature gate +// is not enabled, since we should avoid encountering ICEs on stable if possible. + +trait Bar { + const ASSOC: usize; +} +impl Bar for () { + const ASSOC: usize = 1; +} + +trait Foo {} +impl Foo for () {} +impl Foo for T where T: Bar {} +//~^ ERROR associated const equality is incomplete +//~| ERROR conflicting implementations of trait `Foo` for type `()` + +fn main() {} diff --git a/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.stderr b/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.stderr new file mode 100644 index 0000000000000..7ad495a35e0df --- /dev/null +++ b/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.stderr @@ -0,0 +1,21 @@ +error[E0658]: associated const equality is incomplete + --> $DIR/dont-ice-on-assoc-projection.rs:15:32 + | +LL | impl Foo for T where T: Bar {} + | ^^^^^^^^^ + | + = note: see issue #92827 for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0119]: conflicting implementations of trait `Foo` for type `()` + --> $DIR/dont-ice-on-assoc-projection.rs:15:1 + | +LL | impl Foo for () {} + | --------------- first implementation here +LL | impl Foo for T where T: Bar {} + | ^^^^^^^^^^^^^^^^^ conflicting implementation for `()` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0119, E0658. +For more information about an error, try `rustc --explain E0119`. From 9867023f4f501018dd5524366949bd6f09ded192 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 30 Aug 2023 13:45:04 -0400 Subject: [PATCH 43/73] Encode DepKind as u16 --- .../rustc_middle/src/dep_graph/dep_node.rs | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 04c09d334001b..afcf08395bb2b 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -80,12 +80,56 @@ macro_rules! define_dep_nodes { } /// This enum serves as an index into arrays built by `make_dep_kind_array`. - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] + // This enum has more than u8::MAX variants so we need some kind of multi-byte + // encoding. The derived Encodable/Decodable uses leb128 encoding which is + // dense when only considering this enum. But DepKind is encoded in a larger + // struct, and there we can take advantage of the unused bits in the u16. + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[allow(non_camel_case_types)] + #[repr(u16)] pub enum DepKind { $( $( #[$attr] )* $variant),* } + impl DepKind { + // This const implements two things: A bounds check so that we can decode + // a DepKind from a u16 with just one check, and a const check that the + // discriminants of the variants have been assigned consecutively from 0 + // so that just the one comparison suffices to check that the u16 can be + // transmuted to a DepKind. + const VARIANTS: u16 = { + let deps: &[DepKind] = &[$(DepKind::$variant,)*]; + let mut i = 0; + while i < deps.len() { + if i as u16 != deps[i] as u16 { + panic!(); + } + i += 1; + } + deps.len() as u16 + }; + } + + impl rustc_serialize::Encodable for DepKind { + #[inline] + fn encode(&self, s: &mut S) { + s.emit_u16(*self as u16); + } + } + + impl rustc_serialize::Decodable for DepKind { + #[inline] + fn decode(d: &mut D) -> DepKind { + let discrim = d.read_u16(); + assert!(discrim < DepKind::VARIANTS); + // SAFETY: DepKind::VARIANTS checks that the discriminant values permit + // this one check to soundly guard the transmute. + unsafe { + std::mem::transmute::(discrim) + } + } + } + pub(super) fn dep_kind_from_label_string(label: &str) -> Result { match label { $(stringify!($variant) => Ok(DepKind::$variant),)* @@ -114,6 +158,8 @@ rustc_query_append!(define_dep_nodes![ [] fn CompileMonoItem() -> (), ]); +static_assert_size!(DepKind, 2); + // WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys. // Be very careful changing this type signature! pub(crate) fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode { From eba5b447298c00f07f11540eef2d003cc207f9d1 Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 25 Jul 2023 19:37:45 +0200 Subject: [PATCH 44/73] Add OnceHelp lint level (same as OnceNote, except for help) --- .../rustc_errors/src/annotate_snippet_emitter_writer.rs | 2 +- compiler/rustc_errors/src/diagnostic.rs | 8 ++++++++ compiler/rustc_errors/src/lib.rs | 8 +++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index a88fba6dae63d..d7a008f9a57f9 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -91,7 +91,7 @@ fn annotation_type_for_level(level: Level) -> AnnotationType { } Level::Warning(_) => AnnotationType::Warning, Level::Note | Level::OnceNote => AnnotationType::Note, - Level::Help => AnnotationType::Help, + Level::Help | Level::OnceHelp => AnnotationType::Help, // FIXME(#59346): Not sure how to map this level Level::FailureNote => AnnotationType::Error, Level::Allow => panic!("Should not call with Allow"), diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index a96e317df55dc..3fd087b1d5e1e 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -270,6 +270,7 @@ impl Diagnostic { | Level::Note | Level::OnceNote | Level::Help + | Level::OnceHelp | Level::Allow | Level::Expect(_) => false, } @@ -532,6 +533,13 @@ impl Diagnostic { self } + /// Prints the span with a help above it. + /// This is like [`Diagnostic::help()`], but it gets its own span. + pub fn help_once(&mut self, msg: impl Into) -> &mut Self { + self.sub(Level::OnceHelp, msg, MultiSpan::new(), None); + self + } + /// Add a help message attached to this diagnostic with a customizable highlighted message. pub fn highlighted_help(&mut self, msg: Vec<(String, Style)>) -> &mut Self { self.sub_with_highlights(Level::Help, msg, MultiSpan::new(), None); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 9bb1a6a2b140e..55c4ec66cd9ed 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1390,7 +1390,7 @@ impl HandlerInner { debug!(?self.emitted_diagnostics); let already_emitted_sub = |sub: &mut SubDiagnostic| { debug!(?sub); - if sub.level != Level::OnceNote { + if sub.level != Level::OnceNote && sub.level != Level::OnceHelp { return false; } let mut hasher = StableHasher::new(); @@ -1792,6 +1792,8 @@ pub enum Level { /// A note that is only emitted once. OnceNote, Help, + /// A help that is only emitted once. + OnceHelp, FailureNote, Allow, Expect(LintExpectationId), @@ -1816,7 +1818,7 @@ impl Level { Note | OnceNote => { spec.set_fg(Some(Color::Green)).set_intense(true); } - Help => { + Help | OnceHelp => { spec.set_fg(Some(Color::Cyan)).set_intense(true); } FailureNote => {} @@ -1831,7 +1833,7 @@ impl Level { Fatal | Error { .. } => "error", Warning(_) => "warning", Note | OnceNote => "note", - Help => "help", + Help | OnceHelp => "help", FailureNote => "failure-note", Allow => panic!("Shouldn't call on allowed error"), Expect(_) => panic!("Shouldn't call on expected error"), From f404990eb058819e0842a69a60f733a1de56fb66 Mon Sep 17 00:00:00 2001 From: mojave2 Date: Mon, 4 Sep 2023 20:07:28 +0800 Subject: [PATCH 45/73] improve `AttrTokenStream` --- compiler/rustc_ast/src/tokenstream.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index e9591c7c8dbc6..1e18b1232de76 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -213,14 +213,10 @@ impl AttrTokenStream { .into_iter() } AttrTokenTree::Attributes(data) => { - let mut outer_attrs = Vec::new(); - let mut inner_attrs = Vec::new(); - for attr in &data.attrs { - match attr.style { - crate::AttrStyle::Outer => outer_attrs.push(attr), - crate::AttrStyle::Inner => inner_attrs.push(attr), - } - } + let idx = data + .attrs + .partition_point(|attr| matches!(attr.style, crate::AttrStyle::Outer)); + let (outer_attrs, inner_attrs) = data.attrs.split_at(idx); let mut target_tokens: Vec<_> = data .tokens @@ -265,10 +261,10 @@ impl AttrTokenStream { "Failed to find trailing delimited group in: {target_tokens:?}" ); } - let mut flat: SmallVec<[_; 1]> = SmallVec::new(); + let mut flat: SmallVec<[_; 1]> = + SmallVec::with_capacity(target_tokens.len() + outer_attrs.len()); for attr in outer_attrs { - // FIXME: Make this more efficient - flat.extend(attr.tokens().0.clone().iter().cloned()); + flat.extend(attr.tokens().0.iter().cloned()); } flat.extend(target_tokens); flat.into_iter() From efbe445ba790b5c416bb48df030807a2df2f9f28 Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 25 Jul 2023 19:40:04 +0200 Subject: [PATCH 46/73] Add help to allow lint for the implied by suggestion --- compiler/rustc_middle/src/lint.rs | 3 +++ tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr | 2 ++ .../diagnostic-derive-doc-comment-field.stderr | 2 +- tests/ui/derive-uninhabited-enum-38885.stderr | 1 + tests/ui/lint-group-forbid-always-trumps-cli.stderr | 1 + tests/ui/lint/command-line-lint-group-deny.stderr | 1 + tests/ui/lint/command-line-lint-group-forbid.stderr | 1 + tests/ui/lint/command-line-lint-group-warn.stderr | 1 + .../cap-lints-warn-allowed-warn-by-default-lint.stderr | 1 + tests/ui/lint/force-warn/lint-group-allow-warnings.stderr | 1 + .../lint-group-allowed-cli-warn-by-default-lint.stderr | 1 + tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr | 1 + .../force-warn/lint-group-allowed-warn-by-default-lint.stderr | 1 + tests/ui/lint/future-incompat-test.stderr | 1 + tests/ui/lint/lint-pre-expansion-extern-module.stderr | 1 + tests/ui/macros/must-use-in-macro-55516.stderr | 1 + 16 files changed, 19 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index f62e406692a85..037f84f476fb7 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -225,6 +225,9 @@ pub fn explain_lint_level_source( err.note_once(format!( "`{flag} {hyphen_case_lint_name}` implied by `{flag} {hyphen_case_flag_val}`" )); + err.help_once(format!( + "to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`" + )); } } LintLevelSource::Node { name: lint_attr_name, span, reason, .. } => { diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr index 20486d596d9a3..6e17bbde021ca 100644 --- a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr +++ b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr @@ -13,6 +13,7 @@ LL | fn lintme() { } | ^^^^^^^^^^^^^^^ | = note: `-D test-lint` implied by `-D lint-me` + = help: to override `-D lint-me` add `#[allow(test_lint)]` error: item is named 'pleaselintme' --> $DIR/lint-group-plugin-deny-cmdline.rs:12:1 @@ -21,6 +22,7 @@ LL | fn pleaselintme() { } | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D please-lint` implied by `-D lint-me` + = help: to override `-D lint-me` add `#[allow(please_lint)]` error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index 8c876213ae0eb..e014fc8c693ae 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -23,7 +23,7 @@ LL | arg: NotIntoDiagnosticArg, | = help: normalized in stderr note: required by a bound in `Diagnostic::set_arg` - --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:960:5 + --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:968:5 error: aborting due to 2 previous errors diff --git a/tests/ui/derive-uninhabited-enum-38885.stderr b/tests/ui/derive-uninhabited-enum-38885.stderr index dcdf8f8430ff3..3fabf446dc38e 100644 --- a/tests/ui/derive-uninhabited-enum-38885.stderr +++ b/tests/ui/derive-uninhabited-enum-38885.stderr @@ -9,6 +9,7 @@ LL | Void(Void), | = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis = note: `-W dead-code` implied by `-W unused` + = help: to override `-W unused` add `#[allow(dead_code)]` warning: 1 warning emitted diff --git a/tests/ui/lint-group-forbid-always-trumps-cli.stderr b/tests/ui/lint-group-forbid-always-trumps-cli.stderr index 8910af87ca222..cd042179cce79 100644 --- a/tests/ui/lint-group-forbid-always-trumps-cli.stderr +++ b/tests/ui/lint-group-forbid-always-trumps-cli.stderr @@ -5,6 +5,7 @@ LL | let x = 1; | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `-F unused-variables` implied by `-F unused` + = help: to override `-F unused` add `#[allow(unused_variables)]` error: aborting due to previous error diff --git a/tests/ui/lint/command-line-lint-group-deny.stderr b/tests/ui/lint/command-line-lint-group-deny.stderr index 04c3f6f263790..59d8429ea6967 100644 --- a/tests/ui/lint/command-line-lint-group-deny.stderr +++ b/tests/ui/lint/command-line-lint-group-deny.stderr @@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing` | = note: `-D non-snake-case` implied by `-D bad-style` + = help: to override `-D bad-style` add `#[allow(non_snake_case)]` error: aborting due to previous error diff --git a/tests/ui/lint/command-line-lint-group-forbid.stderr b/tests/ui/lint/command-line-lint-group-forbid.stderr index 736782140639a..486d32a9f08c6 100644 --- a/tests/ui/lint/command-line-lint-group-forbid.stderr +++ b/tests/ui/lint/command-line-lint-group-forbid.stderr @@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing` | = note: `-F non-snake-case` implied by `-F bad-style` + = help: to override `-F bad-style` add `#[allow(non_snake_case)]` error: aborting due to previous error diff --git a/tests/ui/lint/command-line-lint-group-warn.stderr b/tests/ui/lint/command-line-lint-group-warn.stderr index e9c80b4ef21af..cfe346a5bf6b0 100644 --- a/tests/ui/lint/command-line-lint-group-warn.stderr +++ b/tests/ui/lint/command-line-lint-group-warn.stderr @@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing` | = note: `-W non-snake-case` implied by `-W bad-style` + = help: to override `-W bad-style` add `#[allow(non_snake_case)]` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr index d1b764b341435..01c2ed84c635a 100644 --- a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr @@ -7,6 +7,7 @@ LL | 0...100 => true, = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility` + = help: to override `--force-warn rust-2021-compatibility` add `#[allow(ellipsis_inclusive_range_patterns)]` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr index dc7b1b7b98d0c..e925a195fb1c4 100644 --- a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr +++ b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr @@ -5,6 +5,7 @@ LL | pub fn FUNCTION() {} | ^^^^^^^^ help: convert the identifier to snake case: `function` | = note: `--force-warn non-snake-case` implied by `--force-warn nonstandard-style` + = help: to override `--force-warn nonstandard-style` add `#[allow(non_snake_case)]` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr index e17630fd35815..b0cd3ddd26f2f 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -7,6 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` + = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]` help: use `dyn` | LL | pub fn function(_x: Box) {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr index 72198541a7041..8c841916c93d4 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -7,6 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` + = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]` help: use `dyn` | LL | pub fn function(_x: Box) {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr index 52c870ac28ae6..c0144205d6a9b 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -7,6 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` + = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]` help: use `dyn` | LL | pub fn function(_x: Box) {} diff --git a/tests/ui/lint/future-incompat-test.stderr b/tests/ui/lint/future-incompat-test.stderr index 52674a843847d..2951f904fb5e8 100644 --- a/tests/ui/lint/future-incompat-test.stderr +++ b/tests/ui/lint/future-incompat-test.stderr @@ -6,4 +6,5 @@ LL | let x = 1; | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `-A unused-variables` implied by `-A unused` + = help: to override `-A unused` add `#[allow(unused_variables)]` diff --git a/tests/ui/lint/lint-pre-expansion-extern-module.stderr b/tests/ui/lint/lint-pre-expansion-extern-module.stderr index ce3e8806a9e3c..8a6e1531d5fdb 100644 --- a/tests/ui/lint/lint-pre-expansion-extern-module.stderr +++ b/tests/ui/lint/lint-pre-expansion-extern-module.stderr @@ -7,6 +7,7 @@ LL | pub fn try() {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #49716 = note: `-W keyword-idents` implied by `-W rust-2018-compatibility` + = help: to override `-W rust-2018-compatibility` add `#[allow(keyword_idents)]` warning: 1 warning emitted diff --git a/tests/ui/macros/must-use-in-macro-55516.stderr b/tests/ui/macros/must-use-in-macro-55516.stderr index 8878b0eea0fe0..7bf4aaab51c0b 100644 --- a/tests/ui/macros/must-use-in-macro-55516.stderr +++ b/tests/ui/macros/must-use-in-macro-55516.stderr @@ -6,6 +6,7 @@ LL | write!(&mut example, "{}", 42); | = note: this `Result` may be an `Err` variant, which should be handled = note: `-W unused-must-use` implied by `-W unused` + = help: to override `-W unused` add `#[allow(unused_must_use)]` = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 1 warning emitted From 9190e960e1c6b2c2e73c23e85545656ab1577761 Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 1 Aug 2023 14:02:21 +0200 Subject: [PATCH 47/73] Adjust clippy tests with new rustc help suggestion for lints --- .../absolute_paths/absolute_paths.allow_crates.stderr | 1 + .../absolute_paths/absolute_paths.disallow_crates.stderr | 1 + .../uninlined_format_args.stderr | 2 ++ .../arithmetic_side_effects_allowed.stderr | 1 + .../array_size_threshold/array_size_threshold.stderr | 2 ++ .../await_holding_invalid_type.stderr | 1 + .../ui-toml/conf_deprecated_key/conf_deprecated_key.stderr | 1 + src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr | 1 + .../ui-toml/disallowed_macros/disallowed_macros.stderr | 1 + .../disallowed_names_append/disallowed_names.stderr | 1 + .../disallowed_names_replace/disallowed_names.stderr | 1 + .../ui-toml/doc_valid_idents_append/doc_markdown.stderr | 1 + .../ui-toml/doc_valid_idents_replace/doc_markdown.stderr | 1 + .../ui-toml/excessive_nesting/excessive_nesting.stderr | 1 + .../clippy/tests/ui-toml/expect_used/expect_used.stderr | 1 + .../tests/ui-toml/fn_params_excessive_bools/test.stderr | 1 + .../clippy/tests/ui-toml/functions_maxlines/test.stderr | 1 + .../tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr | 1 + .../tests/ui-toml/large_futures/large_futures.stderr | 1 + .../ui-toml/large_include_file/large_include_file.stderr | 1 + .../tests/ui-toml/lint_decimal_readability/test.stderr | 2 ++ .../tests/ui-toml/min_ident_chars/min_ident_chars.stderr | 1 + .../tests/ui-toml/min_rust_version/min_rust_version.stderr | 1 + .../conf_missing_enforced_import_rename.stderr | 1 + .../tests/ui-toml/module_inception/module_inception.stderr | 1 + .../conf_nonstandard_macro_braces.stderr | 1 + .../clippy/tests/ui-toml/print_macro/print_macro.stderr | 2 ++ .../pub_crate_missing_docs/pub_crate_missing_doc.stderr | 1 + src/tools/clippy/tests/ui-toml/semicolon_block/both.stderr | 2 ++ .../ui-toml/semicolon_block/semicolon_inside_block.stderr | 1 + .../ui-toml/semicolon_block/semicolon_outside_block.stderr | 1 + .../ui-toml/strict_non_send_fields_in_send_ty/test.stderr | 1 + .../tests/ui-toml/struct_excessive_bools/test.stderr | 1 + .../tests/ui-toml/suppress_lint_in_const/test.stderr | 1 + .../toml_disallow/conf_french_disallowed_name.stderr | 1 + .../toml_disallowed_methods/conf_disallowed_methods.stderr | 1 + .../toml_disallowed_types/conf_disallowed_types.stderr | 1 + .../clippy/tests/ui-toml/toml_trivially_copy/test.stderr | 1 + .../undocumented_unsafe_blocks.stderr | 2 ++ .../clippy/tests/ui-toml/unwrap_used/unwrap_used.stderr | 2 ++ .../upper_case_acronyms.stderr | 1 + src/tools/clippy/tests/ui-toml/vec_box_sized/test.stderr | 1 + .../clippy/tests/ui/absurd-extreme-comparisons.stderr | 1 + src/tools/clippy/tests/ui/allow_attributes.stderr | 1 + src/tools/clippy/tests/ui/almost_complete_range.stderr | 1 + src/tools/clippy/tests/ui/approx_const.stderr | 1 + src/tools/clippy/tests/ui/arc_with_non_send_sync.stderr | 1 + src/tools/clippy/tests/ui/arithmetic_side_effects.stderr | 1 + src/tools/clippy/tests/ui/as_conversions.stderr | 1 + src/tools/clippy/tests/ui/as_ptr_cast_mut.stderr | 1 + src/tools/clippy/tests/ui/as_underscore.stderr | 1 + src/tools/clippy/tests/ui/asm_syntax.stderr | 2 ++ src/tools/clippy/tests/ui/assertions_on_constants.stderr | 1 + .../clippy/tests/ui/assertions_on_result_states.stderr | 1 + src/tools/clippy/tests/ui/assign_ops.stderr | 1 + src/tools/clippy/tests/ui/assign_ops2.stderr | 2 ++ src/tools/clippy/tests/ui/async_yields_async.stderr | 1 + src/tools/clippy/tests/ui/attrs.stderr | 2 ++ src/tools/clippy/tests/ui/await_holding_lock.stderr | 1 + src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr | 1 + src/tools/clippy/tests/ui/bit_masks.stderr | 2 ++ .../tests/ui/blanket_clippy_restriction_lints.stderr | 1 + src/tools/clippy/tests/ui/blocks_in_if_conditions.stderr | 2 ++ .../clippy/tests/ui/blocks_in_if_conditions_closure.stderr | 1 + src/tools/clippy/tests/ui/bool_assert_comparison.stderr | 1 + src/tools/clippy/tests/ui/bool_comparison.stderr | 1 + src/tools/clippy/tests/ui/bool_to_int_with_if.stderr | 1 + src/tools/clippy/tests/ui/borrow_as_ptr.stderr | 1 + src/tools/clippy/tests/ui/borrow_as_ptr_no_std.stderr | 1 + src/tools/clippy/tests/ui/borrow_deref_ref.stderr | 1 + .../clippy/tests/ui/borrow_deref_ref_unfixable.stderr | 1 + src/tools/clippy/tests/ui/box_collection.stderr | 1 + src/tools/clippy/tests/ui/box_default.stderr | 1 + src/tools/clippy/tests/ui/boxed_local.stderr | 1 + src/tools/clippy/tests/ui/builtin_type_shadow.stderr | 1 + src/tools/clippy/tests/ui/bytes_count_to_len.stderr | 1 + src/tools/clippy/tests/ui/bytes_nth.stderr | 1 + .../ui/case_sensitive_file_extension_comparisons.stderr | 1 + src/tools/clippy/tests/ui/cast.stderr | 5 +++++ src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr | 1 + src/tools/clippy/tests/ui/cast_alignment.stderr | 1 + src/tools/clippy/tests/ui/cast_enum_constructor.stderr | 1 + src/tools/clippy/tests/ui/cast_lossless_bool.stderr | 1 + src/tools/clippy/tests/ui/cast_lossless_float.stderr | 1 + src/tools/clippy/tests/ui/cast_lossless_integer.stderr | 1 + src/tools/clippy/tests/ui/cast_nan_to_int.stderr | 1 + .../clippy/tests/ui/cast_raw_slice_pointer_cast.stderr | 1 + src/tools/clippy/tests/ui/cast_size.stderr | 3 +++ src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr | 1 + src/tools/clippy/tests/ui/cfg_features.stderr | 1 + src/tools/clippy/tests/ui/char_lit_as_u8.stderr | 1 + .../clippy/tests/ui/char_lit_as_u8_suggestions.stderr | 1 + src/tools/clippy/tests/ui/checked_conversions.stderr | 1 + src/tools/clippy/tests/ui/clear_with_drain.stderr | 1 + src/tools/clippy/tests/ui/clone_on_copy.stderr | 1 + src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr | 1 + src/tools/clippy/tests/ui/cmp_null.stderr | 1 + .../clippy/tests/ui/cmp_owned/asymmetric_partial_eq.stderr | 1 + src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr | 1 + src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr | 1 + .../clippy/tests/ui/cmp_owned/without_suggestion.stderr | 1 + src/tools/clippy/tests/ui/cognitive_complexity.stderr | 1 + .../clippy/tests/ui/cognitive_complexity_attr_used.stderr | 1 + src/tools/clippy/tests/ui/collapsible_else_if.stderr | 1 + src/tools/clippy/tests/ui/collapsible_if.stderr | 1 + src/tools/clippy/tests/ui/collapsible_match.stderr | 1 + src/tools/clippy/tests/ui/collapsible_match2.stderr | 1 + src/tools/clippy/tests/ui/collapsible_str_replace.stderr | 1 + src/tools/clippy/tests/ui/collection_is_never_read.stderr | 1 + src/tools/clippy/tests/ui/comparison_chain.stderr | 1 + src/tools/clippy/tests/ui/comparison_to_empty.stderr | 1 + src/tools/clippy/tests/ui/const_comparisons.stderr | 2 ++ src/tools/clippy/tests/ui/copy_iterator.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-10148.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-10645.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-10912.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-2774.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-360.stderr | 2 ++ src/tools/clippy/tests/ui/crashes/ice-3969.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-5835.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-5872.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-6254.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-7169.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-7868.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-7869.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-8250.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-8821.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-8850.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-9041.stderr | 1 + src/tools/clippy/tests/ui/crashes/ice-9445.stderr | 1 + .../ui/crashes/needless_pass_by_value-w-late-bound.stderr | 1 + src/tools/clippy/tests/ui/crate_in_macro_def.stderr | 1 + .../clippy/tests/ui/crate_level_checks/no_std_swap.stderr | 1 + .../tests/ui/crate_level_checks/std_main_recursion.stderr | 1 + src/tools/clippy/tests/ui/create_dir.stderr | 1 + src/tools/clippy/tests/ui/dbg_macro.stderr | 1 + .../clippy/tests/ui/debug_assert_with_mut_call.stderr | 1 + .../clippy/tests/ui/decimal_literal_representation.stderr | 1 + .../tests/ui/declare_interior_mutable_const/enums.stderr | 1 + .../tests/ui/declare_interior_mutable_const/others.stderr | 1 + .../tests/ui/declare_interior_mutable_const/traits.stderr | 1 + src/tools/clippy/tests/ui/def_id_nocore.stderr | 1 + .../tests/ui/default_constructed_unit_structs.stderr | 1 + .../clippy/tests/ui/default_instead_of_iter_empty.stderr | 1 + .../clippy/tests/ui/default_numeric_fallback_f64.stderr | 1 + .../clippy/tests/ui/default_numeric_fallback_i32.stderr | 1 + .../clippy/tests/ui/default_union_representation.stderr | 1 + src/tools/clippy/tests/ui/deprecated.stderr | 1 + src/tools/clippy/tests/ui/deprecated_old.stderr | 1 + src/tools/clippy/tests/ui/deref_addrof.stderr | 1 + .../clippy/tests/ui/deref_addrof_double_trigger.stderr | 1 + src/tools/clippy/tests/ui/deref_by_slicing.stderr | 1 + src/tools/clippy/tests/ui/derivable_impls.stderr | 1 + src/tools/clippy/tests/ui/derive.stderr | 1 + .../clippy/tests/ui/derive_ord_xor_partial_ord.stderr | 1 + .../clippy/tests/ui/derive_partial_eq_without_eq.stderr | 1 + src/tools/clippy/tests/ui/disallowed_names.stderr | 1 + src/tools/clippy/tests/ui/diverging_sub_expression.stderr | 1 + src/tools/clippy/tests/ui/doc/doc-fixable.stderr | 1 + src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr | 1 + src/tools/clippy/tests/ui/doc_errors.stderr | 1 + src/tools/clippy/tests/ui/doc_link_with_quotes.stderr | 1 + src/tools/clippy/tests/ui/doc_unsafe.stderr | 1 + src/tools/clippy/tests/ui/double_comparison.stderr | 1 + src/tools/clippy/tests/ui/double_must_use.stderr | 1 + src/tools/clippy/tests/ui/double_neg.stderr | 1 + src/tools/clippy/tests/ui/double_parens.stderr | 1 + src/tools/clippy/tests/ui/drop_non_drop.stderr | 1 + .../clippy/tests/ui/duplicate_underscore_argument.stderr | 1 + src/tools/clippy/tests/ui/duration_subsec.stderr | 1 + src/tools/clippy/tests/ui/else_if_without_else.stderr | 1 + src/tools/clippy/tests/ui/empty_drop.stderr | 1 + src/tools/clippy/tests/ui/empty_enum.stderr | 1 + .../clippy/tests/ui/empty_line_after_doc_comments.stderr | 1 + .../tests/ui/empty_line_after_outer_attribute.stderr | 1 + src/tools/clippy/tests/ui/empty_loop.stderr | 1 + src/tools/clippy/tests/ui/empty_loop_no_std.stderr | 1 + .../clippy/tests/ui/empty_structs_with_brackets.stderr | 1 + src/tools/clippy/tests/ui/endian_bytes.stderr | 3 +++ src/tools/clippy/tests/ui/entry.stderr | 1 + src/tools/clippy/tests/ui/entry_btree.stderr | 1 + src/tools/clippy/tests/ui/entry_with_else.stderr | 1 + src/tools/clippy/tests/ui/enum_glob_use.stderr | 1 + src/tools/clippy/tests/ui/enum_variants.stderr | 1 + src/tools/clippy/tests/ui/eprint_with_newline.stderr | 1 + src/tools/clippy/tests/ui/eq_op.stderr | 1 + src/tools/clippy/tests/ui/eq_op_macros.stderr | 1 + src/tools/clippy/tests/ui/equatable_if_let.stderr | 1 + src/tools/clippy/tests/ui/erasing_op.stderr | 1 + src/tools/clippy/tests/ui/err_expect.stderr | 1 + src/tools/clippy/tests/ui/error_impl_error.stderr | 1 + src/tools/clippy/tests/ui/eta.stderr | 2 ++ src/tools/clippy/tests/ui/excessive_precision.stderr | 1 + src/tools/clippy/tests/ui/exit1.stderr | 1 + src/tools/clippy/tests/ui/exit2.stderr | 1 + src/tools/clippy/tests/ui/expect.stderr | 1 + src/tools/clippy/tests/ui/expect_fun_call.stderr | 1 + src/tools/clippy/tests/ui/expect_tool_lint_rfc_2383.stderr | 1 + src/tools/clippy/tests/ui/explicit_auto_deref.stderr | 1 + src/tools/clippy/tests/ui/explicit_counter_loop.stderr | 1 + src/tools/clippy/tests/ui/explicit_deref_methods.stderr | 1 + src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr | 1 + src/tools/clippy/tests/ui/explicit_iter_loop.stderr | 1 + src/tools/clippy/tests/ui/explicit_write.stderr | 1 + src/tools/clippy/tests/ui/extend_with_drain.stderr | 1 + src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr | 1 + .../clippy/tests/ui/extra_unused_type_parameters.stderr | 1 + .../tests/ui/extra_unused_type_parameters_unfixable.stderr | 1 + .../clippy/tests/ui/field_reassign_with_default.stderr | 1 + src/tools/clippy/tests/ui/filetype_is_file.stderr | 1 + src/tools/clippy/tests/ui/filter_map_bool_then.stderr | 1 + src/tools/clippy/tests/ui/filter_map_identity.stderr | 1 + src/tools/clippy/tests/ui/filter_map_next.stderr | 1 + src/tools/clippy/tests/ui/filter_map_next_fixable.stderr | 1 + src/tools/clippy/tests/ui/flat_map_identity.stderr | 1 + src/tools/clippy/tests/ui/flat_map_option.stderr | 1 + src/tools/clippy/tests/ui/float_arithmetic.stderr | 1 + src/tools/clippy/tests/ui/float_cmp.stderr | 1 + src/tools/clippy/tests/ui/float_cmp_const.stderr | 1 + .../clippy/tests/ui/float_equality_without_abs.stderr | 1 + src/tools/clippy/tests/ui/floating_point_abs.stderr | 1 + src/tools/clippy/tests/ui/floating_point_exp.stderr | 1 + src/tools/clippy/tests/ui/floating_point_hypot.stderr | 1 + src/tools/clippy/tests/ui/floating_point_log.stderr | 2 ++ src/tools/clippy/tests/ui/floating_point_logbase.stderr | 1 + src/tools/clippy/tests/ui/floating_point_mul_add.stderr | 1 + src/tools/clippy/tests/ui/floating_point_powf.stderr | 2 ++ src/tools/clippy/tests/ui/floating_point_powi.stderr | 1 + src/tools/clippy/tests/ui/floating_point_rad.stderr | 1 + src/tools/clippy/tests/ui/fn_address_comparisons.stderr | 1 + src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr | 1 + src/tools/clippy/tests/ui/fn_to_numeric_cast.stderr | 2 ++ src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr | 1 + src/tools/clippy/tests/ui/for_kv_map.stderr | 1 + src/tools/clippy/tests/ui/forget_non_drop.stderr | 1 + src/tools/clippy/tests/ui/format.stderr | 1 + src/tools/clippy/tests/ui/format_args.stderr | 1 + src/tools/clippy/tests/ui/format_args_unfixable.stderr | 1 + src/tools/clippy/tests/ui/format_collect.stderr | 1 + src/tools/clippy/tests/ui/format_push_string.stderr | 1 + src/tools/clippy/tests/ui/formatting.stderr | 2 ++ src/tools/clippy/tests/ui/four_forward_slashes.stderr | 1 + .../clippy/tests/ui/four_forward_slashes_first_line.stderr | 1 + .../clippy/tests/ui/from_iter_instead_of_collect.stderr | 1 + src/tools/clippy/tests/ui/from_over_into.stderr | 1 + src/tools/clippy/tests/ui/from_over_into_unfixable.stderr | 1 + src/tools/clippy/tests/ui/from_raw_with_void_ptr.stderr | 1 + src/tools/clippy/tests/ui/from_str_radix_10.stderr | 1 + src/tools/clippy/tests/ui/functions.stderr | 2 ++ src/tools/clippy/tests/ui/functions_maxlines.stderr | 1 + src/tools/clippy/tests/ui/future_not_send.stderr | 1 + src/tools/clippy/tests/ui/get_first.stderr | 1 + src/tools/clippy/tests/ui/get_last_with_len.stderr | 1 + src/tools/clippy/tests/ui/get_unwrap.stderr | 1 + src/tools/clippy/tests/ui/identity_op.stderr | 1 + src/tools/clippy/tests/ui/if_let_mutex.stderr | 1 + src/tools/clippy/tests/ui/if_not_else.stderr | 1 + src/tools/clippy/tests/ui/if_same_then_else.stderr | 1 + src/tools/clippy/tests/ui/if_same_then_else2.stderr | 1 + src/tools/clippy/tests/ui/if_then_some_else_none.stderr | 1 + src/tools/clippy/tests/ui/ifs_same_cond.stderr | 1 + src/tools/clippy/tests/ui/ignored_unit_patterns.stderr | 1 + src/tools/clippy/tests/ui/impl.stderr | 1 + src/tools/clippy/tests/ui/impl_trait_in_params.stderr | 1 + src/tools/clippy/tests/ui/implicit_clone.stderr | 1 + src/tools/clippy/tests/ui/implicit_return.stderr | 1 + src/tools/clippy/tests/ui/implicit_saturating_add.stderr | 1 + src/tools/clippy/tests/ui/implicit_saturating_sub.stderr | 1 + src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr | 1 + .../clippy/tests/ui/inconsistent_digit_grouping.stderr | 1 + .../clippy/tests/ui/inconsistent_struct_constructor.stderr | 1 + src/tools/clippy/tests/ui/indexing_slicing_index.stderr | 1 + src/tools/clippy/tests/ui/indexing_slicing_slice.stderr | 2 ++ .../clippy/tests/ui/infallible_destructuring_match.stderr | 1 + src/tools/clippy/tests/ui/infinite_loop.stderr | 1 + src/tools/clippy/tests/ui/inherent_to_string.stderr | 1 + src/tools/clippy/tests/ui/inline_fn_without_body.stderr | 1 + src/tools/clippy/tests/ui/inspect_for_each.stderr | 1 + src/tools/clippy/tests/ui/int_plus_one.stderr | 1 + src/tools/clippy/tests/ui/integer_division.stderr | 1 + src/tools/clippy/tests/ui/into_iter_on_ref.stderr | 1 + .../clippy/tests/ui/invalid_upcast_comparisons.stderr | 1 + src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr | 1 + src/tools/clippy/tests/ui/issue-7447.stderr | 1 + src/tools/clippy/tests/ui/issue_4266.stderr | 2 ++ src/tools/clippy/tests/ui/items_after_statement.stderr | 1 + src/tools/clippy/tests/ui/iter_cloned_collect.stderr | 1 + src/tools/clippy/tests/ui/iter_count.stderr | 1 + src/tools/clippy/tests/ui/iter_kv_map.stderr | 1 + src/tools/clippy/tests/ui/iter_next_slice.stderr | 1 + .../clippy/tests/ui/iter_not_returning_iterator.stderr | 1 + src/tools/clippy/tests/ui/iter_nth.stderr | 1 + src/tools/clippy/tests/ui/iter_nth_zero.stderr | 1 + src/tools/clippy/tests/ui/iter_on_empty_collections.stderr | 1 + src/tools/clippy/tests/ui/iter_on_single_items.stderr | 1 + src/tools/clippy/tests/ui/iter_overeager_cloned.stderr | 2 ++ src/tools/clippy/tests/ui/iter_skip_next.stderr | 1 + src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr | 1 + src/tools/clippy/tests/ui/iter_skip_zero.stderr | 1 + src/tools/clippy/tests/ui/iter_with_drain.stderr | 1 + src/tools/clippy/tests/ui/iterator_step_by_zero.stderr | 1 + src/tools/clippy/tests/ui/large_const_arrays.stderr | 1 + src/tools/clippy/tests/ui/large_digit_groups.stderr | 2 ++ src/tools/clippy/tests/ui/large_enum_variant.stderr | 1 + src/tools/clippy/tests/ui/large_futures.stderr | 1 + src/tools/clippy/tests/ui/large_stack_arrays.stderr | 1 + src/tools/clippy/tests/ui/large_stack_frames.stderr | 1 + .../clippy/tests/ui/large_types_passed_by_value.stderr | 1 + src/tools/clippy/tests/ui/len_without_is_empty.stderr | 2 ++ src/tools/clippy/tests/ui/len_zero.stderr | 2 ++ src/tools/clippy/tests/ui/len_zero_ranges.stderr | 1 + src/tools/clippy/tests/ui/let_and_return.stderr | 1 + src/tools/clippy/tests/ui/let_if_seq.stderr | 1 + src/tools/clippy/tests/ui/let_underscore_future.stderr | 2 ++ src/tools/clippy/tests/ui/let_underscore_lock.stderr | 1 + src/tools/clippy/tests/ui/let_underscore_must_use.stderr | 1 + src/tools/clippy/tests/ui/let_underscore_untyped.stderr | 1 + src/tools/clippy/tests/ui/let_unit.stderr | 1 + src/tools/clippy/tests/ui/let_with_type_underscore.stderr | 1 + src/tools/clippy/tests/ui/lines_filter_map_ok.stderr | 1 + src/tools/clippy/tests/ui/linkedlist.stderr | 1 + src/tools/clippy/tests/ui/literals.stderr | 6 ++++++ src/tools/clippy/tests/ui/lossy_float_literal.stderr | 1 + src/tools/clippy/tests/ui/macro_use_imports.stderr | 1 + src/tools/clippy/tests/ui/manual_assert.edition2018.stderr | 1 + src/tools/clippy/tests/ui/manual_assert.edition2021.stderr | 1 + src/tools/clippy/tests/ui/manual_async_fn.stderr | 1 + src/tools/clippy/tests/ui/manual_bits.stderr | 1 + src/tools/clippy/tests/ui/manual_clamp.stderr | 1 + src/tools/clippy/tests/ui/manual_filter.stderr | 1 + src/tools/clippy/tests/ui/manual_filter_map.stderr | 2 ++ src/tools/clippy/tests/ui/manual_find.stderr | 1 + src/tools/clippy/tests/ui/manual_find_fixable.stderr | 1 + src/tools/clippy/tests/ui/manual_find_map.stderr | 1 + src/tools/clippy/tests/ui/manual_flatten.stderr | 1 + src/tools/clippy/tests/ui/manual_float_methods.stderr | 2 ++ src/tools/clippy/tests/ui/manual_instant_elapsed.stderr | 1 + src/tools/clippy/tests/ui/manual_is_ascii_check.stderr | 1 + src/tools/clippy/tests/ui/manual_let_else.stderr | 1 + src/tools/clippy/tests/ui/manual_let_else_match.stderr | 1 + .../clippy/tests/ui/manual_let_else_question_mark.stderr | 2 ++ src/tools/clippy/tests/ui/manual_main_separator_str.stderr | 1 + src/tools/clippy/tests/ui/manual_map_option.stderr | 1 + src/tools/clippy/tests/ui/manual_map_option_2.stderr | 1 + .../tests/ui/manual_memcpy/with_loop_counters.stderr | 1 + .../tests/ui/manual_memcpy/without_loop_counters.stderr | 1 + src/tools/clippy/tests/ui/manual_next_back.stderr | 1 + .../clippy/tests/ui/manual_non_exhaustive_enum.stderr | 1 + .../clippy/tests/ui/manual_non_exhaustive_struct.stderr | 1 + src/tools/clippy/tests/ui/manual_ok_or.stderr | 1 + src/tools/clippy/tests/ui/manual_range_patterns.stderr | 1 + src/tools/clippy/tests/ui/manual_rem_euclid.stderr | 1 + src/tools/clippy/tests/ui/manual_retain.stderr | 1 + .../clippy/tests/ui/manual_saturating_arithmetic.stderr | 1 + .../clippy/tests/ui/manual_slice_size_calculation.stderr | 1 + src/tools/clippy/tests/ui/manual_split_once.stderr | 1 + src/tools/clippy/tests/ui/manual_str_repeat.stderr | 1 + src/tools/clippy/tests/ui/manual_string_new.stderr | 1 + src/tools/clippy/tests/ui/manual_strip.stderr | 1 + src/tools/clippy/tests/ui/manual_try_fold.stderr | 1 + src/tools/clippy/tests/ui/manual_unwrap_or.stderr | 1 + src/tools/clippy/tests/ui/manual_while_let_some.stderr | 1 + src/tools/clippy/tests/ui/many_single_char_names.stderr | 1 + src/tools/clippy/tests/ui/map_clone.stderr | 1 + src/tools/clippy/tests/ui/map_collect_result_unit.stderr | 1 + src/tools/clippy/tests/ui/map_err.stderr | 1 + src/tools/clippy/tests/ui/map_flatten.stderr | 1 + src/tools/clippy/tests/ui/map_flatten_fixable.stderr | 1 + src/tools/clippy/tests/ui/map_identity.stderr | 1 + src/tools/clippy/tests/ui/map_unwrap_or.stderr | 1 + src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr | 1 + src/tools/clippy/tests/ui/match_as_ref.stderr | 1 + src/tools/clippy/tests/ui/match_bool.stderr | 1 + .../clippy/tests/ui/match_expr_like_matches_macro.stderr | 2 ++ src/tools/clippy/tests/ui/match_on_vec_items.stderr | 1 + src/tools/clippy/tests/ui/match_overlapping_arm.stderr | 1 + src/tools/clippy/tests/ui/match_ref_pats.stderr | 2 ++ src/tools/clippy/tests/ui/match_result_ok.stderr | 1 + src/tools/clippy/tests/ui/match_same_arms.stderr | 1 + src/tools/clippy/tests/ui/match_same_arms2.stderr | 2 ++ .../clippy/tests/ui/match_same_arms_non_exhaustive.stderr | 1 + src/tools/clippy/tests/ui/match_single_binding.stderr | 1 + src/tools/clippy/tests/ui/match_single_binding2.stderr | 1 + src/tools/clippy/tests/ui/match_str_case_mismatch.stderr | 1 + src/tools/clippy/tests/ui/match_wild_err_arm.stderr | 1 + .../tests/ui/match_wildcard_for_single_variants.stderr | 1 + src/tools/clippy/tests/ui/mem_forget.stderr | 1 + src/tools/clippy/tests/ui/mem_replace.stderr | 2 ++ src/tools/clippy/tests/ui/mem_replace_macro.stderr | 1 + src/tools/clippy/tests/ui/methods.stderr | 2 ++ src/tools/clippy/tests/ui/methods_fixable.stderr | 1 + src/tools/clippy/tests/ui/methods_unfixable.stderr | 1 + src/tools/clippy/tests/ui/min_ident_chars.stderr | 1 + src/tools/clippy/tests/ui/min_max.stderr | 1 + .../clippy/tests/ui/mismatched_target_os_non_unix.stderr | 1 + src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr | 1 + .../clippy/tests/ui/mismatching_type_param_order.stderr | 1 + src/tools/clippy/tests/ui/misnamed_getters.stderr | 1 + src/tools/clippy/tests/ui/missing_assert_message.stderr | 1 + .../tests/ui/missing_const_for_fn/could_be_const.stderr | 1 + src/tools/clippy/tests/ui/missing_doc.stderr | 1 + src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr | 1 + src/tools/clippy/tests/ui/missing_doc_impl.stderr | 1 + src/tools/clippy/tests/ui/missing_fields_in_debug.stderr | 1 + src/tools/clippy/tests/ui/missing_inline.stderr | 1 + src/tools/clippy/tests/ui/missing_panics_doc.stderr | 1 + src/tools/clippy/tests/ui/missing_spin_loop.stderr | 1 + src/tools/clippy/tests/ui/missing_spin_loop_no_std.stderr | 1 + src/tools/clippy/tests/ui/missing_trait_methods.stderr | 1 + .../clippy/tests/ui/mixed_read_write_in_expression.stderr | 1 + src/tools/clippy/tests/ui/module_inception.stderr | 1 + src/tools/clippy/tests/ui/module_name_repetitions.stderr | 1 + src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr | 1 + .../clippy/tests/ui/modulo_arithmetic_integral.stderr | 1 + .../tests/ui/modulo_arithmetic_integral_const.stderr | 1 + src/tools/clippy/tests/ui/modulo_one.stderr | 1 + src/tools/clippy/tests/ui/multi_assignments.stderr | 1 + .../clippy/tests/ui/multiple_unsafe_ops_per_block.stderr | 1 + src/tools/clippy/tests/ui/must_use_candidates.stderr | 1 + src/tools/clippy/tests/ui/must_use_unit.stderr | 1 + src/tools/clippy/tests/ui/mut_from_ref.stderr | 1 + src/tools/clippy/tests/ui/mut_key.stderr | 2 ++ src/tools/clippy/tests/ui/mut_mut.stderr | 1 + src/tools/clippy/tests/ui/mut_mutex_lock.stderr | 1 + src/tools/clippy/tests/ui/mut_range_bound.stderr | 1 + src/tools/clippy/tests/ui/mut_reference.stderr | 2 ++ src/tools/clippy/tests/ui/mutex_atomic.stderr | 2 ++ .../clippy/tests/ui/needless_arbitrary_self_type.stderr | 1 + .../tests/ui/needless_arbitrary_self_type_unfixable.stderr | 1 + src/tools/clippy/tests/ui/needless_bitwise_bool.stderr | 1 + src/tools/clippy/tests/ui/needless_bool/fixable.stderr | 2 ++ src/tools/clippy/tests/ui/needless_bool/simple.stderr | 1 + src/tools/clippy/tests/ui/needless_bool_assign.stderr | 1 + src/tools/clippy/tests/ui/needless_borrow.stderr | 1 + src/tools/clippy/tests/ui/needless_borrow_pat.stderr | 1 + src/tools/clippy/tests/ui/needless_borrowed_ref.stderr | 1 + src/tools/clippy/tests/ui/needless_collect.stderr | 1 + src/tools/clippy/tests/ui/needless_collect_indirect.stderr | 1 + src/tools/clippy/tests/ui/needless_continue.stderr | 1 + src/tools/clippy/tests/ui/needless_doc_main.stderr | 1 + src/tools/clippy/tests/ui/needless_else.stderr | 1 + src/tools/clippy/tests/ui/needless_for_each_fixable.stderr | 1 + .../clippy/tests/ui/needless_for_each_unfixable.stderr | 1 + src/tools/clippy/tests/ui/needless_if.stderr | 1 + src/tools/clippy/tests/ui/needless_late_init.stderr | 1 + src/tools/clippy/tests/ui/needless_lifetimes.stderr | 1 + src/tools/clippy/tests/ui/needless_match.stderr | 1 + src/tools/clippy/tests/ui/needless_option_as_deref.stderr | 1 + src/tools/clippy/tests/ui/needless_option_take.stderr | 1 + .../tests/ui/needless_parens_on_range_literals.stderr | 1 + src/tools/clippy/tests/ui/needless_pass_by_ref_mut.stderr | 1 + src/tools/clippy/tests/ui/needless_pass_by_value.stderr | 1 + src/tools/clippy/tests/ui/needless_pub_self.stderr | 1 + src/tools/clippy/tests/ui/needless_question_mark.stderr | 1 + src/tools/clippy/tests/ui/needless_range_loop.stderr | 1 + src/tools/clippy/tests/ui/needless_range_loop2.stderr | 1 + src/tools/clippy/tests/ui/needless_raw_string.stderr | 1 + .../clippy/tests/ui/needless_raw_string_hashes.stderr | 1 + src/tools/clippy/tests/ui/needless_return.stderr | 1 + .../tests/ui/needless_return_with_question_mark.stderr | 1 + src/tools/clippy/tests/ui/needless_splitn.stderr | 1 + src/tools/clippy/tests/ui/needless_update.stderr | 1 + src/tools/clippy/tests/ui/neg_cmp_op_on_partial_ord.stderr | 1 + src/tools/clippy/tests/ui/neg_multiply.stderr | 1 + src/tools/clippy/tests/ui/never_loop.stderr | 1 + src/tools/clippy/tests/ui/new_ret_no_self.stderr | 1 + src/tools/clippy/tests/ui/new_without_default.stderr | 1 + src/tools/clippy/tests/ui/no_effect.stderr | 2 ++ src/tools/clippy/tests/ui/no_effect_replace.stderr | 1 + src/tools/clippy/tests/ui/no_effect_return.stderr | 1 + src/tools/clippy/tests/ui/no_mangle_with_rust_abi.stderr | 1 + src/tools/clippy/tests/ui/non_expressive_names.stderr | 1 + src/tools/clippy/tests/ui/non_minimal_cfg.stderr | 1 + src/tools/clippy/tests/ui/non_minimal_cfg2.stderr | 1 + .../clippy/tests/ui/non_octal_unix_permissions.stderr | 1 + .../clippy/tests/ui/non_send_fields_in_send_ty.stderr | 1 + src/tools/clippy/tests/ui/nonminimal_bool.stderr | 1 + src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr | 1 + src/tools/clippy/tests/ui/numbered_fields.stderr | 1 + src/tools/clippy/tests/ui/obfuscated_if_else.stderr | 1 + src/tools/clippy/tests/ui/octal_escapes.stderr | 1 + src/tools/clippy/tests/ui/ok_expect.stderr | 1 + src/tools/clippy/tests/ui/only_used_in_recursion.stderr | 1 + src/tools/clippy/tests/ui/only_used_in_recursion2.stderr | 1 + src/tools/clippy/tests/ui/op_ref.stderr | 1 + src/tools/clippy/tests/ui/open_options.stderr | 1 + src/tools/clippy/tests/ui/option_as_ref_deref.stderr | 1 + src/tools/clippy/tests/ui/option_env_unwrap.stderr | 1 + src/tools/clippy/tests/ui/option_filter_map.stderr | 1 + src/tools/clippy/tests/ui/option_if_let_else.stderr | 1 + src/tools/clippy/tests/ui/option_map_or_none.stderr | 2 ++ .../clippy/tests/ui/option_map_unit_fn_fixable.stderr | 1 + src/tools/clippy/tests/ui/or_fun_call.stderr | 2 ++ src/tools/clippy/tests/ui/or_then_unwrap.stderr | 1 + .../tests/ui/out_of_bounds_indexing/issue-3102.stderr | 1 + .../clippy/tests/ui/out_of_bounds_indexing/simple.stderr | 1 + .../clippy/tests/ui/overflow_check_conditional.stderr | 1 + src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr | 1 + src/tools/clippy/tests/ui/panic_in_result_fn.stderr | 1 + .../clippy/tests/ui/panic_in_result_fn_assertions.stderr | 1 + src/tools/clippy/tests/ui/panicking_macros.stderr | 4 ++++ src/tools/clippy/tests/ui/partial_pub_fields.stderr | 1 + src/tools/clippy/tests/ui/partialeq_ne_impl.stderr | 1 + src/tools/clippy/tests/ui/partialeq_to_none.stderr | 1 + src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr | 1 + .../tests/ui/pattern_type_mismatch/mutability.stderr | 1 + .../ui/pattern_type_mismatch/pattern_alternatives.stderr | 1 + .../tests/ui/pattern_type_mismatch/pattern_structs.stderr | 1 + .../tests/ui/pattern_type_mismatch/pattern_tuples.stderr | 1 + .../clippy/tests/ui/pattern_type_mismatch/syntax.stderr | 1 + src/tools/clippy/tests/ui/patterns.stderr | 1 + .../clippy/tests/ui/permissions_set_readonly_false.stderr | 1 + src/tools/clippy/tests/ui/precedence.stderr | 1 + src/tools/clippy/tests/ui/print.stderr | 2 ++ src/tools/clippy/tests/ui/print_in_format_impl.stderr | 1 + src/tools/clippy/tests/ui/print_literal.stderr | 1 + src/tools/clippy/tests/ui/print_stderr.stderr | 1 + src/tools/clippy/tests/ui/print_with_newline.stderr | 1 + src/tools/clippy/tests/ui/println_empty_string.stderr | 1 + src/tools/clippy/tests/ui/ptr_arg.stderr | 1 + src/tools/clippy/tests/ui/ptr_as_ptr.stderr | 1 + src/tools/clippy/tests/ui/ptr_cast_constness.stderr | 1 + src/tools/clippy/tests/ui/ptr_eq.stderr | 1 + src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr | 1 + src/tools/clippy/tests/ui/pub_use.stderr | 1 + src/tools/clippy/tests/ui/pub_with_shorthand.stderr | 1 + src/tools/clippy/tests/ui/pub_without_shorthand.stderr | 1 + src/tools/clippy/tests/ui/question_mark.stderr | 1 + src/tools/clippy/tests/ui/question_mark_used.stderr | 1 + src/tools/clippy/tests/ui/range.stderr | 1 + src/tools/clippy/tests/ui/range_contains.stderr | 1 + src/tools/clippy/tests/ui/range_plus_minus_one.stderr | 2 ++ src/tools/clippy/tests/ui/rc_buffer.stderr | 1 + src/tools/clippy/tests/ui/rc_buffer_arc.stderr | 1 + src/tools/clippy/tests/ui/rc_clone_in_vec_init/arc.stderr | 1 + src/tools/clippy/tests/ui/rc_clone_in_vec_init/rc.stderr | 1 + src/tools/clippy/tests/ui/rc_clone_in_vec_init/weak.stderr | 1 + src/tools/clippy/tests/ui/rc_mutex.stderr | 1 + src/tools/clippy/tests/ui/read_line_without_trim.stderr | 1 + src/tools/clippy/tests/ui/read_zero_byte_vec.stderr | 1 + src/tools/clippy/tests/ui/readonly_write_lock.stderr | 1 + src/tools/clippy/tests/ui/recursive_format_impl.stderr | 1 + src/tools/clippy/tests/ui/redundant_allocation.stderr | 1 + .../clippy/tests/ui/redundant_allocation_fixable.stderr | 1 + src/tools/clippy/tests/ui/redundant_async_block.stderr | 1 + src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr | 1 + src/tools/clippy/tests/ui/redundant_clone.stderr | 1 + .../clippy/tests/ui/redundant_closure_call_early.stderr | 1 + .../clippy/tests/ui/redundant_closure_call_fixable.stderr | 1 + .../clippy/tests/ui/redundant_closure_call_late.stderr | 1 + src/tools/clippy/tests/ui/redundant_else.stderr | 1 + src/tools/clippy/tests/ui/redundant_field_names.stderr | 1 + src/tools/clippy/tests/ui/redundant_guards.stderr | 1 + src/tools/clippy/tests/ui/redundant_locals.stderr | 1 + .../tests/ui/redundant_pattern_matching_drop_order.stderr | 1 + .../tests/ui/redundant_pattern_matching_ipaddr.stderr | 1 + .../tests/ui/redundant_pattern_matching_option.stderr | 1 + .../clippy/tests/ui/redundant_pattern_matching_poll.stderr | 1 + .../tests/ui/redundant_pattern_matching_result.stderr | 1 + src/tools/clippy/tests/ui/redundant_pub_crate.stderr | 1 + src/tools/clippy/tests/ui/redundant_slicing.stderr | 1 + .../clippy/tests/ui/redundant_static_lifetimes.stderr | 1 + .../tests/ui/redundant_static_lifetimes_multiple.stderr | 1 + .../clippy/tests/ui/redundant_type_annotations.stderr | 1 + src/tools/clippy/tests/ui/ref_binding_to_reference.stderr | 1 + src/tools/clippy/tests/ui/ref_option_ref.stderr | 1 + src/tools/clippy/tests/ui/ref_patterns.stderr | 1 + src/tools/clippy/tests/ui/regex.stderr | 2 ++ src/tools/clippy/tests/ui/rename.stderr | 1 + src/tools/clippy/tests/ui/repeat_once.stderr | 1 + src/tools/clippy/tests/ui/repl_uninit.stderr | 1 + .../clippy/tests/ui/reserve_after_initialization.stderr | 1 + .../clippy/tests/ui/rest_pat_in_fully_bound_structs.stderr | 1 + src/tools/clippy/tests/ui/result_large_err.stderr | 1 + src/tools/clippy/tests/ui/result_map_or_into_option.stderr | 1 + .../clippy/tests/ui/result_map_unit_fn_fixable.stderr | 1 + .../clippy/tests/ui/result_map_unit_fn_unfixable.stderr | 1 + src/tools/clippy/tests/ui/result_unit_error.stderr | 1 + src/tools/clippy/tests/ui/return_self_not_must_use.stderr | 1 + .../clippy/tests/ui/reversed_empty_ranges_fixable.stderr | 1 + .../tests/ui/reversed_empty_ranges_loops_fixable.stderr | 1 + .../tests/ui/reversed_empty_ranges_loops_unfixable.stderr | 1 + .../clippy/tests/ui/reversed_empty_ranges_unfixable.stderr | 1 + src/tools/clippy/tests/ui/same_item_push.stderr | 1 + src/tools/clippy/tests/ui/same_name_method.stderr | 1 + src/tools/clippy/tests/ui/search_is_some.stderr | 1 + .../clippy/tests/ui/search_is_some_fixable_none.stderr | 1 + .../clippy/tests/ui/search_is_some_fixable_some.stderr | 1 + src/tools/clippy/tests/ui/seek_from_current.stderr | 1 + .../clippy/tests/ui/seek_to_start_instead_of_rewind.stderr | 1 + src/tools/clippy/tests/ui/self_assignment.stderr | 1 + src/tools/clippy/tests/ui/self_named_constructors.stderr | 1 + .../clippy/tests/ui/semicolon_if_nothing_returned.stderr | 1 + src/tools/clippy/tests/ui/semicolon_inside_block.stderr | 1 + src/tools/clippy/tests/ui/semicolon_outside_block.stderr | 1 + src/tools/clippy/tests/ui/serde.stderr | 1 + src/tools/clippy/tests/ui/shadow.stderr | 3 +++ src/tools/clippy/tests/ui/short_circuit_statement.stderr | 1 + .../clippy/tests/ui/should_impl_trait/method_list_1.stderr | 1 + .../clippy/tests/ui/should_impl_trait/method_list_2.stderr | 2 ++ .../clippy/tests/ui/significant_drop_in_scrutinee.stderr | 1 + .../clippy/tests/ui/significant_drop_tightening.stderr | 1 + src/tools/clippy/tests/ui/similar_names.stderr | 1 + src/tools/clippy/tests/ui/single_call_fn.stderr | 1 + src/tools/clippy/tests/ui/single_char_add_str.stderr | 1 + .../clippy/tests/ui/single_char_lifetime_names.stderr | 1 + src/tools/clippy/tests/ui/single_char_pattern.stderr | 1 + .../clippy/tests/ui/single_component_path_imports.stderr | 1 + .../ui/single_component_path_imports_nested_first.stderr | 1 + src/tools/clippy/tests/ui/single_element_loop.stderr | 1 + src/tools/clippy/tests/ui/single_match.stderr | 1 + src/tools/clippy/tests/ui/single_match_else.stderr | 1 + src/tools/clippy/tests/ui/single_range_in_vec_init.stderr | 1 + .../tests/ui/size_of_in_element_count/expressions.stderr | 1 + .../tests/ui/size_of_in_element_count/functions.stderr | 1 + src/tools/clippy/tests/ui/size_of_ref.stderr | 1 + src/tools/clippy/tests/ui/skip_while_next.stderr | 1 + .../clippy/tests/ui/slow_vector_initialization.stderr | 2 ++ src/tools/clippy/tests/ui/stable_sort_primitive.stderr | 1 + src/tools/clippy/tests/ui/starts_ends_with.stderr | 2 ++ src/tools/clippy/tests/ui/std_instead_of_core.stderr | 3 +++ src/tools/clippy/tests/ui/str_to_string.stderr | 1 + src/tools/clippy/tests/ui/string_add.stderr | 2 ++ src/tools/clippy/tests/ui/string_add_assign.stderr | 2 ++ src/tools/clippy/tests/ui/string_extend.stderr | 1 + src/tools/clippy/tests/ui/string_from_utf8_as_bytes.stderr | 1 + src/tools/clippy/tests/ui/string_lit_as_bytes.stderr | 1 + src/tools/clippy/tests/ui/string_lit_chars_any.stderr | 1 + src/tools/clippy/tests/ui/string_slice.stderr | 1 + src/tools/clippy/tests/ui/string_to_string.stderr | 1 + src/tools/clippy/tests/ui/strlen_on_c_strings.stderr | 1 + src/tools/clippy/tests/ui/struct_excessive_bools.stderr | 1 + .../clippy/tests/ui/suspicious_arithmetic_impl.stderr | 2 ++ .../clippy/tests/ui/suspicious_command_arg_space.stderr | 1 + src/tools/clippy/tests/ui/suspicious_doc_comments.stderr | 1 + .../tests/ui/suspicious_doc_comments_unfixable.stderr | 1 + .../clippy/tests/ui/suspicious_else_formatting.stderr | 1 + src/tools/clippy/tests/ui/suspicious_map.stderr | 1 + .../clippy/tests/ui/suspicious_operation_groupings.stderr | 1 + src/tools/clippy/tests/ui/suspicious_splitn.stderr | 1 + src/tools/clippy/tests/ui/suspicious_to_owned.stderr | 2 ++ .../clippy/tests/ui/suspicious_unary_op_formatting.stderr | 1 + .../clippy/tests/ui/suspicious_xor_used_as_pow.stderr | 1 + src/tools/clippy/tests/ui/swap.stderr | 2 ++ src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr | 1 + src/tools/clippy/tests/ui/swap_ptr_to_ref_unfixable.stderr | 1 + src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr | 1 + src/tools/clippy/tests/ui/temporary_assignment.stderr | 1 + src/tools/clippy/tests/ui/tests_outside_test_module.stderr | 1 + src/tools/clippy/tests/ui/to_digit_is_some.stderr | 1 + src/tools/clippy/tests/ui/toplevel_ref_arg.stderr | 1 + .../clippy/tests/ui/toplevel_ref_arg_non_rustfix.stderr | 1 + src/tools/clippy/tests/ui/trailing_empty_array.stderr | 1 + src/tools/clippy/tests/ui/trailing_zeros.stderr | 1 + src/tools/clippy/tests/ui/transmute.stderr | 7 +++++++ src/tools/clippy/tests/ui/transmute_64bit.stderr | 1 + src/tools/clippy/tests/ui/transmute_collection.stderr | 1 + src/tools/clippy/tests/ui/transmute_float_to_int.stderr | 1 + src/tools/clippy/tests/ui/transmute_int_to_non_zero.stderr | 1 + src/tools/clippy/tests/ui/transmute_null_to_fn.stderr | 1 + src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr | 1 + src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr | 1 + src/tools/clippy/tests/ui/transmute_undefined_repr.stderr | 1 + .../tests/ui/transmutes_expressible_as_ptr_casts.stderr | 3 +++ src/tools/clippy/tests/ui/transmuting_null.stderr | 1 + src/tools/clippy/tests/ui/trim_split_whitespace.stderr | 1 + src/tools/clippy/tests/ui/tuple_array_conversions.stderr | 1 + src/tools/clippy/tests/ui/type_complexity.stderr | 1 + src/tools/clippy/tests/ui/type_id_on_box.stderr | 1 + src/tools/clippy/tests/ui/types.stderr | 1 + .../clippy/tests/ui/unchecked_duration_subtraction.stderr | 1 + .../clippy/tests/ui/undocumented_unsafe_blocks.stderr | 2 ++ src/tools/clippy/tests/ui/unicode.stderr | 2 ++ src/tools/clippy/tests/ui/uninit_vec.stderr | 1 + src/tools/clippy/tests/ui/uninlined_format_args.stderr | 1 + .../ui/uninlined_format_args_panic.edition2018.stderr | 1 + .../ui/uninlined_format_args_panic.edition2021.stderr | 1 + src/tools/clippy/tests/ui/unit_arg.stderr | 1 + src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr | 1 + src/tools/clippy/tests/ui/unit_cmp.stderr | 1 + src/tools/clippy/tests/ui/unit_hash.stderr | 1 + src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr | 1 + src/tools/clippy/tests/ui/unknown_clippy_lints.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_box_returns.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_cast.stderr | 1 + .../clippy/tests/ui/unnecessary_cast_unfixable.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_clone.stderr | 2 ++ src/tools/clippy/tests/ui/unnecessary_filter_map.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_find_map.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_fold.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_join.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr | 1 + .../clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr | 1 + .../clippy/tests/ui/unnecessary_literal_unwrap.stderr | 1 + .../tests/ui/unnecessary_literal_unwrap_unfixable.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_operation.stderr | 1 + .../clippy/tests/ui/unnecessary_owned_empty_strings.stderr | 1 + .../clippy/tests/ui/unnecessary_safety_comment.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_self_imports.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_sort_by.stderr | 1 + .../tests/ui/unnecessary_struct_initialization.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_to_owned.stderr | 2 ++ src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr | 1 + src/tools/clippy/tests/ui/unnecessary_wraps.stderr | 1 + src/tools/clippy/tests/ui/unneeded_field_pattern.stderr | 1 + src/tools/clippy/tests/ui/unnested_or_patterns.stderr | 1 + src/tools/clippy/tests/ui/unnested_or_patterns2.stderr | 1 + src/tools/clippy/tests/ui/unreadable_literal.stderr | 1 + src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr | 1 + src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr | 1 + .../clippy/tests/ui/unseparated_prefix_literals.stderr | 1 + src/tools/clippy/tests/ui/unused_async.stderr | 1 + .../clippy/tests/ui/unused_format_specs_unfixable.stderr | 1 + src/tools/clippy/tests/ui/unused_io_amount.stderr | 1 + src/tools/clippy/tests/ui/unused_peekable.stderr | 1 + src/tools/clippy/tests/ui/unused_rounding.stderr | 1 + src/tools/clippy/tests/ui/unused_self.stderr | 1 + src/tools/clippy/tests/ui/unwrap.stderr | 1 + src/tools/clippy/tests/ui/unwrap_expect_used.stderr | 2 ++ src/tools/clippy/tests/ui/unwrap_in_result.stderr | 1 + src/tools/clippy/tests/ui/unwrap_or.stderr | 1 + src/tools/clippy/tests/ui/unwrap_or_else_default.stderr | 1 + src/tools/clippy/tests/ui/upper_case_acronyms.stderr | 1 + src/tools/clippy/tests/ui/use_self.stderr | 1 + src/tools/clippy/tests/ui/use_self_trait.stderr | 1 + src/tools/clippy/tests/ui/used_underscore_binding.stderr | 1 + src/tools/clippy/tests/ui/useless_attribute.stderr | 1 + src/tools/clippy/tests/ui/vec.stderr | 1 + src/tools/clippy/tests/ui/vec_box_sized.stderr | 1 + src/tools/clippy/tests/ui/vec_init_then_push.stderr | 1 + src/tools/clippy/tests/ui/vec_resize_to_zero.stderr | 1 + src/tools/clippy/tests/ui/verbose_file_reads.stderr | 1 + .../clippy/tests/ui/vtable_address_comparisons.stderr | 1 + src/tools/clippy/tests/ui/while_let_loop.stderr | 1 + src/tools/clippy/tests/ui/while_let_on_iterator.stderr | 1 + src/tools/clippy/tests/ui/wild_in_or_pats.stderr | 1 + src/tools/clippy/tests/ui/wildcard_imports.stderr | 1 + .../tests/ui/wildcard_imports_2021.edition2018.stderr | 1 + .../tests/ui/wildcard_imports_2021.edition2021.stderr | 1 + src/tools/clippy/tests/ui/write_literal.stderr | 1 + src/tools/clippy/tests/ui/write_literal_2.stderr | 2 ++ src/tools/clippy/tests/ui/write_with_newline.stderr | 1 + src/tools/clippy/tests/ui/writeln_empty_string.stderr | 1 + src/tools/clippy/tests/ui/wrong_self_convention.stderr | 1 + src/tools/clippy/tests/ui/wrong_self_convention2.stderr | 1 + .../clippy/tests/ui/wrong_self_conventions_mut.stderr | 1 + src/tools/clippy/tests/ui/zero_div_zero.stderr | 1 + src/tools/clippy/tests/ui/zero_ptr.stderr | 1 + .../clippy/tests/ui/zero_sized_btreemap_values.stderr | 1 + src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr | 1 + 751 files changed, 838 insertions(+) diff --git a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr index a8900da4e6eb4..99f08d9472789 100644 --- a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr +++ b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.allow_crates.stderr @@ -5,6 +5,7 @@ LL | std::f32::MAX; | ^^^^^^^^^^^^^ | = note: `-D clippy::absolute-paths` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]` error: consider bringing this path into scope with the `use` keyword --> $DIR/absolute_paths.rs:41:5 diff --git a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr index 41b70644be8c3..017ba4cc24f11 100644 --- a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr +++ b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr @@ -5,6 +5,7 @@ LL | std::f32::MAX; | ^^^^^^^^^^^^^ | = note: `-D clippy::absolute-paths` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]` error: consider bringing this path into scope with the `use` keyword --> $DIR/absolute_paths.rs:41:5 diff --git a/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr index c5912b7af9e5c..b754f67edfb61 100644 --- a/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr +++ b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr @@ -5,6 +5,7 @@ LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::uninlined-format-args` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]` help: change this to | LL - println!("val='{}'", local_i32); @@ -30,6 +31,7 @@ LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); | ^^^ | = note: `-D clippy::print-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_literal)]` help: try | LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64); diff --git a/src/tools/clippy/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr b/src/tools/clippy/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr index 4f98ca1923114..5e8d26e074138 100644 --- a/src/tools/clippy/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr +++ b/src/tools/clippy/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr @@ -5,6 +5,7 @@ LL | let _ = Baz + Baz; | ^^^^^^^^^ | = note: `-D clippy::arithmetic-side-effects` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:80:13 diff --git a/src/tools/clippy/tests/ui-toml/array_size_threshold/array_size_threshold.stderr b/src/tools/clippy/tests/ui-toml/array_size_threshold/array_size_threshold.stderr index ac017b20916de..cf70b3c5cfcd2 100644 --- a/src/tools/clippy/tests/ui-toml/array_size_threshold/array_size_threshold.stderr +++ b/src/tools/clippy/tests/ui-toml/array_size_threshold/array_size_threshold.stderr @@ -7,6 +7,7 @@ LL | const ABOVE: [u8; 11] = [0; 11]; | help: make this a static item: `static` | = note: `-D clippy::large-const-arrays` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]` error: allocating a local array larger than 10 bytes --> $DIR/array_size_threshold.rs:4:25 @@ -16,6 +17,7 @@ LL | const ABOVE: [u8; 11] = [0; 11]; | = help: consider allocating on the heap with `vec![0; 11].into_boxed_slice()` = note: `-D clippy::large-stack-arrays` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]` error: allocating a local array larger than 10 bytes --> $DIR/array_size_threshold.rs:8:17 diff --git a/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr b/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr index 825aa1487e7a3..6f8b04fd12b94 100644 --- a/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr +++ b/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr @@ -6,6 +6,7 @@ LL | let _x = String::from("hello"); | = note: strings are bad (from clippy.toml) = note: `-D clippy::await-holding-invalid-type` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::await_holding_invalid_type)]` error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml` --> $DIR/await_holding_invalid_type.rs:10:9 diff --git a/src/tools/clippy/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr b/src/tools/clippy/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr index 89d84eb24556d..a21952c0e7ada 100644 --- a/src/tools/clippy/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr +++ b/src/tools/clippy/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr @@ -18,6 +18,7 @@ LL | fn cognitive_complexity() { | = help: you could split it up into multiple smaller functions = note: `-D clippy::cognitive-complexity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cognitive_complexity)]` error: aborting due to previous error; 2 warnings emitted diff --git a/src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr b/src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr index 859383a71194f..3a66f701e4df6 100644 --- a/src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr +++ b/src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr @@ -5,6 +5,7 @@ LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::dbg-macro` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]` help: remove the invocation before committing it to a version control system | LL | if let Some(n) = n.checked_sub(4) { n } else { n } diff --git a/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr index aed9feb6f796c..0eebd587a5f10 100644 --- a/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr +++ b/src/tools/clippy/tests/ui-toml/disallowed_macros/disallowed_macros.stderr @@ -5,6 +5,7 @@ LL | println!("one"); | ^^^^^^^^^^^^^^^ | = note: `-D clippy::disallowed-macros` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]` error: use of a disallowed macro `std::println` --> $DIR/disallowed_macros.rs:11:5 diff --git a/src/tools/clippy/tests/ui-toml/disallowed_names_append/disallowed_names.stderr b/src/tools/clippy/tests/ui-toml/disallowed_names_append/disallowed_names.stderr index 23c3e96a8d082..51cbe1abf599c 100644 --- a/src/tools/clippy/tests/ui-toml/disallowed_names_append/disallowed_names.stderr +++ b/src/tools/clippy/tests/ui-toml/disallowed_names_append/disallowed_names.stderr @@ -5,6 +5,7 @@ LL | let foo = "bar"; | ^^^ | = note: `-D clippy::disallowed-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `ducks` --> $DIR/disallowed_names.rs:7:9 diff --git a/src/tools/clippy/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr b/src/tools/clippy/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr index d961fa34074b3..d9f25a3eee50a 100644 --- a/src/tools/clippy/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr +++ b/src/tools/clippy/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr @@ -5,6 +5,7 @@ LL | let ducks = ["quack", "quack"]; | ^^^^^ | = note: `-D clippy::disallowed-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr b/src/tools/clippy/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr index 0f767c9b8559f..92b0350581d33 100644 --- a/src/tools/clippy/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr +++ b/src/tools/clippy/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr @@ -5,6 +5,7 @@ LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and sh | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::doc-markdown` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` help: try | LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted. diff --git a/src/tools/clippy/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr b/src/tools/clippy/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr index e0613eb863b39..6567b5f1275d0 100644 --- a/src/tools/clippy/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr +++ b/src/tools/clippy/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr @@ -5,6 +5,7 @@ LL | /// OAuth and LaTeX are inside Clippy's default list. | ^^^^^ | = note: `-D clippy::doc-markdown` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` help: try | LL | /// `OAuth` and LaTeX are inside Clippy's default list. diff --git a/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr b/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr index 1a7311b33e869..74be5b2e2b92b 100644 --- a/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr +++ b/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr @@ -6,6 +6,7 @@ LL | let w = { 3 }; | = help: try refactoring your code to minimize nesting = note: `-D clippy::excessive-nesting` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::excessive_nesting)]` error: this block is too nested --> $DIR/excessive_nesting.rs:67:17 diff --git a/src/tools/clippy/tests/ui-toml/expect_used/expect_used.stderr b/src/tools/clippy/tests/ui-toml/expect_used/expect_used.stderr index 815d009350f3c..13b6d7ff9cd49 100644 --- a/src/tools/clippy/tests/ui-toml/expect_used/expect_used.stderr +++ b/src/tools/clippy/tests/ui-toml/expect_used/expect_used.stderr @@ -6,6 +6,7 @@ LL | let _ = opt.expect(""); | = note: if this value is `None`, it will panic = note: `-D clippy::expect-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value --> $DIR/expect_used.rs:12:13 diff --git a/src/tools/clippy/tests/ui-toml/fn_params_excessive_bools/test.stderr b/src/tools/clippy/tests/ui-toml/fn_params_excessive_bools/test.stderr index 87bdb61c6a5e7..717a4bbfbfe17 100644 --- a/src/tools/clippy/tests/ui-toml/fn_params_excessive_bools/test.stderr +++ b/src/tools/clippy/tests/ui-toml/fn_params_excessive_bools/test.stderr @@ -6,6 +6,7 @@ LL | fn g(_: bool, _: bool) {} | = help: consider refactoring bools into two-variant enums = note: `-D clippy::fn-params-excessive-bools` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fn_params_excessive_bools)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui-toml/functions_maxlines/test.stderr b/src/tools/clippy/tests/ui-toml/functions_maxlines/test.stderr index dc255bdcabafe..a2ca623e96620 100644 --- a/src/tools/clippy/tests/ui-toml/functions_maxlines/test.stderr +++ b/src/tools/clippy/tests/ui-toml/functions_maxlines/test.stderr @@ -8,6 +8,7 @@ LL | | } | |_^ | = note: `-D clippy::too-many-lines` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::too_many_lines)]` error: this function has too many lines (4/1) --> $DIR/test.rs:25:1 diff --git a/src/tools/clippy/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr b/src/tools/clippy/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr index 2841f62bc94ab..305e00af27e54 100644 --- a/src/tools/clippy/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr +++ b/src/tools/clippy/tests/ui-toml/ifs_same_cond/ifs_same_cond.stderr @@ -10,6 +10,7 @@ note: same as this LL | if x.get() { | ^^^^^^^ = note: `-D clippy::ifs-same-cond` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ifs_same_cond)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui-toml/large_futures/large_futures.stderr b/src/tools/clippy/tests/ui-toml/large_futures/large_futures.stderr index b92734de2f08c..7a02fcdbdd2f5 100644 --- a/src/tools/clippy/tests/ui-toml/large_futures/large_futures.stderr +++ b/src/tools/clippy/tests/ui-toml/large_futures/large_futures.stderr @@ -5,6 +5,7 @@ LL | should_warn().await; | ^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(should_warn())` | = note: `-D clippy::large-futures` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_futures)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui-toml/large_include_file/large_include_file.stderr b/src/tools/clippy/tests/ui-toml/large_include_file/large_include_file.stderr index 7b5fb9e876594..7508cd6c46e23 100644 --- a/src/tools/clippy/tests/ui-toml/large_include_file/large_include_file.stderr +++ b/src/tools/clippy/tests/ui-toml/large_include_file/large_include_file.stderr @@ -6,6 +6,7 @@ LL | const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); | = note: the configuration allows a maximum size of 600 bytes = note: `-D clippy::large-include-file` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_include_file)]` = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) error: attempted to include a large file diff --git a/src/tools/clippy/tests/ui-toml/lint_decimal_readability/test.stderr b/src/tools/clippy/tests/ui-toml/lint_decimal_readability/test.stderr index ac9d89d0cbeeb..ef97e5d3f3128 100644 --- a/src/tools/clippy/tests/ui-toml/lint_decimal_readability/test.stderr +++ b/src/tools/clippy/tests/ui-toml/lint_decimal_readability/test.stderr @@ -5,6 +5,7 @@ LL | let _fail1 = 100_200_300.123456789; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: long literal lacking separators --> $DIR/test.rs:22:18 @@ -13,6 +14,7 @@ LL | let _fail2 = 100200300.300200100; | ^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.300_200_100` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]` error: aborting due to 2 previous errors diff --git a/src/tools/clippy/tests/ui-toml/min_ident_chars/min_ident_chars.stderr b/src/tools/clippy/tests/ui-toml/min_ident_chars/min_ident_chars.stderr index d9a27628ddb22..7f00fac492430 100644 --- a/src/tools/clippy/tests/ui-toml/min_ident_chars/min_ident_chars.stderr +++ b/src/tools/clippy/tests/ui-toml/min_ident_chars/min_ident_chars.stderr @@ -5,6 +5,7 @@ LL | use extern_types::Aaa; | ^^^ | = note: `-D clippy::min-ident-chars` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` error: this ident is too short (3 <= 3) --> $DIR/min_ident_chars.rs:10:5 diff --git a/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.stderr b/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.stderr index 5dae5af7eb5a9..5b1f8dbd3eab7 100644 --- a/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.stderr +++ b/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.stderr @@ -5,6 +5,7 @@ LL | let _: Option = Some(&16).map(|b| *b); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()` | = note: `-D clippy::map-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_clone)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr b/src/tools/clippy/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr index 45de8fdffef76..0aea330d40bbc 100644 --- a/src/tools/clippy/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr +++ b/src/tools/clippy/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr @@ -5,6 +5,7 @@ LL | use std::process::{exit as wrong_exit, Child as Kid}; | ^^^^^^^^^^^^^^^^^^ help: try: `exit as goodbye` | = note: `-D clippy::missing-enforced-import-renames` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_enforced_import_renames)]` error: this import should be renamed --> $DIR/conf_missing_enforced_import_rename.rs:6:1 diff --git a/src/tools/clippy/tests/ui-toml/module_inception/module_inception.stderr b/src/tools/clippy/tests/ui-toml/module_inception/module_inception.stderr index a5a09c322e13d..0eb25453b2564 100644 --- a/src/tools/clippy/tests/ui-toml/module_inception/module_inception.stderr +++ b/src/tools/clippy/tests/ui-toml/module_inception/module_inception.stderr @@ -7,6 +7,7 @@ LL | | } | |_________^ | = note: `-D clippy::module-inception` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::module_inception)]` error: module has the same name as its containing module --> $DIR/module_inception.rs:11:5 diff --git a/src/tools/clippy/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr b/src/tools/clippy/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr index cfff1fffe80a9..483941d3c3125 100644 --- a/src/tools/clippy/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr +++ b/src/tools/clippy/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr @@ -5,6 +5,7 @@ LL | let _ = vec! {1, 2, 3}; | ^^^^^^^^^^^^^^ help: consider writing: `vec![1, 2, 3]` | = note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::nonstandard_macro_braces)]` error: use of irregular braces for `format!` macro --> $DIR/conf_nonstandard_macro_braces.rs:44:13 diff --git a/src/tools/clippy/tests/ui-toml/print_macro/print_macro.stderr b/src/tools/clippy/tests/ui-toml/print_macro/print_macro.stderr index d4b1ae84fd7dc..fe2d5afc6caaa 100644 --- a/src/tools/clippy/tests/ui-toml/print_macro/print_macro.stderr +++ b/src/tools/clippy/tests/ui-toml/print_macro/print_macro.stderr @@ -5,6 +5,7 @@ LL | print!("{n}"); | ^^^^^^^^^^^^^ | = note: `-D clippy::print-stdout` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `eprint!` --> $DIR/print_macro.rs:7:5 @@ -13,6 +14,7 @@ LL | eprint!("{n}"); | ^^^^^^^^^^^^^^ | = note: `-D clippy::print-stderr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_stderr)]` error: aborting due to 2 previous errors diff --git a/src/tools/clippy/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr b/src/tools/clippy/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr index a474187050c17..1ecdabbc03e6d 100644 --- a/src/tools/clippy/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr +++ b/src/tools/clippy/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr @@ -5,6 +5,7 @@ LL | pub(crate) fn crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a function --> $DIR/pub_crate_missing_doc.rs:15:5 diff --git a/src/tools/clippy/tests/ui-toml/semicolon_block/both.stderr b/src/tools/clippy/tests/ui-toml/semicolon_block/both.stderr index 49b5806746720..ca6a7475cf37c 100644 --- a/src/tools/clippy/tests/ui-toml/semicolon_block/both.stderr +++ b/src/tools/clippy/tests/ui-toml/semicolon_block/both.stderr @@ -5,6 +5,7 @@ LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::semicolon-outside-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_outside_block)]` help: put the `;` here | LL - { unit_fn_block(); } @@ -33,6 +34,7 @@ LL | | }; | |______^ | = note: `-D clippy::semicolon-inside-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_inside_block)]` help: put the `;` here | LL ~ unit_fn_block(); diff --git a/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr b/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr index 13ba9750f4b82..ce03d7d75a264 100644 --- a/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr +++ b/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_inside_block.stderr @@ -8,6 +8,7 @@ LL | | }; | |______^ | = note: `-D clippy::semicolon-inside-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_inside_block)]` help: put the `;` here | LL ~ unit_fn_block(); diff --git a/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr b/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr index 3c619ebe73d1e..fcc409796e2dd 100644 --- a/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr +++ b/src/tools/clippy/tests/ui-toml/semicolon_block/semicolon_outside_block.stderr @@ -5,6 +5,7 @@ LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::semicolon-outside-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_outside_block)]` help: put the `;` here | LL - { unit_fn_block(); } diff --git a/src/tools/clippy/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr b/src/tools/clippy/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr index c72f8c6488dbd..6df11cc1fb7d4 100644 --- a/src/tools/clippy/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr +++ b/src/tools/clippy/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr @@ -11,6 +11,7 @@ LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` = note: `-D clippy::non-send-fields-in-send-ty` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]` error: some fields in `MultiField` are not safe to be sent to another thread --> $DIR/test.rs:19:1 diff --git a/src/tools/clippy/tests/ui-toml/struct_excessive_bools/test.stderr b/src/tools/clippy/tests/ui-toml/struct_excessive_bools/test.stderr index 4e7c70d18385c..9237c9c9d29d9 100644 --- a/src/tools/clippy/tests/ui-toml/struct_excessive_bools/test.stderr +++ b/src/tools/clippy/tests/ui-toml/struct_excessive_bools/test.stderr @@ -8,6 +8,7 @@ LL | | } | = help: consider using a state machine or refactoring bools into two-variant enums = note: `-D clippy::struct-excessive-bools` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::struct_excessive_bools)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr b/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr index 14e13194427c0..d14974faffa67 100644 --- a/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -18,6 +18,7 @@ LL | x[index]; | = help: consider using `.get(n)` or `.get_mut(n)` instead = note: `-D clippy::indexing-slicing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic --> $DIR/test.rs:46:5 diff --git a/src/tools/clippy/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr b/src/tools/clippy/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr index 9082c1c54c36b..621328292236a 100644 --- a/src/tools/clippy/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr +++ b/src/tools/clippy/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr @@ -5,6 +5,7 @@ LL | fn test(toto: ()) {} | ^^^^ | = note: `-D clippy::disallowed-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `toto` --> $DIR/conf_french_disallowed_name.rs:9:9 diff --git a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr index fc137c225d83a..d9b70e3b77ce2 100644 --- a/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr +++ b/src/tools/clippy/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr @@ -5,6 +5,7 @@ LL | let re = Regex::new(r"ab.*c").unwrap(); | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::disallowed-methods` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]` error: use of a disallowed method `regex::Regex::is_match` --> $DIR/conf_disallowed_methods.rs:36:5 diff --git a/src/tools/clippy/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr b/src/tools/clippy/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr index e3ece799c7ce6..4ac96deb44f3a 100644 --- a/src/tools/clippy/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr +++ b/src/tools/clippy/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr @@ -5,6 +5,7 @@ LL | use std::sync::atomic::AtomicU32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::disallowed-types` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_types)]` error: `std::time::Instant` is not allowed according to config --> $DIR/conf_disallowed_types.rs:8:1 diff --git a/src/tools/clippy/tests/ui-toml/toml_trivially_copy/test.stderr b/src/tools/clippy/tests/ui-toml/toml_trivially_copy/test.stderr index db5d6805362de..262d302e72de7 100644 --- a/src/tools/clippy/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/src/tools/clippy/tests/ui-toml/toml_trivially_copy/test.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::trivially_copy_pass_by_ref)]` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/test.rs:15:20 diff --git a/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr b/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr index 9a0fd05938962..183c07fe786ce 100644 --- a/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr +++ b/src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr @@ -6,6 +6,7 @@ LL | /* Safety: */ unsafe {} | = help: consider adding a safety comment on the preceding line = note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:267:5 @@ -251,6 +252,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ = note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:473:5 diff --git a/src/tools/clippy/tests/ui-toml/unwrap_used/unwrap_used.stderr b/src/tools/clippy/tests/ui-toml/unwrap_used/unwrap_used.stderr index 10219beaf9719..cc22ea273d4f2 100644 --- a/src/tools/clippy/tests/ui-toml/unwrap_used/unwrap_used.stderr +++ b/src/tools/clippy/tests/ui-toml/unwrap_used/unwrap_used.stderr @@ -5,6 +5,7 @@ LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` | = note: `-D clippy::get-unwrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::get_unwrap)]` error: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:38:17 @@ -15,6 +16,7 @@ LL | let _ = boxed_slice.get(1).unwrap(); = note: if this value is `None`, it will panic = help: consider using `expect()` to provide a better panic message = note: `-D clippy::unwrap-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:39:17 diff --git a/src/tools/clippy/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr b/src/tools/clippy/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr index 02f29bbefe14a..3fad561b17c97 100644 --- a/src/tools/clippy/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr +++ b/src/tools/clippy/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr @@ -5,6 +5,7 @@ LL | struct HTTPResponse; // not linted by default, but with cfg option | ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse` | = note: `-D clippy::upper-case-acronyms` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::upper_case_acronyms)]` error: name `NS` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:8:5 diff --git a/src/tools/clippy/tests/ui-toml/vec_box_sized/test.stderr b/src/tools/clippy/tests/ui-toml/vec_box_sized/test.stderr index 55de68f8ecf47..c88860ea8f6fd 100644 --- a/src/tools/clippy/tests/ui-toml/vec_box_sized/test.stderr +++ b/src/tools/clippy/tests/ui-toml/vec_box_sized/test.stderr @@ -5,6 +5,7 @@ LL | struct Foo(Vec>); | ^^^^^^^^^^^^ help: try: `Vec` | = note: `-D clippy::vec-box` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::vec_box)]` error: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/test.rs:10:12 diff --git a/src/tools/clippy/tests/ui/absurd-extreme-comparisons.stderr b/src/tools/clippy/tests/ui/absurd-extreme-comparisons.stderr index a7843e2b349e2..64d38e60dc63b 100644 --- a/src/tools/clippy/tests/ui/absurd-extreme-comparisons.stderr +++ b/src/tools/clippy/tests/ui/absurd-extreme-comparisons.stderr @@ -6,6 +6,7 @@ LL | u <= 0; | = help: because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `u == 0` instead = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::absurd_extreme_comparisons)]` 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:16:5 diff --git a/src/tools/clippy/tests/ui/allow_attributes.stderr b/src/tools/clippy/tests/ui/allow_attributes.stderr index 30a947b0648bd..7ac0bd456847a 100644 --- a/src/tools/clippy/tests/ui/allow_attributes.stderr +++ b/src/tools/clippy/tests/ui/allow_attributes.stderr @@ -5,6 +5,7 @@ LL | #[allow(dead_code)] | ^^^^^ help: replace it with: `expect` | = note: `-D clippy::allow-attributes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::allow_attributes)]` error: #[allow] attribute found --> $DIR/allow_attributes.rs:22:30 diff --git a/src/tools/clippy/tests/ui/almost_complete_range.stderr b/src/tools/clippy/tests/ui/almost_complete_range.stderr index 9a6d91b7d8b39..054a02c9c9021 100644 --- a/src/tools/clippy/tests/ui/almost_complete_range.stderr +++ b/src/tools/clippy/tests/ui/almost_complete_range.stderr @@ -7,6 +7,7 @@ LL | let _ = ('a') ..'z'; | help: use an inclusive range: `..=` | = note: `-D clippy::almost-complete-range` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]` error: almost complete ascii range --> $DIR/almost_complete_range.rs:19:17 diff --git a/src/tools/clippy/tests/ui/approx_const.stderr b/src/tools/clippy/tests/ui/approx_const.stderr index 28d2d317155bb..4b5cd2a7a62f1 100644 --- a/src/tools/clippy/tests/ui/approx_const.stderr +++ b/src/tools/clippy/tests/ui/approx_const.stderr @@ -6,6 +6,7 @@ LL | let my_e = 2.7182; | = help: consider using the constant directly = note: `-D clippy::approx-constant` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::approx_constant)]` error: approximate value of `f{32, 64}::consts::E` found --> $DIR/approx_const.rs:6:20 diff --git a/src/tools/clippy/tests/ui/arc_with_non_send_sync.stderr b/src/tools/clippy/tests/ui/arc_with_non_send_sync.stderr index de3f2fb9e16e6..fd239580d284b 100644 --- a/src/tools/clippy/tests/ui/arc_with_non_send_sync.stderr +++ b/src/tools/clippy/tests/ui/arc_with_non_send_sync.stderr @@ -8,6 +8,7 @@ LL | let _ = Arc::new(RefCell::new(42)); = note: required for `Arc>` to implement `Send` and `Sync` = help: consider using an `Rc` instead or wrapping the inner type with a `Mutex` = note: `-D clippy::arc-with-non-send-sync` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::arc_with_non_send_sync)]` error: usage of an `Arc` that is not `Send` or `Sync` --> $DIR/arc_with_non_send_sync.rs:40:13 diff --git a/src/tools/clippy/tests/ui/arithmetic_side_effects.stderr b/src/tools/clippy/tests/ui/arithmetic_side_effects.stderr index 7f490748160b8..13729a6c5a334 100644 --- a/src/tools/clippy/tests/ui/arithmetic_side_effects.stderr +++ b/src/tools/clippy/tests/ui/arithmetic_side_effects.stderr @@ -5,6 +5,7 @@ LL | _n += 1; | ^^^^^^^ | = note: `-D clippy::arithmetic-side-effects` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:305:5 diff --git a/src/tools/clippy/tests/ui/as_conversions.stderr b/src/tools/clippy/tests/ui/as_conversions.stderr index 54037a6499787..4bb964399e2da 100644 --- a/src/tools/clippy/tests/ui/as_conversions.stderr +++ b/src/tools/clippy/tests/ui/as_conversions.stderr @@ -6,6 +6,7 @@ LL | let i = 0u32 as u64; | = help: consider using a safe wrapper for this conversion = note: `-D clippy::as-conversions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::as_conversions)]` error: using a potentially dangerous silent `as` conversion --> $DIR/as_conversions.rs:12:13 diff --git a/src/tools/clippy/tests/ui/as_ptr_cast_mut.stderr b/src/tools/clippy/tests/ui/as_ptr_cast_mut.stderr index 1cd57dd6d1653..92cdf911538df 100644 --- a/src/tools/clippy/tests/ui/as_ptr_cast_mut.stderr +++ b/src/tools/clippy/tests/ui/as_ptr_cast_mut.stderr @@ -5,6 +5,7 @@ LL | let _ = string.as_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` | = note: `-D clippy::as-ptr-cast-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::as_ptr_cast_mut)]` error: casting the result of `as_ptr` to *mut i8 --> $DIR/as_ptr_cast_mut.rs:25:22 diff --git a/src/tools/clippy/tests/ui/as_underscore.stderr b/src/tools/clippy/tests/ui/as_underscore.stderr index 21d7884445d97..1842eeeacecb1 100644 --- a/src/tools/clippy/tests/ui/as_underscore.stderr +++ b/src/tools/clippy/tests/ui/as_underscore.stderr @@ -7,6 +7,7 @@ LL | foo(n as _); | help: consider giving the type explicitly: `usize` | = note: `-D clippy::as-underscore` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::as_underscore)]` error: using `as _` conversion --> $DIR/as_underscore.rs:10:18 diff --git a/src/tools/clippy/tests/ui/asm_syntax.stderr b/src/tools/clippy/tests/ui/asm_syntax.stderr index 8ee3c97ae2c6c..537ea8c57e9b2 100644 --- a/src/tools/clippy/tests/ui/asm_syntax.stderr +++ b/src/tools/clippy/tests/ui/asm_syntax.stderr @@ -6,6 +6,7 @@ LL | asm!(""); | = help: use AT&T x86 assembly syntax = note: `-D clippy::inline-asm-x86-intel-syntax` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]` error: Intel x86 assembly syntax used --> $DIR/asm_syntax.rs:10:9 @@ -31,6 +32,7 @@ LL | asm!("", options(att_syntax)); | = help: use Intel x86 assembly syntax = note: `-D clippy::inline-asm-x86-att-syntax` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]` error: AT&T x86 assembly syntax used --> $DIR/asm_syntax.rs:28:9 diff --git a/src/tools/clippy/tests/ui/assertions_on_constants.stderr b/src/tools/clippy/tests/ui/assertions_on_constants.stderr index fc1c7671ffc72..780d1fe1c8a7a 100644 --- a/src/tools/clippy/tests/ui/assertions_on_constants.stderr +++ b/src/tools/clippy/tests/ui/assertions_on_constants.stderr @@ -6,6 +6,7 @@ LL | assert!(true); | = help: remove it = note: `-D clippy::assertions-on-constants` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::assertions_on_constants)]` error: `assert!(false)` should probably be replaced --> $DIR/assertions_on_constants.rs:12:5 diff --git a/src/tools/clippy/tests/ui/assertions_on_result_states.stderr b/src/tools/clippy/tests/ui/assertions_on_result_states.stderr index 298d63c9c34fb..23af51cfe6fd0 100644 --- a/src/tools/clippy/tests/ui/assertions_on_result_states.stderr +++ b/src/tools/clippy/tests/ui/assertions_on_result_states.stderr @@ -5,6 +5,7 @@ LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` | = note: `-D clippy::assertions-on-result-states` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::assertions_on_result_states)]` error: called `assert!` with `Result::is_ok` --> $DIR/assertions_on_result_states.rs:42:5 diff --git a/src/tools/clippy/tests/ui/assign_ops.stderr b/src/tools/clippy/tests/ui/assign_ops.stderr index 525ce592b4920..e021e1bab4c43 100644 --- a/src/tools/clippy/tests/ui/assign_ops.stderr +++ b/src/tools/clippy/tests/ui/assign_ops.stderr @@ -5,6 +5,7 @@ LL | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:8:5 diff --git a/src/tools/clippy/tests/ui/assign_ops2.stderr b/src/tools/clippy/tests/ui/assign_ops2.stderr index b392d1c690bb6..6e9b96c0a644a 100644 --- a/src/tools/clippy/tests/ui/assign_ops2.stderr +++ b/src/tools/clippy/tests/ui/assign_ops2.stderr @@ -5,6 +5,7 @@ LL | a += a + 1; | ^^^^^^^^^^ | = note: `-D clippy::misrefactored-assign-op` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::misrefactored_assign_op)]` help: did you mean `a = a + 1` or `a = a + a + 1`? Consider replacing it with | LL | a += 1; @@ -141,6 +142,7 @@ LL | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: aborting due to 10 previous errors diff --git a/src/tools/clippy/tests/ui/async_yields_async.stderr b/src/tools/clippy/tests/ui/async_yields_async.stderr index 22ce1c6f6471b..c29e3c734b75b 100644 --- a/src/tools/clippy/tests/ui/async_yields_async.stderr +++ b/src/tools/clippy/tests/ui/async_yields_async.stderr @@ -11,6 +11,7 @@ LL | | }; | |______- outer async construct | = note: `-D clippy::async-yields-async` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::async_yields_async)]` help: consider awaiting this value | LL ~ async { diff --git a/src/tools/clippy/tests/ui/attrs.stderr b/src/tools/clippy/tests/ui/attrs.stderr index 0139717f54861..16402a4ddfeff 100644 --- a/src/tools/clippy/tests/ui/attrs.stderr +++ b/src/tools/clippy/tests/ui/attrs.stderr @@ -5,6 +5,7 @@ LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::inline-always` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_always)]` error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:27:14 @@ -13,6 +14,7 @@ LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::deprecated-semver` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deprecated_semver)]` error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:32:14 diff --git a/src/tools/clippy/tests/ui/await_holding_lock.stderr b/src/tools/clippy/tests/ui/await_holding_lock.stderr index d360c757158b0..56b111c4d9e41 100644 --- a/src/tools/clippy/tests/ui/await_holding_lock.stderr +++ b/src/tools/clippy/tests/ui/await_holding_lock.stderr @@ -14,6 +14,7 @@ LL | | baz().await LL | | } | |_____^ = note: `-D clippy::await-holding-lock` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::await_holding_lock)]` error: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:25:13 diff --git a/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr b/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr index 266f8f39028a5..6b7e1d1afddf4 100644 --- a/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr +++ b/src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr @@ -14,6 +14,7 @@ LL | | baz().await LL | | } | |_^ = note: `-D clippy::await-holding-refcell-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::await_holding_refcell_ref)]` error: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:12:9 diff --git a/src/tools/clippy/tests/ui/bit_masks.stderr b/src/tools/clippy/tests/ui/bit_masks.stderr index d0cb3a263fca8..4423d15d79d4d 100644 --- a/src/tools/clippy/tests/ui/bit_masks.stderr +++ b/src/tools/clippy/tests/ui/bit_masks.stderr @@ -5,6 +5,7 @@ LL | x & 0 == 0; | ^^^^^^^^^^ | = note: `-D clippy::bad-bit-mask` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bad_bit_mask)]` error: this operation will always return zero. This is likely not the intended outcome --> $DIR/bit_masks.rs:14:5 @@ -87,6 +88,7 @@ LL | x | 1 > 3; | ^^^^^^^^^ | = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ineffective_bit_mask)]` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly --> $DIR/bit_masks.rs:72:5 diff --git a/src/tools/clippy/tests/ui/blanket_clippy_restriction_lints.stderr b/src/tools/clippy/tests/ui/blanket_clippy_restriction_lints.stderr index 0f92fbebae99f..d04ea7151c2a5 100644 --- a/src/tools/clippy/tests/ui/blanket_clippy_restriction_lints.stderr +++ b/src/tools/clippy/tests/ui/blanket_clippy_restriction_lints.stderr @@ -3,6 +3,7 @@ error: `clippy::restriction` is not meant to be enabled as a group = note: because of the command line `--warn clippy::restriction` = help: enable the restriction lints you need individually = note: `-D clippy::blanket-clippy-restriction-lints` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::blanket_clippy_restriction_lints)]` error: `clippy::restriction` is not meant to be enabled as a group --> $DIR/blanket_clippy_restriction_lints.rs:6:9 diff --git a/src/tools/clippy/tests/ui/blocks_in_if_conditions.stderr b/src/tools/clippy/tests/ui/blocks_in_if_conditions.stderr index 2af7f3128c154..d80ef9c0fd8d2 100644 --- a/src/tools/clippy/tests/ui/blocks_in_if_conditions.stderr +++ b/src/tools/clippy/tests/ui/blocks_in_if_conditions.stderr @@ -8,6 +8,7 @@ LL | | } { | |_____^ | = note: `-D clippy::blocks-in-if-conditions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::blocks_in_if_conditions)]` help: try | LL ~ let res = { @@ -29,6 +30,7 @@ LL | if true && x == 3 { 6 } else { 10 } | ^^^^^^^^^^^^^^ help: try: `x == 3` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: aborting due to 3 previous errors diff --git a/src/tools/clippy/tests/ui/blocks_in_if_conditions_closure.stderr b/src/tools/clippy/tests/ui/blocks_in_if_conditions_closure.stderr index 34ebe5b6d1446..ab68997d477cb 100644 --- a/src/tools/clippy/tests/ui/blocks_in_if_conditions_closure.stderr +++ b/src/tools/clippy/tests/ui/blocks_in_if_conditions_closure.stderr @@ -11,6 +11,7 @@ LL | | }, | |_____________^ | = note: `-D clippy::blocks-in-if-conditions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::blocks_in_if_conditions)]` 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/blocks_in_if_conditions_closure.rs:34:13 diff --git a/src/tools/clippy/tests/ui/bool_assert_comparison.stderr b/src/tools/clippy/tests/ui/bool_assert_comparison.stderr index e0d718c4ed846..5969e4faa1aa5 100644 --- a/src/tools/clippy/tests/ui/bool_assert_comparison.stderr +++ b/src/tools/clippy/tests/ui/bool_assert_comparison.stderr @@ -5,6 +5,7 @@ LL | assert_eq!("a".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::bool-assert-comparison` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bool_assert_comparison)]` help: replace it with `assert!(..)` | LL - assert_eq!("a".is_empty(), false); diff --git a/src/tools/clippy/tests/ui/bool_comparison.stderr b/src/tools/clippy/tests/ui/bool_comparison.stderr index 31522d4a52519..4560df6d4cdbd 100644 --- a/src/tools/clippy/tests/ui/bool_comparison.stderr +++ b/src/tools/clippy/tests/ui/bool_comparison.stderr @@ -5,6 +5,7 @@ LL | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` | = note: `-D clippy::bool-comparison` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:12:8 diff --git a/src/tools/clippy/tests/ui/bool_to_int_with_if.stderr b/src/tools/clippy/tests/ui/bool_to_int_with_if.stderr index b0581e96834c2..837ed05d3a650 100644 --- a/src/tools/clippy/tests/ui/bool_to_int_with_if.stderr +++ b/src/tools/clippy/tests/ui/bool_to_int_with_if.stderr @@ -10,6 +10,7 @@ LL | | }; | = note: `a as i32` or `a.into()` can also be valid options = note: `-D clippy::bool-to-int-with-if` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bool_to_int_with_if)]` error: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:19:5 diff --git a/src/tools/clippy/tests/ui/borrow_as_ptr.stderr b/src/tools/clippy/tests/ui/borrow_as_ptr.stderr index b0e4e9363f1ff..43a7a6bf5b57e 100644 --- a/src/tools/clippy/tests/ui/borrow_as_ptr.stderr +++ b/src/tools/clippy/tests/ui/borrow_as_ptr.stderr @@ -5,6 +5,7 @@ LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)` | = note: `-D clippy::borrow-as-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]` error: borrow as raw pointer --> $DIR/borrow_as_ptr.rs:17:18 diff --git a/src/tools/clippy/tests/ui/borrow_as_ptr_no_std.stderr b/src/tools/clippy/tests/ui/borrow_as_ptr_no_std.stderr index 4a0467cdbfe13..2f258bcf966ad 100644 --- a/src/tools/clippy/tests/ui/borrow_as_ptr_no_std.stderr +++ b/src/tools/clippy/tests/ui/borrow_as_ptr_no_std.stderr @@ -5,6 +5,7 @@ LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of!(val)` | = note: `-D clippy::borrow-as-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]` error: borrow as raw pointer --> $DIR/borrow_as_ptr_no_std.rs:11:18 diff --git a/src/tools/clippy/tests/ui/borrow_deref_ref.stderr b/src/tools/clippy/tests/ui/borrow_deref_ref.stderr index 524cf597c7f27..c389d6797388b 100644 --- a/src/tools/clippy/tests/ui/borrow_deref_ref.stderr +++ b/src/tools/clippy/tests/ui/borrow_deref_ref.stderr @@ -5,6 +5,7 @@ LL | let b = &*a; | ^^^ help: if you would like to reborrow, try removing `&*`: `a` | = note: `-D clippy::borrow-deref-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::borrow_deref_ref)]` error: deref on an immutable reference --> $DIR/borrow_deref_ref.rs:15:22 diff --git a/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr b/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr index 5650f722b54bf..2a21f5ca236fb 100644 --- a/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr +++ b/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr @@ -5,6 +5,7 @@ LL | let x: &str = &*s; | ^^^ | = note: `-D clippy::borrow-deref-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::borrow_deref_ref)]` help: if you would like to reborrow, try removing `&*` | LL | let x: &str = s; diff --git a/src/tools/clippy/tests/ui/box_collection.stderr b/src/tools/clippy/tests/ui/box_collection.stderr index 7734271267534..1ae7c2a05e3dc 100644 --- a/src/tools/clippy/tests/ui/box_collection.stderr +++ b/src/tools/clippy/tests/ui/box_collection.stderr @@ -6,6 +6,7 @@ LL | fn test1(foo: Box>) {} | = help: `Vec<..>` is already on the heap, `Box>` makes an extra allocation = note: `-D clippy::box-collection` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::box_collection)]` error: you seem to be trying to use `Box`. Consider using just `String` --> $DIR/box_collection.rs:29:15 diff --git a/src/tools/clippy/tests/ui/box_default.stderr b/src/tools/clippy/tests/ui/box_default.stderr index 8c4778983d390..004550c6c64a7 100644 --- a/src/tools/clippy/tests/ui/box_default.stderr +++ b/src/tools/clippy/tests/ui/box_default.stderr @@ -5,6 +5,7 @@ LL | let _string: Box = Box::new(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` | = note: `-D clippy::box-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::box_default)]` error: `Box::new(_)` of default value --> $DIR/box_default.rs:23:17 diff --git a/src/tools/clippy/tests/ui/boxed_local.stderr b/src/tools/clippy/tests/ui/boxed_local.stderr index 11868605d9693..187cc8fa18bac 100644 --- a/src/tools/clippy/tests/ui/boxed_local.stderr +++ b/src/tools/clippy/tests/ui/boxed_local.stderr @@ -5,6 +5,7 @@ LL | fn warn_arg(x: Box) { | ^ | = note: `-D clippy::boxed-local` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::boxed_local)]` error: local variable doesn't need to be boxed here --> $DIR/boxed_local.rs:123:12 diff --git a/src/tools/clippy/tests/ui/builtin_type_shadow.stderr b/src/tools/clippy/tests/ui/builtin_type_shadow.stderr index 47a8a1e623e8a..cb8462182b895 100644 --- a/src/tools/clippy/tests/ui/builtin_type_shadow.stderr +++ b/src/tools/clippy/tests/ui/builtin_type_shadow.stderr @@ -5,6 +5,7 @@ LL | fn foo(a: u32) -> u32 { | ^^^ | = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::builtin_type_shadow)]` error[E0308]: mismatched types --> $DIR/builtin_type_shadow.rs:5:5 diff --git a/src/tools/clippy/tests/ui/bytes_count_to_len.stderr b/src/tools/clippy/tests/ui/bytes_count_to_len.stderr index fe2c8b0627dc2..db0bb4099de9f 100644 --- a/src/tools/clippy/tests/ui/bytes_count_to_len.stderr +++ b/src/tools/clippy/tests/ui/bytes_count_to_len.stderr @@ -5,6 +5,7 @@ LL | let _ = String::from("foo").bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `String::from("foo").len()` | = note: `-D clippy::bytes-count-to-len` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bytes_count_to_len)]` error: using long and hard to read `.bytes().count()` --> $DIR/bytes_count_to_len.rs:10:13 diff --git a/src/tools/clippy/tests/ui/bytes_nth.stderr b/src/tools/clippy/tests/ui/bytes_nth.stderr index d9ede64a3815a..574bfaac193db 100644 --- a/src/tools/clippy/tests/ui/bytes_nth.stderr +++ b/src/tools/clippy/tests/ui/bytes_nth.stderr @@ -5,6 +5,7 @@ LL | let _ = s.bytes().nth(3); | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3).copied()` | = note: `-D clippy::bytes-nth` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bytes_nth)]` error: called `.bytes().nth().unwrap()` on a `String` --> $DIR/bytes_nth.rs:7:14 diff --git a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr index 9abf8aaca93bf..49c840bd76924 100644 --- a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr +++ b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr @@ -6,6 +6,7 @@ LL | filename.ends_with(".rs") | = help: consider using a case-insensitive comparison instead = note: `-D clippy::case-sensitive-file-extension-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::case_sensitive_file_extension_comparisons)]` help: use std::path::Path | LL ~ std::path::Path::new(filename) diff --git a/src/tools/clippy/tests/ui/cast.stderr b/src/tools/clippy/tests/ui/cast.stderr index 5442ef5db16d2..bc74f7b728e86 100644 --- a/src/tools/clippy/tests/ui/cast.stderr +++ b/src/tools/clippy/tests/ui/cast.stderr @@ -5,6 +5,7 @@ LL | x0 as f32; | ^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` 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:20:5 @@ -44,6 +45,7 @@ LL | 1f32 as i32; | = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]` error: casting `f32` to `u32` may truncate the value --> $DIR/cast.rs:35:5 @@ -60,6 +62,7 @@ LL | 1f32 as u32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_sign_loss)]` error: casting `f64` to `f32` may truncate the value --> $DIR/cast.rs:39:5 @@ -190,6 +193,7 @@ LL | 1u8 as i8; | ^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `u16` to `i16` may wrap around the value --> $DIR/cast.rs:69:5 @@ -360,6 +364,7 @@ LL | let _ = Self::B as u8; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-enum-truncation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_enum_truncation)]` error: casting `main::E5` to `i8` may truncate the value --> $DIR/cast.rs:260:21 diff --git a/src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr b/src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr index 94b87df0b6ece..fbdb559fc4219 100644 --- a/src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr +++ b/src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr @@ -5,6 +5,7 @@ LL | let y: u32 = x.abs() as u32; | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` | = note: `-D clippy::cast-abs-to-unsigned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_abs_to_unsigned)]` error: casting the result of `i32::abs()` to usize --> $DIR/cast_abs_to_unsigned.rs:10:20 diff --git a/src/tools/clippy/tests/ui/cast_alignment.stderr b/src/tools/clippy/tests/ui/cast_alignment.stderr index 70510eaf6345a..49bd8dad9c241 100644 --- a/src/tools/clippy/tests/ui/cast_alignment.stderr +++ b/src/tools/clippy/tests/ui/cast_alignment.stderr @@ -5,6 +5,7 @@ LL | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_ptr_alignment)]` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) --> $DIR/cast_alignment.rs:22:5 diff --git a/src/tools/clippy/tests/ui/cast_enum_constructor.stderr b/src/tools/clippy/tests/ui/cast_enum_constructor.stderr index f0489f08f9105..b1bf61edeedbe 100644 --- a/src/tools/clippy/tests/ui/cast_enum_constructor.stderr +++ b/src/tools/clippy/tests/ui/cast_enum_constructor.stderr @@ -5,6 +5,7 @@ LL | let _ = Foo::Y as usize; | ^^^^^^^^^^^^^^^ | = note: `-D clippy::cast-enum-constructor` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_enum_constructor)]` error: cast of an enum tuple constructor to an integer --> $DIR/cast_enum_constructor.rs:16:13 diff --git a/src/tools/clippy/tests/ui/cast_lossless_bool.stderr b/src/tools/clippy/tests/ui/cast_lossless_bool.stderr index 891476f304df0..e4a5b2e805c35 100644 --- a/src/tools/clippy/tests/ui/cast_lossless_bool.stderr +++ b/src/tools/clippy/tests/ui/cast_lossless_bool.stderr @@ -5,6 +5,7 @@ LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` --> $DIR/cast_lossless_bool.rs:7:13 diff --git a/src/tools/clippy/tests/ui/cast_lossless_float.stderr b/src/tools/clippy/tests/ui/cast_lossless_float.stderr index 70dc4a1026481..95e80b4e4a6e7 100644 --- a/src/tools/clippy/tests/ui/cast_lossless_float.stderr +++ b/src/tools/clippy/tests/ui/cast_lossless_float.stderr @@ -5,6 +5,7 @@ LL | let _ = x0 as f32; | ^^^^^^^^^ help: try: `f32::from(x0)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: casting `i8` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:8:13 diff --git a/src/tools/clippy/tests/ui/cast_lossless_integer.stderr b/src/tools/clippy/tests/ui/cast_lossless_integer.stderr index 4891d934c5e17..da75cb195ebae 100644 --- a/src/tools/clippy/tests/ui/cast_lossless_integer.stderr +++ b/src/tools/clippy/tests/ui/cast_lossless_integer.stderr @@ -5,6 +5,7 @@ LL | let _ = 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: casting `i8` to `i32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:7:13 diff --git a/src/tools/clippy/tests/ui/cast_nan_to_int.stderr b/src/tools/clippy/tests/ui/cast_nan_to_int.stderr index 678db89954e51..c0bb29448f2f8 100644 --- a/src/tools/clippy/tests/ui/cast_nan_to_int.stderr +++ b/src/tools/clippy/tests/ui/cast_nan_to_int.stderr @@ -6,6 +6,7 @@ LL | let _ = (0.0_f32 / -0.0) as usize; | = note: this always evaluates to 0 = note: `-D clippy::cast-nan-to-int` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_nan_to_int)]` error: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:8:13 diff --git a/src/tools/clippy/tests/ui/cast_raw_slice_pointer_cast.stderr b/src/tools/clippy/tests/ui/cast_raw_slice_pointer_cast.stderr index 8316411202670..47dc39a30ef7d 100644 --- a/src/tools/clippy/tests/ui/cast_raw_slice_pointer_cast.stderr +++ b/src/tools/clippy/tests/ui/cast_raw_slice_pointer_cast.stderr @@ -5,6 +5,7 @@ LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) as *co | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` | = note: `-D clippy::cast-slice-from-raw-parts` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_slice_from_raw_parts)]` error: casting the result of `from_raw_parts_mut` to *mut [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:9:35 diff --git a/src/tools/clippy/tests/ui/cast_size.stderr b/src/tools/clippy/tests/ui/cast_size.stderr index 6c7459b3abaee..bc9224be64401 100644 --- a/src/tools/clippy/tests/ui/cast_size.stderr +++ b/src/tools/clippy/tests/ui/cast_size.stderr @@ -6,6 +6,7 @@ LL | 1isize as i8; | = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]` help: ... or use `try_from` and handle the error accordingly | LL | i8::try_from(1isize); @@ -18,6 +19,7 @@ LL | x0 as f64; | ^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` 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:19:5 @@ -92,6 +94,7 @@ LL | 1usize as i32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:36:5 diff --git a/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr b/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr index 524a2bf72484b..8816ce2d83749 100644 --- a/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr +++ b/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr @@ -5,6 +5,7 @@ LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` | = note: `-D clippy::deprecated-cfg-attr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deprecated_cfg_attr)]` error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes --> $DIR/cfg_attr_rustfmt.rs:22:1 diff --git a/src/tools/clippy/tests/ui/cfg_features.stderr b/src/tools/clippy/tests/ui/cfg_features.stderr index 5f92dfe169c72..401c3e92ed952 100644 --- a/src/tools/clippy/tests/ui/cfg_features.stderr +++ b/src/tools/clippy/tests/ui/cfg_features.stderr @@ -5,6 +5,7 @@ LL | #[cfg(features = "not-really-a-feature")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `feature = "not-really-a-feature"` | = note: `-D clippy::maybe-misused-cfg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::maybe_misused_cfg)]` error: feature may misspelled as features --> $DIR/cfg_features.rs:9:34 diff --git a/src/tools/clippy/tests/ui/char_lit_as_u8.stderr b/src/tools/clippy/tests/ui/char_lit_as_u8.stderr index da3e5c5e52b16..ce1f2f8296e5d 100644 --- a/src/tools/clippy/tests/ui/char_lit_as_u8.stderr +++ b/src/tools/clippy/tests/ui/char_lit_as_u8.stderr @@ -6,6 +6,7 @@ LL | let _ = '❤' as u8; | = note: `char` is four bytes wide, but `u8` is a single byte = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::char_lit_as_u8)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/char_lit_as_u8_suggestions.stderr b/src/tools/clippy/tests/ui/char_lit_as_u8_suggestions.stderr index 0542db5501a0c..359857119d09c 100644 --- a/src/tools/clippy/tests/ui/char_lit_as_u8_suggestions.stderr +++ b/src/tools/clippy/tests/ui/char_lit_as_u8_suggestions.stderr @@ -6,6 +6,7 @@ LL | let _ = 'a' as u8; | = note: `char` is four bytes wide, but `u8` is a single byte = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::char_lit_as_u8)]` error: casting a character literal to `u8` truncates --> $DIR/char_lit_as_u8_suggestions.rs:5:13 diff --git a/src/tools/clippy/tests/ui/checked_conversions.stderr b/src/tools/clippy/tests/ui/checked_conversions.stderr index 08457973a2188..3e0169b74dabc 100644 --- a/src/tools/clippy/tests/ui/checked_conversions.stderr +++ b/src/tools/clippy/tests/ui/checked_conversions.stderr @@ -5,6 +5,7 @@ LL | let _ = value <= (u32::max_value() as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` | = note: `-D clippy::checked-conversions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::checked_conversions)]` error: checked cast can be simplified --> $DIR/checked_conversions.rs:15:13 diff --git a/src/tools/clippy/tests/ui/clear_with_drain.stderr b/src/tools/clippy/tests/ui/clear_with_drain.stderr index db545c5fba4e9..b1a3812563afa 100644 --- a/src/tools/clippy/tests/ui/clear_with_drain.stderr +++ b/src/tools/clippy/tests/ui/clear_with_drain.stderr @@ -5,6 +5,7 @@ LL | v.drain(0..v.len()); | ^^^^^^^^^^^^^^^^^ help: try: `clear()` | = note: `-D clippy::clear-with-drain` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::clear_with_drain)]` error: `drain` used to clear a `Vec` --> $DIR/clear_with_drain.rs:26:7 diff --git a/src/tools/clippy/tests/ui/clone_on_copy.stderr b/src/tools/clippy/tests/ui/clone_on_copy.stderr index 053dee954481e..0526c2f5a28a4 100644 --- a/src/tools/clippy/tests/ui/clone_on_copy.stderr +++ b/src/tools/clippy/tests/ui/clone_on_copy.stderr @@ -5,6 +5,7 @@ LL | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::clone_on_copy)]` error: using `clone` on type `i32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:27:5 diff --git a/src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr b/src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr index 247d15a015ab9..69a3738dd05b5 100644 --- a/src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr +++ b/src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr @@ -5,6 +5,7 @@ LL | let _ = [1].iter().cloned(); | ^^^^^^ help: try: `copied` | = note: `-D clippy::cloned-instead-of-copied` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cloned_instead_of_copied)]` error: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:8:31 diff --git a/src/tools/clippy/tests/ui/cmp_null.stderr b/src/tools/clippy/tests/ui/cmp_null.stderr index cc2ffb21b476b..d3b7c85b22935 100644 --- a/src/tools/clippy/tests/ui/cmp_null.stderr +++ b/src/tools/clippy/tests/ui/cmp_null.stderr @@ -5,6 +5,7 @@ LL | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-null` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cmp_null)]` error: comparing with null is better expressed by the `.is_null()` method --> $DIR/cmp_null.rs:16:8 diff --git a/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.stderr b/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.stderr index 95c829e795e6e..6431b3619be9a 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/asymmetric_partial_eq.stderr @@ -5,6 +5,7 @@ LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` | = note: `-D clippy::cmp-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:47:21 diff --git a/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr b/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr index 76983578f4169..09a495996f2cc 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr @@ -5,6 +5,7 @@ LL | if a.to_string() != "bar" { | ^^^^^^^^^^^^^ help: try: `a` | = note: `-D clippy::cmp-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison --> $DIR/comparison_flip.rs:10:17 diff --git a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr index 88e6da2f06710..0b1127c1a61bd 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr @@ -5,6 +5,7 @@ LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` | = note: `-D clippy::cmp-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:7:9 diff --git a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr index fa7cb380eba18..c4f63bd09cb81 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr @@ -5,6 +5,7 @@ LL | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating | = note: `-D clippy::cmp-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison --> $DIR/without_suggestion.rs:13:5 diff --git a/src/tools/clippy/tests/ui/cognitive_complexity.stderr b/src/tools/clippy/tests/ui/cognitive_complexity.stderr index a712b163b171c..58c7455d11a69 100644 --- a/src/tools/clippy/tests/ui/cognitive_complexity.stderr +++ b/src/tools/clippy/tests/ui/cognitive_complexity.stderr @@ -6,6 +6,7 @@ LL | fn main() { | = help: you could split it up into multiple smaller functions = note: `-D clippy::cognitive-complexity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cognitive_complexity)]` error: the function has a cognitive complexity of (7/1) --> $DIR/cognitive_complexity.rs:92:4 diff --git a/src/tools/clippy/tests/ui/cognitive_complexity_attr_used.stderr b/src/tools/clippy/tests/ui/cognitive_complexity_attr_used.stderr index bb48f32974867..9cd25f6fda989 100644 --- a/src/tools/clippy/tests/ui/cognitive_complexity_attr_used.stderr +++ b/src/tools/clippy/tests/ui/cognitive_complexity_attr_used.stderr @@ -6,6 +6,7 @@ LL | fn kaboom() { | = help: you could split it up into multiple smaller functions = note: `-D clippy::cognitive-complexity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cognitive_complexity)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/collapsible_else_if.stderr b/src/tools/clippy/tests/ui/collapsible_else_if.stderr index b644205d9830e..f0f840653f8ac 100644 --- a/src/tools/clippy/tests/ui/collapsible_else_if.stderr +++ b/src/tools/clippy/tests/ui/collapsible_else_if.stderr @@ -10,6 +10,7 @@ LL | | } | |_____^ | = note: `-D clippy::collapsible-else-if` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::collapsible_else_if)]` help: collapse nested if block | LL ~ } else if y == "world" { diff --git a/src/tools/clippy/tests/ui/collapsible_if.stderr b/src/tools/clippy/tests/ui/collapsible_if.stderr index c687bae1acc52..e8a36bf48f11b 100644 --- a/src/tools/clippy/tests/ui/collapsible_if.stderr +++ b/src/tools/clippy/tests/ui/collapsible_if.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::collapsible-if` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::collapsible_if)]` help: collapse nested if block | LL ~ if x == "hello" && y == "world" { diff --git a/src/tools/clippy/tests/ui/collapsible_match.stderr b/src/tools/clippy/tests/ui/collapsible_match.stderr index 51a5eedd761c2..ce7da1c16d30c 100644 --- a/src/tools/clippy/tests/ui/collapsible_match.stderr +++ b/src/tools/clippy/tests/ui/collapsible_match.stderr @@ -18,6 +18,7 @@ LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern = note: `-D clippy::collapsible-match` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]` error: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:23:20 diff --git a/src/tools/clippy/tests/ui/collapsible_match2.stderr b/src/tools/clippy/tests/ui/collapsible_match2.stderr index f1b7c1417ef71..e008355bec8aa 100644 --- a/src/tools/clippy/tests/ui/collapsible_match2.stderr +++ b/src/tools/clippy/tests/ui/collapsible_match2.stderr @@ -18,6 +18,7 @@ LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern = note: `-D clippy::collapsible-match` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]` error: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match2.rs:21:24 diff --git a/src/tools/clippy/tests/ui/collapsible_str_replace.stderr b/src/tools/clippy/tests/ui/collapsible_str_replace.stderr index 0751a1043002d..4b0bd818d2f00 100644 --- a/src/tools/clippy/tests/ui/collapsible_str_replace.stderr +++ b/src/tools/clippy/tests/ui/collapsible_str_replace.stderr @@ -5,6 +5,7 @@ LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` | = note: `-D clippy::collapsible-str-replace` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::collapsible_str_replace)]` error: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:20:27 diff --git a/src/tools/clippy/tests/ui/collection_is_never_read.stderr b/src/tools/clippy/tests/ui/collection_is_never_read.stderr index 0d3f2fc602f81..acb9abff68e9b 100644 --- a/src/tools/clippy/tests/ui/collection_is_never_read.stderr +++ b/src/tools/clippy/tests/ui/collection_is_never_read.stderr @@ -5,6 +5,7 @@ LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::collection-is-never-read` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::collection_is_never_read)]` error: collection is never read --> $DIR/collection_is_never_read.rs:62:5 diff --git a/src/tools/clippy/tests/ui/comparison_chain.stderr b/src/tools/clippy/tests/ui/comparison_chain.stderr index db20b1fbb3b4b..3b41dcf55c623 100644 --- a/src/tools/clippy/tests/ui/comparison_chain.stderr +++ b/src/tools/clippy/tests/ui/comparison_chain.stderr @@ -11,6 +11,7 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` = note: `-D clippy::comparison-chain` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::comparison_chain)]` error: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:28:5 diff --git a/src/tools/clippy/tests/ui/comparison_to_empty.stderr b/src/tools/clippy/tests/ui/comparison_to_empty.stderr index 0a59caea8a2d7..b97ab4c3c9375 100644 --- a/src/tools/clippy/tests/ui/comparison_to_empty.stderr +++ b/src/tools/clippy/tests/ui/comparison_to_empty.stderr @@ -5,6 +5,7 @@ LL | let _ = s == ""; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` | = note: `-D clippy::comparison-to-empty` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]` error: comparison to empty slice --> $DIR/comparison_to_empty.rs:9:13 diff --git a/src/tools/clippy/tests/ui/const_comparisons.stderr b/src/tools/clippy/tests/ui/const_comparisons.stderr index 8c920d36896d6..f773ccbc711e9 100644 --- a/src/tools/clippy/tests/ui/const_comparisons.stderr +++ b/src/tools/clippy/tests/ui/const_comparisons.stderr @@ -6,6 +6,7 @@ LL | status_code <= 400 && status_code > 500; | = note: since `400` < `500`, the expression evaluates to false for any value of `status_code` = note: `-D clippy::impossible-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::impossible_comparisons)]` error: boolean expression will never evaluate to 'true' --> $DIR/const_comparisons.rs:48:5 @@ -131,6 +132,7 @@ note: `if `status_code < 200` evaluates to true, status_code <= 299` will always LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::redundant-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_comparisons)]` error: left-hand side of `&&` operator has no effect --> $DIR/const_comparisons.rs:114:5 diff --git a/src/tools/clippy/tests/ui/copy_iterator.stderr b/src/tools/clippy/tests/ui/copy_iterator.stderr index 12a329bdc12b6..48c3385b6c8a9 100644 --- a/src/tools/clippy/tests/ui/copy_iterator.stderr +++ b/src/tools/clippy/tests/ui/copy_iterator.stderr @@ -12,6 +12,7 @@ LL | | } | = note: consider implementing `IntoIterator` instead = note: `-D clippy::copy-iterator` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::copy_iterator)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-10148.stderr b/src/tools/clippy/tests/ui/crashes/ice-10148.stderr index f23e4433f95ed..4d436e3aa04fa 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10148.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-10148.stderr @@ -7,6 +7,7 @@ LL | println!(with_span!(""something "")); | help: remove the empty string | = note: `-D clippy::println-empty-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::println_empty_string)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-10645.stderr b/src/tools/clippy/tests/ui/crashes/ice-10645.stderr index 0055fe061e2aa..fc5347c86cdeb 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10645.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-10645.stderr @@ -11,6 +11,7 @@ LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^ has type `T` which is not `Send` = note: `T` doesn't implement `std::marker::Send` = note: `-D clippy::future-not-send` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::future_not_send)]` warning: 1 warning emitted diff --git a/src/tools/clippy/tests/ui/crashes/ice-10912.stderr b/src/tools/clippy/tests/ui/crashes/ice-10912.stderr index 0833769feecf1..2be297b56250f 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10912.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-10912.stderr @@ -11,6 +11,7 @@ LL | fn f2() -> impl Sized { && 3.14159265358979323846E } | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider: `3.141_592_653_589_793_238_46` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]` error: aborting due to 2 previous errors diff --git a/src/tools/clippy/tests/ui/crashes/ice-2774.stderr b/src/tools/clippy/tests/ui/crashes/ice-2774.stderr index a166ccb3ee8fa..ae9610c9acd42 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-2774.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-2774.stderr @@ -5,6 +5,7 @@ LL | pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { | ^^ ^^ | = note: `-D clippy::needless-lifetimes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` help: elide the lifetimes | LL - pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { diff --git a/src/tools/clippy/tests/ui/crashes/ice-360.stderr b/src/tools/clippy/tests/ui/crashes/ice-360.stderr index 292b27dd934ed..dd016355b5325 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-360.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-360.stderr @@ -11,6 +11,7 @@ LL | | } | |_____^ help: try: `while let Some(ele) = iter.next() { .. }` | = note: `-D clippy::while-let-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: empty `loop {}` wastes CPU cycles --> $DIR/ice-360.rs:12:9 @@ -20,6 +21,7 @@ LL | loop {} | = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body = note: `-D clippy::empty-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: aborting due to 2 previous errors diff --git a/src/tools/clippy/tests/ui/crashes/ice-3969.stderr b/src/tools/clippy/tests/ui/crashes/ice-3969.stderr index bc10555693ca8..c6bef3004d377 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-3969.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-3969.stderr @@ -5,6 +5,7 @@ LL | str: Sized; | ^^^^^ | = note: `-D trivial-bounds` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(trivial_bounds)]` error: trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/ice-3969.rs:26:30 diff --git a/src/tools/clippy/tests/ui/crashes/ice-5835.stderr b/src/tools/clippy/tests/ui/crashes/ice-5835.stderr index c972bcb60a0cd..74d99a3484729 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-5835.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-5835.stderr @@ -5,6 +5,7 @@ LL | /// 位 | ^^^^ help: consider using four spaces per tab | = note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-5872.stderr b/src/tools/clippy/tests/ui/crashes/ice-5872.stderr index a60ca345cf78d..75a26ee318c32 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-5872.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-5872.stderr @@ -5,6 +5,7 @@ LL | let _ = vec![1, 2, 3].into_iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` | = note: `-D clippy::needless-collect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_collect)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-6254.stderr b/src/tools/clippy/tests/ui/crashes/ice-6254.stderr index 263c27d3d646a..6ace7dae8bdce 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6254.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6254.stderr @@ -9,6 +9,7 @@ LL | FOO_REF_REF => {}, = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details = note: `-D indirect-structural-match` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(indirect_structural_match)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-7169.stderr b/src/tools/clippy/tests/ui/crashes/ice-7169.stderr index 0cd02851640e6..47947f89baf53 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-7169.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-7169.stderr @@ -5,6 +5,7 @@ LL | if let Ok(_) = Ok::<_, ()>(A::::default()) {} | -------^^^^^-------------------------------------- help: try: `if Ok::<_, ()>(A::::default()).is_ok()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-7868.stderr b/src/tools/clippy/tests/ui/crashes/ice-7868.stderr index 1d8314e889fa1..e5f14f2215d7e 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-7868.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-7868.stderr @@ -6,6 +6,7 @@ LL | unsafe { 0 }; | = help: consider adding a safety comment on the preceding line = note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-7869.stderr b/src/tools/clippy/tests/ui/crashes/ice-7869.stderr index 61fc8a4817a7d..7acace78a7b26 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-7869.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-7869.stderr @@ -11,6 +11,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports = note: `-D clippy::enum-variant-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::enum_variant_names)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-8250.stderr b/src/tools/clippy/tests/ui/crashes/ice-8250.stderr index e6f3644ef34f2..9c57f334581c5 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-8250.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-8250.stderr @@ -5,6 +5,7 @@ LL | let _ = s[1..].splitn(2, '.').next()?; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s[1..].split('.')` | = note: `-D clippy::needless-splitn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_splitn)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-8821.stderr b/src/tools/clippy/tests/ui/crashes/ice-8821.stderr index 486096e0a06dd..c8bd01fb1c645 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-8821.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-8821.stderr @@ -5,6 +5,7 @@ LL | let _: () = FN(); | ^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `FN();` | = note: `-D clippy::let-unit-value` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-8850.stderr b/src/tools/clippy/tests/ui/crashes/ice-8850.stderr index 41da3f715ae37..aa140f305e39d 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-8850.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-8850.stderr @@ -7,6 +7,7 @@ LL | res | ^^^ | = note: `-D clippy::let-and-return` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_and_return)]` help: return the expression directly | LL ~ diff --git a/src/tools/clippy/tests/ui/crashes/ice-9041.stderr b/src/tools/clippy/tests/ui/crashes/ice-9041.stderr index f5038f0a84847..49c9bdc300ee9 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9041.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9041.stderr @@ -5,6 +5,7 @@ LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|p| is_thing_ready(&p))` | = note: `-D clippy::search-is-some` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-9445.stderr b/src/tools/clippy/tests/ui/crashes/ice-9445.stderr index a59d098e5ac0a..9307409ba5852 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9445.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9445.stderr @@ -7,6 +7,7 @@ LL | const UNINIT: core::mem::MaybeUninit> = core: | make this a static item (maybe with lazy_static) | = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr b/src/tools/clippy/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr index 7a0a648974fc7..6d45393996d07 100644 --- a/src/tools/clippy/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr +++ b/src/tools/clippy/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr @@ -10,6 +10,7 @@ help: consider marking this type as `Copy` LL | struct Foo<'a>(&'a [(); 100]); | ^^^^^^^^^^^^^^ = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_value)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crate_in_macro_def.stderr b/src/tools/clippy/tests/ui/crate_in_macro_def.stderr index faf2bca1d6298..3e624618237c2 100644 --- a/src/tools/clippy/tests/ui/crate_in_macro_def.stderr +++ b/src/tools/clippy/tests/ui/crate_in_macro_def.stderr @@ -5,6 +5,7 @@ LL | println!("{}", crate::unhygienic::MESSAGE); | ^^^^^ help: to reference the macro definition's crate, use: `$crate` | = note: `-D clippy::crate-in-macro-def` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::crate_in_macro_def)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr b/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr index 9258c828aafc6..01033246dd90b 100644 --- a/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr +++ b/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr @@ -9,6 +9,7 @@ LL | | b = a; | = note: or maybe you should use `core::mem::replace`? = note: `-D clippy::almost-swapped` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::almost_swapped)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/crate_level_checks/std_main_recursion.stderr b/src/tools/clippy/tests/ui/crate_level_checks/std_main_recursion.stderr index 82c68bd1cfef9..f3ffd6a10c717 100644 --- a/src/tools/clippy/tests/ui/crate_level_checks/std_main_recursion.stderr +++ b/src/tools/clippy/tests/ui/crate_level_checks/std_main_recursion.stderr @@ -6,6 +6,7 @@ LL | main(); | = help: consider using another function for this recursion = note: `-D clippy::main-recursion` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::main_recursion)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/create_dir.stderr b/src/tools/clippy/tests/ui/create_dir.stderr index 5c005bee761e4..037e6ff173ac0 100644 --- a/src/tools/clippy/tests/ui/create_dir.stderr +++ b/src/tools/clippy/tests/ui/create_dir.stderr @@ -5,6 +5,7 @@ LL | std::fs::create_dir("foo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("foo")` | = note: `-D clippy::create-dir` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::create_dir)]` error: calling `std::fs::create_dir` where there may be a better way --> $DIR/create_dir.rs:11:5 diff --git a/src/tools/clippy/tests/ui/dbg_macro.stderr b/src/tools/clippy/tests/ui/dbg_macro.stderr index e63d07a5f2472..f45a7ba1faebd 100644 --- a/src/tools/clippy/tests/ui/dbg_macro.stderr +++ b/src/tools/clippy/tests/ui/dbg_macro.stderr @@ -5,6 +5,7 @@ LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::dbg-macro` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]` help: remove the invocation before committing it to a version control system | LL | if let Some(n) = n.checked_sub(4) { n } else { n } diff --git a/src/tools/clippy/tests/ui/debug_assert_with_mut_call.stderr b/src/tools/clippy/tests/ui/debug_assert_with_mut_call.stderr index 97c47064a3353..b993bbf5526dd 100644 --- a/src/tools/clippy/tests/ui/debug_assert_with_mut_call.stderr +++ b/src/tools/clippy/tests/ui/debug_assert_with_mut_call.stderr @@ -5,6 +5,7 @@ LL | debug_assert!(bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::debug-assert-with-mut-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::debug_assert_with_mut_call)]` error: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:45:20 diff --git a/src/tools/clippy/tests/ui/decimal_literal_representation.stderr b/src/tools/clippy/tests/ui/decimal_literal_representation.stderr index 2f126073c3379..f1d4d744e7312 100644 --- a/src/tools/clippy/tests/ui/decimal_literal_representation.stderr +++ b/src/tools/clippy/tests/ui/decimal_literal_representation.stderr @@ -5,6 +5,7 @@ LL | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::decimal_literal_representation)]` error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:17:9 diff --git a/src/tools/clippy/tests/ui/declare_interior_mutable_const/enums.stderr b/src/tools/clippy/tests/ui/declare_interior_mutable_const/enums.stderr index 6070df749ca98..6d34373886d5a 100644 --- a/src/tools/clippy/tests/ui/declare_interior_mutable_const/enums.stderr +++ b/src/tools/clippy/tests/ui/declare_interior_mutable_const/enums.stderr @@ -7,6 +7,7 @@ LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(tru | make this a static item (maybe with lazy_static) | = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable --> $DIR/enums.rs:23:1 diff --git a/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.stderr b/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.stderr index 0259f6a4a286b..cc286b9f7f685 100644 --- a/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.stderr +++ b/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.stderr @@ -7,6 +7,7 @@ LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); | make this a static item (maybe with lazy_static) | = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable --> $DIR/others.rs:10:1 diff --git a/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.stderr b/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.stderr index ef62919dfead3..7647cd96fec77 100644 --- a/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.stderr +++ b/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.stderr @@ -5,6 +5,7 @@ LL | const ATOMIC: AtomicUsize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` error: a `const` item should never be interior mutable --> $DIR/traits.rs:9:9 diff --git a/src/tools/clippy/tests/ui/def_id_nocore.stderr b/src/tools/clippy/tests/ui/def_id_nocore.stderr index f8fc17e872bd4..bfd0de4e13acb 100644 --- a/src/tools/clippy/tests/ui/def_id_nocore.stderr +++ b/src/tools/clippy/tests/ui/def_id_nocore.stderr @@ -6,6 +6,7 @@ LL | pub fn as_ref(self) -> &'static str { | = help: consider choosing a less ambiguous name = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/default_constructed_unit_structs.stderr b/src/tools/clippy/tests/ui/default_constructed_unit_structs.stderr index 25128b89f2e9d..434c72aa9b174 100644 --- a/src/tools/clippy/tests/ui/default_constructed_unit_structs.stderr +++ b/src/tools/clippy/tests/ui/default_constructed_unit_structs.stderr @@ -5,6 +5,7 @@ LL | Self::default() | ^^^^^^^^^^^ help: remove this call to `default` | = note: `-D clippy::default-constructed-unit-structs` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::default_constructed_unit_structs)]` error: use of `default` to create a unit struct --> $DIR/default_constructed_unit_structs.rs:53:31 diff --git a/src/tools/clippy/tests/ui/default_instead_of_iter_empty.stderr b/src/tools/clippy/tests/ui/default_instead_of_iter_empty.stderr index 2763ad6120e79..48d6c02d150d8 100644 --- a/src/tools/clippy/tests/ui/default_instead_of_iter_empty.stderr +++ b/src/tools/clippy/tests/ui/default_instead_of_iter_empty.stderr @@ -5,6 +5,7 @@ LL | let _ = std::iter::Empty::::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::()` | = note: `-D clippy::default-instead-of-iter-empty` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::default_instead_of_iter_empty)]` error: `std::iter::empty()` is the more idiomatic way --> $DIR/default_instead_of_iter_empty.rs:13:13 diff --git a/src/tools/clippy/tests/ui/default_numeric_fallback_f64.stderr b/src/tools/clippy/tests/ui/default_numeric_fallback_f64.stderr index 7aa2ad2522852..7ea2e3e681947 100644 --- a/src/tools/clippy/tests/ui/default_numeric_fallback_f64.stderr +++ b/src/tools/clippy/tests/ui/default_numeric_fallback_f64.stderr @@ -5,6 +5,7 @@ LL | let x = 0.12; | ^^^^ help: consider adding suffix: `0.12_f64` | = note: `-D clippy::default-numeric-fallback` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::default_numeric_fallback)]` error: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:22:18 diff --git a/src/tools/clippy/tests/ui/default_numeric_fallback_i32.stderr b/src/tools/clippy/tests/ui/default_numeric_fallback_i32.stderr index 586f4fc0c03da..b03b8b84c3324 100644 --- a/src/tools/clippy/tests/ui/default_numeric_fallback_i32.stderr +++ b/src/tools/clippy/tests/ui/default_numeric_fallback_i32.stderr @@ -5,6 +5,7 @@ LL | let x = 22; | ^^ help: consider adding suffix: `22_i32` | = note: `-D clippy::default-numeric-fallback` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::default_numeric_fallback)]` error: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:22:18 diff --git a/src/tools/clippy/tests/ui/default_union_representation.stderr b/src/tools/clippy/tests/ui/default_union_representation.stderr index 256eebc44200a..82f69ffeec373 100644 --- a/src/tools/clippy/tests/ui/default_union_representation.stderr +++ b/src/tools/clippy/tests/ui/default_union_representation.stderr @@ -10,6 +10,7 @@ LL | | } | = help: consider annotating `NoAttribute` with `#[repr(C)]` to explicitly specify memory layout = note: `-D clippy::default-union-representation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::default_union_representation)]` error: this union has the default representation --> $DIR/default_union_representation.rs:17:1 diff --git a/src/tools/clippy/tests/ui/deprecated.stderr b/src/tools/clippy/tests/ui/deprecated.stderr index 0e142ac8f20e7..388fcc2384668 100644 --- a/src/tools/clippy/tests/ui/deprecated.stderr +++ b/src/tools/clippy/tests/ui/deprecated.stderr @@ -5,6 +5,7 @@ LL | #![warn(clippy::should_assert_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D renamed-and-removed-lints` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `clippy::extend_from_slice` has been removed: `.extend_from_slice(_)` is a faster way to extend a Vec by a slice --> $DIR/deprecated.rs:6:9 diff --git a/src/tools/clippy/tests/ui/deprecated_old.stderr b/src/tools/clippy/tests/ui/deprecated_old.stderr index 5a6c4be80b246..d27ad852f97ff 100644 --- a/src/tools/clippy/tests/ui/deprecated_old.stderr +++ b/src/tools/clippy/tests/ui/deprecated_old.stderr @@ -5,6 +5,7 @@ LL | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ | = note: `-D renamed-and-removed-lints` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 --> $DIR/deprecated_old.rs:4:8 diff --git a/src/tools/clippy/tests/ui/deref_addrof.stderr b/src/tools/clippy/tests/ui/deref_addrof.stderr index 5918a33f38bf0..b01fa4df6b1f5 100644 --- a/src/tools/clippy/tests/ui/deref_addrof.stderr +++ b/src/tools/clippy/tests/ui/deref_addrof.stderr @@ -5,6 +5,7 @@ LL | let b = *&a; | ^^^ help: try: `a` | = note: `-D clippy::deref-addrof` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference --> $DIR/deref_addrof.rs:25:13 diff --git a/src/tools/clippy/tests/ui/deref_addrof_double_trigger.stderr b/src/tools/clippy/tests/ui/deref_addrof_double_trigger.stderr index 3463f0a1ab73e..78ec73400162e 100644 --- a/src/tools/clippy/tests/ui/deref_addrof_double_trigger.stderr +++ b/src/tools/clippy/tests/ui/deref_addrof_double_trigger.stderr @@ -5,6 +5,7 @@ LL | let b = **&&a; | ^^^^ help: try: `&a` | = note: `-D clippy::deref-addrof` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference --> $DIR/deref_addrof_double_trigger.rs:16:17 diff --git a/src/tools/clippy/tests/ui/deref_by_slicing.stderr b/src/tools/clippy/tests/ui/deref_by_slicing.stderr index b22c18c492db2..7b8144a9a6e19 100644 --- a/src/tools/clippy/tests/ui/deref_by_slicing.stderr +++ b/src/tools/clippy/tests/ui/deref_by_slicing.stderr @@ -5,6 +5,7 @@ LL | let _ = &vec[..]; | ^^^^^^^^ help: dereference the original value instead: `&*vec` | = note: `-D clippy::deref-by-slicing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deref_by_slicing)]` error: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:9:13 diff --git a/src/tools/clippy/tests/ui/derivable_impls.stderr b/src/tools/clippy/tests/ui/derivable_impls.stderr index b05af79e3fd6c..98e2f3612904a 100644 --- a/src/tools/clippy/tests/ui/derivable_impls.stderr +++ b/src/tools/clippy/tests/ui/derivable_impls.stderr @@ -11,6 +11,7 @@ LL | | } | |_^ | = note: `-D clippy::derivable-impls` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::derivable_impls)]` = help: remove the manual implementation... help: ...and instead derive it | diff --git a/src/tools/clippy/tests/ui/derive.stderr b/src/tools/clippy/tests/ui/derive.stderr index 2986296bcaf77..e9b2ee34760f2 100644 --- a/src/tools/clippy/tests/ui/derive.stderr +++ b/src/tools/clippy/tests/ui/derive.stderr @@ -20,6 +20,7 @@ LL | | } LL | | } | |_^ = note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::expl_impl_clone_on_copy)]` error: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:37:1 diff --git a/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr b/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr index ee900c5ea2762..7555c12b196d9 100644 --- a/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr +++ b/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr @@ -10,6 +10,7 @@ note: `PartialOrd` implemented here LL | impl PartialOrd for DeriveOrd { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::derive-ord-xor-partial-ord` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::derive_ord_xor_partial_ord)]` = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `Ord` but have implemented `PartialOrd` explicitly diff --git a/src/tools/clippy/tests/ui/derive_partial_eq_without_eq.stderr b/src/tools/clippy/tests/ui/derive_partial_eq_without_eq.stderr index 91729abc2bbbe..abfd70e8c3d50 100644 --- a/src/tools/clippy/tests/ui/derive_partial_eq_without_eq.stderr +++ b/src/tools/clippy/tests/ui/derive_partial_eq_without_eq.stderr @@ -5,6 +5,7 @@ LL | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = note: `-D clippy::derive-partial-eq-without-eq` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::derive_partial_eq_without_eq)]` error: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:53:10 diff --git a/src/tools/clippy/tests/ui/disallowed_names.stderr b/src/tools/clippy/tests/ui/disallowed_names.stderr index 259501a94e78c..3387906a0e5c2 100644 --- a/src/tools/clippy/tests/ui/disallowed_names.stderr +++ b/src/tools/clippy/tests/ui/disallowed_names.stderr @@ -5,6 +5,7 @@ LL | fn test(foo: ()) {} | ^^^ | = note: `-D clippy::disallowed-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `foo` --> $DIR/disallowed_names.rs:17:9 diff --git a/src/tools/clippy/tests/ui/diverging_sub_expression.stderr b/src/tools/clippy/tests/ui/diverging_sub_expression.stderr index 042e2690ec41e..d8021c5d7ba83 100644 --- a/src/tools/clippy/tests/ui/diverging_sub_expression.stderr +++ b/src/tools/clippy/tests/ui/diverging_sub_expression.stderr @@ -5,6 +5,7 @@ LL | b || diverge(); | ^^^^^^^^^ | = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:23:10 diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.stderr b/src/tools/clippy/tests/ui/doc/doc-fixable.stderr index dda764f8493bc..a30ded81385f1 100644 --- a/src/tools/clippy/tests/ui/doc/doc-fixable.stderr +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.stderr @@ -5,6 +5,7 @@ LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot t | ^^^^^^^ | = note: `-D clippy::doc-markdown` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` help: try | LL | /// The `foo_bar` function does _nothing_. See also foo::bar. (note the dot there) diff --git a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr index 7a3544288be85..92b6f8536c88b 100644 --- a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr +++ b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr @@ -10,6 +10,7 @@ LL | | /// very `confusing_and_misleading`. | = help: a backtick may be missing a pair = note: `-D clippy::doc-markdown` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` error: backticks are unbalanced --> $DIR/unbalanced_ticks.rs:14:1 diff --git a/src/tools/clippy/tests/ui/doc_errors.stderr b/src/tools/clippy/tests/ui/doc_errors.stderr index a0356623003e8..9cea864f1d867 100644 --- a/src/tools/clippy/tests/ui/doc_errors.stderr +++ b/src/tools/clippy/tests/ui/doc_errors.stderr @@ -5,6 +5,7 @@ LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-errors-doc` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_errors_doc)]` error: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:13:1 diff --git a/src/tools/clippy/tests/ui/doc_link_with_quotes.stderr b/src/tools/clippy/tests/ui/doc_link_with_quotes.stderr index ea730e667d65b..2db1bc0928953 100644 --- a/src/tools/clippy/tests/ui/doc_link_with_quotes.stderr +++ b/src/tools/clippy/tests/ui/doc_link_with_quotes.stderr @@ -5,6 +5,7 @@ LL | /// Calls ['bar'] uselessly | ^^^^^ | = note: `-D clippy::doc-link-with-quotes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::doc_link_with_quotes)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/doc_unsafe.stderr b/src/tools/clippy/tests/ui/doc_unsafe.stderr index a86e191370e3e..ab3fb3c029dd3 100644 --- a/src/tools/clippy/tests/ui/doc_unsafe.stderr +++ b/src/tools/clippy/tests/ui/doc_unsafe.stderr @@ -5,6 +5,7 @@ LL | pub unsafe fn destroy_the_planet() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-safety-doc` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_safety_doc)]` error: unsafe function's docs miss `# Safety` section --> $DIR/doc_unsafe.rs:32:5 diff --git a/src/tools/clippy/tests/ui/double_comparison.stderr b/src/tools/clippy/tests/ui/double_comparison.stderr index 05ef4e25f7f87..02f0a960974b8 100644 --- a/src/tools/clippy/tests/ui/double_comparison.stderr +++ b/src/tools/clippy/tests/ui/double_comparison.stderr @@ -5,6 +5,7 @@ LL | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` | = note: `-D clippy::double-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::double_comparisons)]` error: this binary expression can be simplified --> $DIR/double_comparison.rs:9:8 diff --git a/src/tools/clippy/tests/ui/double_must_use.stderr b/src/tools/clippy/tests/ui/double_must_use.stderr index 46d56006ebfce..a2d87c59ecf8a 100644 --- a/src/tools/clippy/tests/ui/double_must_use.stderr +++ b/src/tools/clippy/tests/ui/double_must_use.stderr @@ -6,6 +6,7 @@ LL | pub fn must_use_result() -> Result<(), ()> { | = help: either add some descriptive text or remove the attribute = note: `-D clippy::double-must-use` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]` error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` --> $DIR/double_must_use.rs:11:1 diff --git a/src/tools/clippy/tests/ui/double_neg.stderr b/src/tools/clippy/tests/ui/double_neg.stderr index 7cdb040b68739..a6241c78610a7 100644 --- a/src/tools/clippy/tests/ui/double_neg.stderr +++ b/src/tools/clippy/tests/ui/double_neg.stderr @@ -5,6 +5,7 @@ LL | --x; | ^^^ | = note: `-D clippy::double-neg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::double_neg)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/double_parens.stderr b/src/tools/clippy/tests/ui/double_parens.stderr index 303ddce024837..8a010d8ccc045 100644 --- a/src/tools/clippy/tests/ui/double_parens.stderr +++ b/src/tools/clippy/tests/ui/double_parens.stderr @@ -5,6 +5,7 @@ LL | ((0)) | ^^^^^ | = note: `-D clippy::double-parens` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::double_parens)]` error: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:21:14 diff --git a/src/tools/clippy/tests/ui/drop_non_drop.stderr b/src/tools/clippy/tests/ui/drop_non_drop.stderr index 15e7c6eeca276..a571076f68cd2 100644 --- a/src/tools/clippy/tests/ui/drop_non_drop.stderr +++ b/src/tools/clippy/tests/ui/drop_non_drop.stderr @@ -10,6 +10,7 @@ note: argument has type `main::Foo` LL | drop(Foo); | ^^^ = note: `-D clippy::drop-non-drop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::drop_non_drop)]` error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes --> $DIR/drop_non_drop.rs:38:5 diff --git a/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr b/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr index f71614a5fd16e..f47f6c89622d1 100644 --- a/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr +++ b/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr @@ -5,6 +5,7 @@ LL | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | = note: `-D clippy::duplicate-underscore-argument` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::duplicate_underscore_argument)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/duration_subsec.stderr b/src/tools/clippy/tests/ui/duration_subsec.stderr index 6c1fd433e7cc9..705683837123e 100644 --- a/src/tools/clippy/tests/ui/duration_subsec.stderr +++ b/src/tools/clippy/tests/ui/duration_subsec.stderr @@ -5,6 +5,7 @@ LL | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` | = note: `-D clippy::duration-subsec` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::duration_subsec)]` error: calling `subsec_millis()` is more concise than this calculation --> $DIR/duration_subsec.rs:10:24 diff --git a/src/tools/clippy/tests/ui/else_if_without_else.stderr b/src/tools/clippy/tests/ui/else_if_without_else.stderr index 11baf75441ae2..b2bf4ac4d1b12 100644 --- a/src/tools/clippy/tests/ui/else_if_without_else.stderr +++ b/src/tools/clippy/tests/ui/else_if_without_else.stderr @@ -10,6 +10,7 @@ LL | | } | = help: add an `else` block here = note: `-D clippy::else-if-without-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::else_if_without_else)]` error: `if` expression with an `else if`, but without a final `else` --> $DIR/else_if_without_else.rs:54:12 diff --git a/src/tools/clippy/tests/ui/empty_drop.stderr b/src/tools/clippy/tests/ui/empty_drop.stderr index e952169372637..5848eab744740 100644 --- a/src/tools/clippy/tests/ui/empty_drop.stderr +++ b/src/tools/clippy/tests/ui/empty_drop.stderr @@ -7,6 +7,7 @@ LL | | } | |_^ help: try removing this impl | = note: `-D clippy::empty-drop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_drop)]` error: empty drop implementation --> $DIR/empty_drop.rs:23:1 diff --git a/src/tools/clippy/tests/ui/empty_enum.stderr b/src/tools/clippy/tests/ui/empty_enum.stderr index 0d9aa5818e28d..92d81c7269a53 100644 --- a/src/tools/clippy/tests/ui/empty_enum.stderr +++ b/src/tools/clippy/tests/ui/empty_enum.stderr @@ -6,6 +6,7 @@ LL | enum Empty {} | = help: consider using the uninhabited type `!` (never type) or a wrapper around it to introduce a type which can't be instantiated = note: `-D clippy::empty-enum` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_enum)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/empty_line_after_doc_comments.stderr b/src/tools/clippy/tests/ui/empty_line_after_doc_comments.stderr index 2ca1b51679ed1..2cf5b5b0f5494 100644 --- a/src/tools/clippy/tests/ui/empty_line_after_doc_comments.stderr +++ b/src/tools/clippy/tests/ui/empty_line_after_doc_comments.stderr @@ -7,6 +7,7 @@ LL | | fn with_doc_and_newline() { assert!(true)} | |_ | = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]` error: found an empty line after a doc comment. Perhaps you need to use `//!` to make a comment on a module, remove the empty line, or make a regular comment with `//`? --> $DIR/empty_line_after_doc_comments.rs:68:1 diff --git a/src/tools/clippy/tests/ui/empty_line_after_outer_attribute.stderr b/src/tools/clippy/tests/ui/empty_line_after_outer_attribute.stderr index 594fca44a3210..0cb848c20dde7 100644 --- a/src/tools/clippy/tests/ui/empty_line_after_outer_attribute.stderr +++ b/src/tools/clippy/tests/ui/empty_line_after_outer_attribute.stderr @@ -8,6 +8,7 @@ LL | | fn with_one_newline_and_comment() { assert!(true) } | |_ | = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]` 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:23:1 diff --git a/src/tools/clippy/tests/ui/empty_loop.stderr b/src/tools/clippy/tests/ui/empty_loop.stderr index 7602412334bbf..84d7d61c7daa8 100644 --- a/src/tools/clippy/tests/ui/empty_loop.stderr +++ b/src/tools/clippy/tests/ui/empty_loop.stderr @@ -6,6 +6,7 @@ LL | loop {} | = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body = note: `-D clippy::empty-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop.rs:11:9 diff --git a/src/tools/clippy/tests/ui/empty_loop_no_std.stderr b/src/tools/clippy/tests/ui/empty_loop_no_std.stderr index 417b7f01c78a9..90200826472b1 100644 --- a/src/tools/clippy/tests/ui/empty_loop_no_std.stderr +++ b/src/tools/clippy/tests/ui/empty_loop_no_std.stderr @@ -6,6 +6,7 @@ LL | loop {} | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = note: `-D clippy::empty-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop_no_std.rs:26:5 diff --git a/src/tools/clippy/tests/ui/empty_structs_with_brackets.stderr b/src/tools/clippy/tests/ui/empty_structs_with_brackets.stderr index ba3013750d56b..4b8572d5c9ef6 100644 --- a/src/tools/clippy/tests/ui/empty_structs_with_brackets.stderr +++ b/src/tools/clippy/tests/ui/empty_structs_with_brackets.stderr @@ -5,6 +5,7 @@ LL | pub struct MyEmptyStruct {} // should trigger lint | ^^^ | = note: `-D clippy::empty-structs-with-brackets` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_structs_with_brackets)]` = help: remove the brackets error: found empty brackets on struct declaration diff --git a/src/tools/clippy/tests/ui/endian_bytes.stderr b/src/tools/clippy/tests/ui/endian_bytes.stderr index 5e64ea5b5ab8b..a458c46fa69ac 100644 --- a/src/tools/clippy/tests/ui/endian_bytes.stderr +++ b/src/tools/clippy/tests/ui/endian_bytes.stderr @@ -9,6 +9,7 @@ LL | fn host() { fn_body!(); } | = help: specify the desired endianness explicitly = note: `-D clippy::host-endian-bytes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::host_endian_bytes)]` = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i8::to_ne_bytes` method @@ -346,6 +347,7 @@ LL | fn little() { fn_body!(); } | = help: use the native endianness instead = note: `-D clippy::little-endian-bytes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::little_endian_bytes)]` = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i8::to_le_bytes` method @@ -707,6 +709,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } | = help: use `u8::to_le_bytes` instead = note: `-D clippy::big-endian-bytes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::big_endian_bytes)]` = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_be_bytes` diff --git a/src/tools/clippy/tests/ui/entry.stderr b/src/tools/clippy/tests/ui/entry.stderr index e89d15cc1af70..b01f0a9a0e56b 100644 --- a/src/tools/clippy/tests/ui/entry.stderr +++ b/src/tools/clippy/tests/ui/entry.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: try: `m.entry(k).or_insert(v);` | = note: `-D clippy::map-entry` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_entry)]` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:29:5 diff --git a/src/tools/clippy/tests/ui/entry_btree.stderr b/src/tools/clippy/tests/ui/entry_btree.stderr index e5a1365eae93c..cc0e951d9b421 100644 --- a/src/tools/clippy/tests/ui/entry_btree.stderr +++ b/src/tools/clippy/tests/ui/entry_btree.stderr @@ -8,6 +8,7 @@ LL | | } | |_____^ | = note: `-D clippy::map-entry` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_entry)]` help: try | LL ~ if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) { diff --git a/src/tools/clippy/tests/ui/entry_with_else.stderr b/src/tools/clippy/tests/ui/entry_with_else.stderr index a0f39568708c0..425e87122d57f 100644 --- a/src/tools/clippy/tests/ui/entry_with_else.stderr +++ b/src/tools/clippy/tests/ui/entry_with_else.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::map-entry` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_entry)]` help: try | LL ~ match m.entry(k) { diff --git a/src/tools/clippy/tests/ui/enum_glob_use.stderr b/src/tools/clippy/tests/ui/enum_glob_use.stderr index c1851f92765b8..8b94e67f87ea3 100644 --- a/src/tools/clippy/tests/ui/enum_glob_use.stderr +++ b/src/tools/clippy/tests/ui/enum_glob_use.stderr @@ -5,6 +5,7 @@ LL | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::cmp::Ordering::Less` | = note: `-D clippy::enum-glob-use` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::enum_glob_use)]` error: usage of wildcard import for enum variants --> $DIR/enum_glob_use.rs:11:5 diff --git a/src/tools/clippy/tests/ui/enum_variants.stderr b/src/tools/clippy/tests/ui/enum_variants.stderr index 1cfe48cd797f9..9ea80b635f462 100644 --- a/src/tools/clippy/tests/ui/enum_variants.stderr +++ b/src/tools/clippy/tests/ui/enum_variants.stderr @@ -5,6 +5,7 @@ LL | cFoo, | ^^^^ | = note: `-D clippy::enum-variant-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::enum_variant_names)]` error: all variants have the same prefix: `c` --> $DIR/enum_variants.rs:14:1 diff --git a/src/tools/clippy/tests/ui/eprint_with_newline.stderr b/src/tools/clippy/tests/ui/eprint_with_newline.stderr index 934c4c8317314..674b4fdaed50e 100644 --- a/src/tools/clippy/tests/ui/eprint_with_newline.stderr +++ b/src/tools/clippy/tests/ui/eprint_with_newline.stderr @@ -5,6 +5,7 @@ LL | eprint!("Hello\n"); | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-with-newline` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_with_newline)]` help: use `eprintln!` instead | LL - eprint!("Hello\n"); diff --git a/src/tools/clippy/tests/ui/eq_op.stderr b/src/tools/clippy/tests/ui/eq_op.stderr index 315d94cc90e62..2427ac0dda55f 100644 --- a/src/tools/clippy/tests/ui/eq_op.stderr +++ b/src/tools/clippy/tests/ui/eq_op.stderr @@ -5,6 +5,7 @@ LL | let _ = 1 == 1; | ^^^^^^ | = note: `-D clippy::eq-op` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::eq_op)]` error: equal expressions as operands to `==` --> $DIR/eq_op.rs:10:13 diff --git a/src/tools/clippy/tests/ui/eq_op_macros.stderr b/src/tools/clippy/tests/ui/eq_op_macros.stderr index 3c60cdbc5ca95..0df26607aa6e8 100644 --- a/src/tools/clippy/tests/ui/eq_op_macros.stderr +++ b/src/tools/clippy/tests/ui/eq_op_macros.stderr @@ -8,6 +8,7 @@ LL | assert_in_macro_def!(); | ---------------------- in this macro invocation | = note: `-D clippy::eq-op` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::eq_op)]` = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: identical args used in this `assert_ne!` macro call diff --git a/src/tools/clippy/tests/ui/equatable_if_let.stderr b/src/tools/clippy/tests/ui/equatable_if_let.stderr index 3b6cbbabbe2ba..6cc19d829edc7 100644 --- a/src/tools/clippy/tests/ui/equatable_if_let.stderr +++ b/src/tools/clippy/tests/ui/equatable_if_let.stderr @@ -5,6 +5,7 @@ LL | if let 2 = a {} | ^^^^^^^^^ help: try: `a == 2` | = note: `-D clippy::equatable-if-let` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::equatable_if_let)]` error: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:65:8 diff --git a/src/tools/clippy/tests/ui/erasing_op.stderr b/src/tools/clippy/tests/ui/erasing_op.stderr index 7b9608fe45228..1b50a05cd228d 100644 --- a/src/tools/clippy/tests/ui/erasing_op.stderr +++ b/src/tools/clippy/tests/ui/erasing_op.stderr @@ -5,6 +5,7 @@ LL | x * 0; | ^^^^^ | = note: `-D clippy::erasing-op` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::erasing_op)]` error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:38:5 diff --git a/src/tools/clippy/tests/ui/err_expect.stderr b/src/tools/clippy/tests/ui/err_expect.stderr index e3046a5a13a76..da7cd47f0bb49 100644 --- a/src/tools/clippy/tests/ui/err_expect.stderr +++ b/src/tools/clippy/tests/ui/err_expect.stderr @@ -5,6 +5,7 @@ LL | test_debug.err().expect("Testing debug type"); | ^^^^^^^^^^^^ help: try: `expect_err` | = note: `-D clippy::err-expect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::err_expect)]` error: called `.err().expect()` on a `Result` value --> $DIR/err_expect.rs:25:7 diff --git a/src/tools/clippy/tests/ui/error_impl_error.stderr b/src/tools/clippy/tests/ui/error_impl_error.stderr index 54a55d5dcf4b1..d7a1aa829890c 100644 --- a/src/tools/clippy/tests/ui/error_impl_error.stderr +++ b/src/tools/clippy/tests/ui/error_impl_error.stderr @@ -10,6 +10,7 @@ note: `Error` was implemented here LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::error-impl-error` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::error_impl_error)]` error: exported type named `Error` that implements `Error` --> $DIR/error_impl_error.rs:21:21 diff --git a/src/tools/clippy/tests/ui/eta.stderr b/src/tools/clippy/tests/ui/eta.stderr index db6184e36a430..7c7f179746205 100644 --- a/src/tools/clippy/tests/ui/eta.stderr +++ b/src/tools/clippy/tests/ui/eta.stderr @@ -5,6 +5,7 @@ LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: replace the closure with the function itself: `foo` | = note: `-D clippy::redundant-closure` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: redundant closure --> $DIR/eta.rs:32:40 @@ -37,6 +38,7 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo` | = note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_for_method_calls)]` error: redundant closure --> $DIR/eta.rs:94:51 diff --git a/src/tools/clippy/tests/ui/excessive_precision.stderr b/src/tools/clippy/tests/ui/excessive_precision.stderr index a1f874e93d44b..5e7672e185af3 100644 --- a/src/tools/clippy/tests/ui/excessive_precision.stderr +++ b/src/tools/clippy/tests/ui/excessive_precision.stderr @@ -5,6 +5,7 @@ LL | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79_f32` | = note: `-D clippy::excessive-precision` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::excessive_precision)]` error: float has excessive precision --> $DIR/excessive_precision.rs:21:26 diff --git a/src/tools/clippy/tests/ui/exit1.stderr b/src/tools/clippy/tests/ui/exit1.stderr index a8d3956aa27a0..94d8f1e32ee13 100644 --- a/src/tools/clippy/tests/ui/exit1.stderr +++ b/src/tools/clippy/tests/ui/exit1.stderr @@ -5,6 +5,7 @@ LL | std::process::exit(4); | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::exit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::exit)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/exit2.stderr b/src/tools/clippy/tests/ui/exit2.stderr index 7263e156a9d26..cd324f182205e 100644 --- a/src/tools/clippy/tests/ui/exit2.stderr +++ b/src/tools/clippy/tests/ui/exit2.stderr @@ -5,6 +5,7 @@ LL | std::process::exit(3); | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::exit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::exit)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/expect.stderr b/src/tools/clippy/tests/ui/expect.stderr index c9a29624d530a..35a258a85e4e9 100644 --- a/src/tools/clippy/tests/ui/expect.stderr +++ b/src/tools/clippy/tests/ui/expect.stderr @@ -6,6 +6,7 @@ LL | let _ = opt.expect(""); | = note: if this value is `None`, it will panic = note: `-D clippy::expect-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value --> $DIR/expect.rs:12:13 diff --git a/src/tools/clippy/tests/ui/expect_fun_call.stderr b/src/tools/clippy/tests/ui/expect_fun_call.stderr index b5ab580ad000f..dd3976f3624c6 100644 --- a/src/tools/clippy/tests/ui/expect_fun_call.stderr +++ b/src/tools/clippy/tests/ui/expect_fun_call.stderr @@ -5,6 +5,7 @@ LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` | = note: `-D clippy::expect-fun-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::expect_fun_call)]` error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:40:26 diff --git a/src/tools/clippy/tests/ui/expect_tool_lint_rfc_2383.stderr b/src/tools/clippy/tests/ui/expect_tool_lint_rfc_2383.stderr index 1a08d77113a40..3f8d0b7243620 100644 --- a/src/tools/clippy/tests/ui/expect_tool_lint_rfc_2383.stderr +++ b/src/tools/clippy/tests/ui/expect_tool_lint_rfc_2383.stderr @@ -5,6 +5,7 @@ LL | #[expect(dead_code)] | ^^^^^^^^^ | = note: `-D unfulfilled-lint-expectations` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]` error: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:41:18 diff --git a/src/tools/clippy/tests/ui/explicit_auto_deref.stderr b/src/tools/clippy/tests/ui/explicit_auto_deref.stderr index 34ce188530c31..bea014d8ad555 100644 --- a/src/tools/clippy/tests/ui/explicit_auto_deref.stderr +++ b/src/tools/clippy/tests/ui/explicit_auto_deref.stderr @@ -5,6 +5,7 @@ LL | let _: &str = &*s; | ^^^ help: try: `&s` | = note: `-D clippy::explicit-auto-deref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::explicit_auto_deref)]` error: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:69:19 diff --git a/src/tools/clippy/tests/ui/explicit_counter_loop.stderr b/src/tools/clippy/tests/ui/explicit_counter_loop.stderr index 3b36f28617bb0..aef979072525b 100644 --- a/src/tools/clippy/tests/ui/explicit_counter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_counter_loop.stderr @@ -5,6 +5,7 @@ LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` | = note: `-D clippy::explicit-counter-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::explicit_counter_loop)]` error: the variable `_index` is used as a loop counter --> $DIR/explicit_counter_loop.rs:15:5 diff --git a/src/tools/clippy/tests/ui/explicit_deref_methods.stderr b/src/tools/clippy/tests/ui/explicit_deref_methods.stderr index 362e559b21a57..eb7059367a203 100644 --- a/src/tools/clippy/tests/ui/explicit_deref_methods.stderr +++ b/src/tools/clippy/tests/ui/explicit_deref_methods.stderr @@ -5,6 +5,7 @@ LL | let b: &str = a.deref(); | ^^^^^^^^^ help: try: `&*a` | = note: `-D clippy::explicit-deref-methods` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::explicit_deref_methods)]` error: explicit `deref_mut` method call --> $DIR/explicit_deref_methods.rs:56:23 diff --git a/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr b/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr index 744be093b7b84..c03647ab43367 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr @@ -5,6 +5,7 @@ LL | for _ in iterator.into_iter() {} | ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator` | = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::explicit_into_iter_loop)]` error: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/explicit_into_iter_loop.rs:22:14 diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.stderr b/src/tools/clippy/tests/ui/explicit_iter_loop.stderr index c311096117f60..af46d74e989af 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.stderr @@ -53,6 +53,7 @@ LL | for _ in (&mut [1, 2, 3]).iter() {} | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]` error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/explicit_iter_loop.rs:33:14 diff --git a/src/tools/clippy/tests/ui/explicit_write.stderr b/src/tools/clippy/tests/ui/explicit_write.stderr index 230762c2db178..26aad266bbfc4 100644 --- a/src/tools/clippy/tests/ui/explicit_write.stderr +++ b/src/tools/clippy/tests/ui/explicit_write.stderr @@ -5,6 +5,7 @@ LL | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")` | = note: `-D clippy::explicit-write` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::explicit_write)]` error: use of `write!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:24:9 diff --git a/src/tools/clippy/tests/ui/extend_with_drain.stderr b/src/tools/clippy/tests/ui/extend_with_drain.stderr index 2c06d71e10202..e0bd5a620e78f 100644 --- a/src/tools/clippy/tests/ui/extend_with_drain.stderr +++ b/src/tools/clippy/tests/ui/extend_with_drain.stderr @@ -5,6 +5,7 @@ LL | vec2.extend(vec1.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec2.append(&mut vec1)` | = note: `-D clippy::extend-with-drain` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::extend_with_drain)]` error: use of `extend` instead of `append` for adding the full range of a second vector --> $DIR/extend_with_drain.rs:13:5 diff --git a/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr b/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr index 26ebc3976dfca..8790fe5a5b1a5 100644 --- a/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr +++ b/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr @@ -5,6 +5,7 @@ LL | fn unused_lt<'a>(x: u8) {} | ^^ | = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::extra_unused_lifetimes)]` error: this lifetime isn't used in the function definition --> $DIR/extra_unused_lifetimes.rs:46:10 diff --git a/src/tools/clippy/tests/ui/extra_unused_type_parameters.stderr b/src/tools/clippy/tests/ui/extra_unused_type_parameters.stderr index 82cdc95a1d15f..9a179076c4824 100644 --- a/src/tools/clippy/tests/ui/extra_unused_type_parameters.stderr +++ b/src/tools/clippy/tests/ui/extra_unused_type_parameters.stderr @@ -5,6 +5,7 @@ LL | fn unused_ty(x: u8) { | ^^^ help: consider removing the parameter | = note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::extra_unused_type_parameters)]` error: type parameters go unused in function definition: T, U --> $DIR/extra_unused_type_parameters.rs:13:16 diff --git a/src/tools/clippy/tests/ui/extra_unused_type_parameters_unfixable.stderr b/src/tools/clippy/tests/ui/extra_unused_type_parameters_unfixable.stderr index bbd0cf478ab3c..a216c4363075f 100644 --- a/src/tools/clippy/tests/ui/extra_unused_type_parameters_unfixable.stderr +++ b/src/tools/clippy/tests/ui/extra_unused_type_parameters_unfixable.stderr @@ -6,6 +6,7 @@ LL | fn unused_where_clause(x: U) | = help: consider removing the parameter = note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::extra_unused_type_parameters)]` error: type parameters go unused in function definition: T, V --> $DIR/extra_unused_type_parameters_unfixable.rs:11:30 diff --git a/src/tools/clippy/tests/ui/field_reassign_with_default.stderr b/src/tools/clippy/tests/ui/field_reassign_with_default.stderr index da74f9ef9f7ee..a8cf84bd4114a 100644 --- a/src/tools/clippy/tests/ui/field_reassign_with_default.stderr +++ b/src/tools/clippy/tests/ui/field_reassign_with_default.stderr @@ -10,6 +10,7 @@ note: consider initializing the variable with `main::A { i: 42, ..Default::defau LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::field-reassign-with-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::field_reassign_with_default)]` error: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:96:5 diff --git a/src/tools/clippy/tests/ui/filetype_is_file.stderr b/src/tools/clippy/tests/ui/filetype_is_file.stderr index 718d287e6799f..8876ad5c9bbce 100644 --- a/src/tools/clippy/tests/ui/filetype_is_file.stderr +++ b/src/tools/clippy/tests/ui/filetype_is_file.stderr @@ -6,6 +6,7 @@ LL | if fs::metadata("foo.txt")?.file_type().is_file() { | = help: use `!FileType::is_dir()` instead = note: `-D clippy::filetype-is-file` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filetype_is_file)]` error: `!FileType::is_file()` only denies regular files --> $DIR/filetype_is_file.rs:15:8 diff --git a/src/tools/clippy/tests/ui/filter_map_bool_then.stderr b/src/tools/clippy/tests/ui/filter_map_bool_then.stderr index c4215791c46fb..86ef6edf8eeda 100644 --- a/src/tools/clippy/tests/ui/filter_map_bool_then.stderr +++ b/src/tools/clippy/tests/ui/filter_map_bool_then.stderr @@ -5,6 +5,7 @@ LL | v.clone().iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` | = note: `-D clippy::filter-map-bool-then` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_map_bool_then)]` error: usage of `bool::then` in `filter_map` --> $DIR/filter_map_bool_then.rs:20:27 diff --git a/src/tools/clippy/tests/ui/filter_map_identity.stderr b/src/tools/clippy/tests/ui/filter_map_identity.stderr index 248f6318f76ab..a08477695c931 100644 --- a/src/tools/clippy/tests/ui/filter_map_identity.stderr +++ b/src/tools/clippy/tests/ui/filter_map_identity.stderr @@ -5,6 +5,7 @@ LL | let _ = iterator.filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` | = note: `-D clippy::filter-map-identity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_map_identity)]` error: use of `filter_map` with an identity function --> $DIR/filter_map_identity.rs:9:22 diff --git a/src/tools/clippy/tests/ui/filter_map_next.stderr b/src/tools/clippy/tests/ui/filter_map_next.stderr index 3220ee51c2ac9..1841553917ff5 100644 --- a/src/tools/clippy/tests/ui/filter_map_next.stderr +++ b/src/tools/clippy/tests/ui/filter_map_next.stderr @@ -12,6 +12,7 @@ LL | | .next(); | |_______________^ | = note: `-D clippy::filter-map-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_map_next)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/filter_map_next_fixable.stderr b/src/tools/clippy/tests/ui/filter_map_next_fixable.stderr index fcbdbc31f3533..0edf4e6e07d46 100644 --- a/src/tools/clippy/tests/ui/filter_map_next_fixable.stderr +++ b/src/tools/clippy/tests/ui/filter_map_next_fixable.stderr @@ -5,6 +5,7 @@ LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())` | = note: `-D clippy::filter-map-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_map_next)]` error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead --> $DIR/filter_map_next_fixable.rs:20:26 diff --git a/src/tools/clippy/tests/ui/flat_map_identity.stderr b/src/tools/clippy/tests/ui/flat_map_identity.stderr index 6e4637874acef..d6fcc14fc5630 100644 --- a/src/tools/clippy/tests/ui/flat_map_identity.stderr +++ b/src/tools/clippy/tests/ui/flat_map_identity.stderr @@ -5,6 +5,7 @@ LL | let _ = iterator.flat_map(|x| x); | ^^^^^^^^^^^^^^^ help: try: `flatten()` | = note: `-D clippy::flat-map-identity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::flat_map_identity)]` error: use of `flat_map` with an identity function --> $DIR/flat_map_identity.rs:11:22 diff --git a/src/tools/clippy/tests/ui/flat_map_option.stderr b/src/tools/clippy/tests/ui/flat_map_option.stderr index c750902eb2fdb..e0a59daf6a8f8 100644 --- a/src/tools/clippy/tests/ui/flat_map_option.stderr +++ b/src/tools/clippy/tests/ui/flat_map_option.stderr @@ -5,6 +5,7 @@ LL | let _ = [1].iter().flat_map(c); | ^^^^^^^^ help: try: `filter_map` | = note: `-D clippy::flat-map-option` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::flat_map_option)]` error: used `flat_map` where `filter_map` could be used instead --> $DIR/flat_map_option.rs:8:24 diff --git a/src/tools/clippy/tests/ui/float_arithmetic.stderr b/src/tools/clippy/tests/ui/float_arithmetic.stderr index fe8446c98167a..da4ca976792f5 100644 --- a/src/tools/clippy/tests/ui/float_arithmetic.stderr +++ b/src/tools/clippy/tests/ui/float_arithmetic.stderr @@ -5,6 +5,7 @@ LL | f * 2.0; | ^^^^^^^ | = note: `-D clippy::float-arithmetic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::float_arithmetic)]` error: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:19:5 diff --git a/src/tools/clippy/tests/ui/float_cmp.stderr b/src/tools/clippy/tests/ui/float_cmp.stderr index 5836b5603d6eb..cbe529954d0c2 100644 --- a/src/tools/clippy/tests/ui/float_cmp.stderr +++ b/src/tools/clippy/tests/ui/float_cmp.stderr @@ -6,6 +6,7 @@ LL | ONE as f64 != 2.0; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `-D clippy::float-cmp` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::float_cmp)]` error: strict comparison of `f32` or `f64` --> $DIR/float_cmp.rs:64:5 diff --git a/src/tools/clippy/tests/ui/float_cmp_const.stderr b/src/tools/clippy/tests/ui/float_cmp_const.stderr index 4de1d58adc0f3..856aaa2ea716d 100644 --- a/src/tools/clippy/tests/ui/float_cmp_const.stderr +++ b/src/tools/clippy/tests/ui/float_cmp_const.stderr @@ -6,6 +6,7 @@ LL | 1f32 == ONE; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `-D clippy::float-cmp-const` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::float_cmp_const)]` error: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:19:5 diff --git a/src/tools/clippy/tests/ui/float_equality_without_abs.stderr b/src/tools/clippy/tests/ui/float_equality_without_abs.stderr index c9806019f1fa7..155699f6fcf0e 100644 --- a/src/tools/clippy/tests/ui/float_equality_without_abs.stderr +++ b/src/tools/clippy/tests/ui/float_equality_without_abs.stderr @@ -7,6 +7,7 @@ LL | (a - b) < f32::EPSILON | help: add `.abs()`: `(a - b).abs()` | = note: `-D clippy::float-equality-without-abs` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::float_equality_without_abs)]` error: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:15:13 diff --git a/src/tools/clippy/tests/ui/floating_point_abs.stderr b/src/tools/clippy/tests/ui/floating_point_abs.stderr index 464a0af5f9f59..fbc5783824d6f 100644 --- a/src/tools/clippy/tests/ui/floating_point_abs.stderr +++ b/src/tools/clippy/tests/ui/floating_point_abs.stderr @@ -5,6 +5,7 @@ LL | if num >= 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:19:5 diff --git a/src/tools/clippy/tests/ui/floating_point_exp.stderr b/src/tools/clippy/tests/ui/floating_point_exp.stderr index f84eede19872a..6b64b9b600821 100644 --- a/src/tools/clippy/tests/ui/floating_point_exp.stderr +++ b/src/tools/clippy/tests/ui/floating_point_exp.stderr @@ -5,6 +5,7 @@ LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` | = note: `-D clippy::imprecise-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: (e.pow(x) - 1) can be computed more accurately --> $DIR/floating_point_exp.rs:7:13 diff --git a/src/tools/clippy/tests/ui/floating_point_hypot.stderr b/src/tools/clippy/tests/ui/floating_point_hypot.stderr index 82b0ed31204ce..21e0bd8b5810f 100644 --- a/src/tools/clippy/tests/ui/floating_point_hypot.stderr +++ b/src/tools/clippy/tests/ui/floating_point_hypot.stderr @@ -5,6 +5,7 @@ LL | let _ = (x * x + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` | = note: `-D clippy::imprecise-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: hypotenuse can be computed more accurately --> $DIR/floating_point_hypot.rs:7:13 diff --git a/src/tools/clippy/tests/ui/floating_point_log.stderr b/src/tools/clippy/tests/ui/floating_point_log.stderr index cbadd239aa2fb..a426f4c3dde81 100644 --- a/src/tools/clippy/tests/ui/floating_point_log.stderr +++ b/src/tools/clippy/tests/ui/floating_point_log.stderr @@ -5,6 +5,7 @@ LL | let _ = x.log(2f32); | ^^^^^^^^^^^ help: consider using: `x.log2()` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:10:13 @@ -61,6 +62,7 @@ LL | let _ = (1f32 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` | = note: `-D clippy::imprecise-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:25:13 diff --git a/src/tools/clippy/tests/ui/floating_point_logbase.stderr b/src/tools/clippy/tests/ui/floating_point_logbase.stderr index 384e3554cbbe1..463bdb84c1595 100644 --- a/src/tools/clippy/tests/ui/floating_point_logbase.stderr +++ b/src/tools/clippy/tests/ui/floating_point_logbase.stderr @@ -5,6 +5,7 @@ LL | let _ = x.ln() / y.ln(); | ^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: log base can be expressed more clearly --> $DIR/floating_point_logbase.rs:8:13 diff --git a/src/tools/clippy/tests/ui/floating_point_mul_add.stderr b/src/tools/clippy/tests/ui/floating_point_mul_add.stderr index 613954724a5bb..81b7126db54d4 100644 --- a/src/tools/clippy/tests/ui/floating_point_mul_add.stderr +++ b/src/tools/clippy/tests/ui/floating_point_mul_add.stderr @@ -5,6 +5,7 @@ LL | let _ = a * b + c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:21:13 diff --git a/src/tools/clippy/tests/ui/floating_point_powf.stderr b/src/tools/clippy/tests/ui/floating_point_powf.stderr index e9693de8fc909..0ff8f82d9a7dd 100644 --- a/src/tools/clippy/tests/ui/floating_point_powf.stderr +++ b/src/tools/clippy/tests/ui/floating_point_powf.stderr @@ -5,6 +5,7 @@ LL | let _ = 2f32.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:7:13 @@ -49,6 +50,7 @@ LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` | = note: `-D clippy::imprecise-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: cube-root of a number can be computed more accurately --> $DIR/floating_point_powf.rs:14:13 diff --git a/src/tools/clippy/tests/ui/floating_point_powi.stderr b/src/tools/clippy/tests/ui/floating_point_powi.stderr index d60885e1b9a1e..ddf20ff40ba26 100644 --- a/src/tools/clippy/tests/ui/floating_point_powi.stderr +++ b/src/tools/clippy/tests/ui/floating_point_powi.stderr @@ -5,6 +5,7 @@ LL | let _ = x.powi(2) + y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:10:13 diff --git a/src/tools/clippy/tests/ui/floating_point_rad.stderr b/src/tools/clippy/tests/ui/floating_point_rad.stderr index 914358c98676d..e7b42de04bdfb 100644 --- a/src/tools/clippy/tests/ui/floating_point_rad.stderr +++ b/src/tools/clippy/tests/ui/floating_point_rad.stderr @@ -5,6 +5,7 @@ LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: conversion to degrees can be done more accurately --> $DIR/floating_point_rad.rs:12:13 diff --git a/src/tools/clippy/tests/ui/fn_address_comparisons.stderr b/src/tools/clippy/tests/ui/fn_address_comparisons.stderr index 87415a0d9048c..be7fa62f1b790 100644 --- a/src/tools/clippy/tests/ui/fn_address_comparisons.stderr +++ b/src/tools/clippy/tests/ui/fn_address_comparisons.stderr @@ -5,6 +5,7 @@ LL | let _ = f == a; | ^^^^^^ | = note: `-D clippy::fn-address-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fn_address_comparisons)]` error: comparing with a non-unique address of a function item --> $DIR/fn_address_comparisons.rs:18:13 diff --git a/src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr b/src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr index db09418cd808e..f529d8cc4110b 100644 --- a/src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr +++ b/src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr @@ -6,6 +6,7 @@ LL | fn g(_: bool, _: bool, _: bool, _: bool) {} | = help: consider refactoring bools into two-variant enums = note: `-D clippy::fn-params-excessive-bools` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fn_params_excessive_bools)]` error: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:23:1 diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.stderr index 5b2e8bdf30b06..53e8ac3c4b420 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast.stderr +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast.stderr @@ -5,6 +5,7 @@ LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` | = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]` error: casting function pointer `foo` to `i16`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:13:13 @@ -25,6 +26,7 @@ LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` | = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]` error: casting function pointer `foo` to `i128` --> $DIR/fn_to_numeric_cast.rs:20:13 diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr index 36058965479c0..a1514c87b5ec8 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr @@ -5,6 +5,7 @@ LL | let _ = foo as i8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i8` | = note: `-D clippy::fn-to-numeric-cast-any` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_any)]` error: casting function pointer `foo` to `i16` --> $DIR/fn_to_numeric_cast_any.rs:26:13 diff --git a/src/tools/clippy/tests/ui/for_kv_map.stderr b/src/tools/clippy/tests/ui/for_kv_map.stderr index d5e4ef0b4ba36..d29617e24f244 100644 --- a/src/tools/clippy/tests/ui/for_kv_map.stderr +++ b/src/tools/clippy/tests/ui/for_kv_map.stderr @@ -5,6 +5,7 @@ LL | for (_, v) in &m { | ^^ | = note: `-D clippy::for-kv-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::for_kv_map)]` help: use the corresponding method | LL | for v in m.values() { diff --git a/src/tools/clippy/tests/ui/forget_non_drop.stderr b/src/tools/clippy/tests/ui/forget_non_drop.stderr index 4634dc67f02db..c0fa433c479df 100644 --- a/src/tools/clippy/tests/ui/forget_non_drop.stderr +++ b/src/tools/clippy/tests/ui/forget_non_drop.stderr @@ -10,6 +10,7 @@ note: argument has type `main::Foo` LL | forget(Foo); | ^^^ = note: `-D clippy::forget-non-drop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::forget_non_drop)]` error: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it --> $DIR/forget_non_drop.rs:25:5 diff --git a/src/tools/clippy/tests/ui/format.stderr b/src/tools/clippy/tests/ui/format.stderr index 7019e2c867547..d4630a8f1dabb 100644 --- a/src/tools/clippy/tests/ui/format.stderr +++ b/src/tools/clippy/tests/ui/format.stderr @@ -5,6 +5,7 @@ LL | format!("foo"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` | = note: `-D clippy::useless-format` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::useless_format)]` error: useless use of `format!` --> $DIR/format.rs:21:5 diff --git a/src/tools/clippy/tests/ui/format_args.stderr b/src/tools/clippy/tests/ui/format_args.stderr index a922f293b48ef..dcdfa668aff30 100644 --- a/src/tools/clippy/tests/ui/format_args.stderr +++ b/src/tools/clippy/tests/ui/format_args.stderr @@ -5,6 +5,7 @@ LL | let _ = format!("error: something failed at {}", Location::caller().to_ | ^^^^^^^^^^^^ help: remove this | = note: `-D clippy::to-string-in-format-args` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::to_string_in_format_args)]` error: `to_string` applied to a type that implements `Display` in `write!` args --> $DIR/format_args.rs:80:27 diff --git a/src/tools/clippy/tests/ui/format_args_unfixable.stderr b/src/tools/clippy/tests/ui/format_args_unfixable.stderr index 430c435957931..3ffe2f6c89440 100644 --- a/src/tools/clippy/tests/ui/format_args_unfixable.stderr +++ b/src/tools/clippy/tests/ui/format_args_unfixable.stderr @@ -7,6 +7,7 @@ LL | println!("error: {}", format!("something failed at {}", Location::calle = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` = note: `-D clippy::format-in-format-args` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::format_in_format_args)]` error: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:28:5 diff --git a/src/tools/clippy/tests/ui/format_collect.stderr b/src/tools/clippy/tests/ui/format_collect.stderr index 79e353111f387..340218ccf2c9f 100644 --- a/src/tools/clippy/tests/ui/format_collect.stderr +++ b/src/tools/clippy/tests/ui/format_collect.stderr @@ -16,6 +16,7 @@ LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^^^^^^^^^^^^^^^^ = note: this can be written more efficiently by appending to a `String` directly = note: `-D clippy::format-collect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::format_collect)]` error: use of `format!` to build up a string from an iterator --> $DIR/format_collect.rs:11:5 diff --git a/src/tools/clippy/tests/ui/format_push_string.stderr b/src/tools/clippy/tests/ui/format_push_string.stderr index d862dd6dc5f36..545915b56b56b 100644 --- a/src/tools/clippy/tests/ui/format_push_string.stderr +++ b/src/tools/clippy/tests/ui/format_push_string.stderr @@ -6,6 +6,7 @@ LL | string += &format!("{:?}", 1234); | = help: consider using `write!` to avoid the extra allocation = note: `-D clippy::format-push-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` error: `format!(..)` appended to existing `String` --> $DIR/format_push_string.rs:7:5 diff --git a/src/tools/clippy/tests/ui/formatting.stderr b/src/tools/clippy/tests/ui/formatting.stderr index 1266d143cb165..d4eb8e511c8f9 100644 --- a/src/tools/clippy/tests/ui/formatting.stderr +++ b/src/tools/clippy/tests/ui/formatting.stderr @@ -6,6 +6,7 @@ LL | a =- 35; | = note: to remove this lint, use either `-=` or `= -` = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_assignment_formatting)]` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` --> $DIR/formatting.rs:19:6 @@ -31,6 +32,7 @@ LL | -1, -2, -3 // <= no comma here | = note: to remove this lint, add a comma or write the expr in a single line = note: `-D clippy::possible-missing-comma` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::possible_missing_comma)]` error: possibly missing a comma here --> $DIR/formatting.rs:41:19 diff --git a/src/tools/clippy/tests/ui/four_forward_slashes.stderr b/src/tools/clippy/tests/ui/four_forward_slashes.stderr index 89162e6b010e8..6450c5f94601a 100644 --- a/src/tools/clippy/tests/ui/four_forward_slashes.stderr +++ b/src/tools/clippy/tests/ui/four_forward_slashes.stderr @@ -6,6 +6,7 @@ LL | | fn a() {} | |_ | = note: `-D clippy::four-forward-slashes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]` help: make this a doc comment by removing one `/` | LL + /// whoops diff --git a/src/tools/clippy/tests/ui/four_forward_slashes_first_line.stderr b/src/tools/clippy/tests/ui/four_forward_slashes_first_line.stderr index 7944da14feb0e..afb7c6b4dbda4 100644 --- a/src/tools/clippy/tests/ui/four_forward_slashes_first_line.stderr +++ b/src/tools/clippy/tests/ui/four_forward_slashes_first_line.stderr @@ -6,6 +6,7 @@ LL | | fn a() {} | |_ | = note: `-D clippy::four-forward-slashes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]` help: make this a doc comment by removing one `/` | LL + /// borked doc comment on the first line. doesn't combust! diff --git a/src/tools/clippy/tests/ui/from_iter_instead_of_collect.stderr b/src/tools/clippy/tests/ui/from_iter_instead_of_collect.stderr index e42851bf84603..6e86341d1574d 100644 --- a/src/tools/clippy/tests/ui/from_iter_instead_of_collect.stderr +++ b/src/tools/clippy/tests/ui/from_iter_instead_of_collect.stderr @@ -5,6 +5,7 @@ LL | >::from_iter(iter.into_iter().copied()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter.into_iter().copied().collect::()` | = note: `-D clippy::from-iter-instead-of-collect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::from_iter_instead_of_collect)]` error: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:23:13 diff --git a/src/tools/clippy/tests/ui/from_over_into.stderr b/src/tools/clippy/tests/ui/from_over_into.stderr index 96afec3de30e3..784843ce5fd55 100644 --- a/src/tools/clippy/tests/ui/from_over_into.stderr +++ b/src/tools/clippy/tests/ui/from_over_into.stderr @@ -5,6 +5,7 @@ LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::from-over-into` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::from_over_into)]` help: replace the `Into` implementation with `From` | LL ~ impl From for StringWrapper { diff --git a/src/tools/clippy/tests/ui/from_over_into_unfixable.stderr b/src/tools/clippy/tests/ui/from_over_into_unfixable.stderr index 3470eff9e9585..8ef36f082e0ef 100644 --- a/src/tools/clippy/tests/ui/from_over_into_unfixable.stderr +++ b/src/tools/clippy/tests/ui/from_over_into_unfixable.stderr @@ -6,6 +6,7 @@ LL | impl Into for String { | = help: replace the `Into` implementation with `From` = note: `-D clippy::from-over-into` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::from_over_into)]` error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into_unfixable.rs:20:1 diff --git a/src/tools/clippy/tests/ui/from_raw_with_void_ptr.stderr b/src/tools/clippy/tests/ui/from_raw_with_void_ptr.stderr index b6460862419d3..6e1ad0d99c49f 100644 --- a/src/tools/clippy/tests/ui/from_raw_with_void_ptr.stderr +++ b/src/tools/clippy/tests/ui/from_raw_with_void_ptr.stderr @@ -10,6 +10,7 @@ help: cast this to a pointer of the appropriate type LL | let _ = unsafe { Box::from_raw(ptr) }; | ^^^ = note: `-D clippy::from-raw-with-void-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::from_raw_with_void_ptr)]` error: creating a `Rc` from a void raw pointer --> $DIR/from_raw_with_void_ptr.rs:23:22 diff --git a/src/tools/clippy/tests/ui/from_str_radix_10.stderr b/src/tools/clippy/tests/ui/from_str_radix_10.stderr index 1fbd1e3a5f20d..439dcff74d9c9 100644 --- a/src/tools/clippy/tests/ui/from_str_radix_10.stderr +++ b/src/tools/clippy/tests/ui/from_str_radix_10.stderr @@ -5,6 +5,7 @@ LL | u32::from_str_radix("30", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"30".parse::()` | = note: `-D clippy::from-str-radix-10` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::from_str_radix_10)]` error: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:31:5 diff --git a/src/tools/clippy/tests/ui/functions.stderr b/src/tools/clippy/tests/ui/functions.stderr index fb8f4511e9951..371ea1612601e 100644 --- a/src/tools/clippy/tests/ui/functions.stderr +++ b/src/tools/clippy/tests/ui/functions.stderr @@ -5,6 +5,7 @@ LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::too-many-arguments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]` error: this function has too many arguments (8/7) --> $DIR/functions.rs:13:1 @@ -37,6 +38,7 @@ LL | println!("{}", unsafe { *p }); | ^ | = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::not_unsafe_ptr_arg_deref)]` error: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:71:35 diff --git a/src/tools/clippy/tests/ui/functions_maxlines.stderr b/src/tools/clippy/tests/ui/functions_maxlines.stderr index 6551892363c49..1d6ddad79ff2d 100644 --- a/src/tools/clippy/tests/ui/functions_maxlines.stderr +++ b/src/tools/clippy/tests/ui/functions_maxlines.stderr @@ -11,6 +11,7 @@ LL | | } | |_^ | = note: `-D clippy::too-many-lines` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::too_many_lines)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/future_not_send.stderr b/src/tools/clippy/tests/ui/future_not_send.stderr index 9628cf3a1b952..e417de723ff3e 100644 --- a/src/tools/clippy/tests/ui/future_not_send.stderr +++ b/src/tools/clippy/tests/ui/future_not_send.stderr @@ -27,6 +27,7 @@ LL | } | - `cell` is later dropped here = note: `std::cell::Cell` doesn't implement `std::marker::Sync` = note: `-D clippy::future-not-send` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::future_not_send)]` error: future cannot be sent between threads safely --> $DIR/future_not_send.rs:12:42 diff --git a/src/tools/clippy/tests/ui/get_first.stderr b/src/tools/clippy/tests/ui/get_first.stderr index 51ebb1f3f06fa..56b4c29a31353 100644 --- a/src/tools/clippy/tests/ui/get_first.stderr +++ b/src/tools/clippy/tests/ui/get_first.stderr @@ -5,6 +5,7 @@ LL | let _ = x.get(0); // Use x.first() | ^^^^^^^^ help: try: `x.first()` | = note: `-D clippy::get-first` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::get_first)]` error: accessing first element with `y.get(0)` --> $DIR/get_first.rs:22:13 diff --git a/src/tools/clippy/tests/ui/get_last_with_len.stderr b/src/tools/clippy/tests/ui/get_last_with_len.stderr index 8e852bbb26557..0056adc57f22c 100644 --- a/src/tools/clippy/tests/ui/get_last_with_len.stderr +++ b/src/tools/clippy/tests/ui/get_last_with_len.stderr @@ -5,6 +5,7 @@ LL | let _ = x.get(x.len() - 1); | ^^^^^^^^^^^^^^^^^^ help: try: `x.last()` | = note: `-D clippy::get-last-with-len` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::get_last_with_len)]` error: accessing last element with `s.field.get(s.field.len() - 1)` --> $DIR/get_last_with_len.rs:32:13 diff --git a/src/tools/clippy/tests/ui/get_unwrap.stderr b/src/tools/clippy/tests/ui/get_unwrap.stderr index 242c339bbf1da..384860ea116e9 100644 --- a/src/tools/clippy/tests/ui/get_unwrap.stderr +++ b/src/tools/clippy/tests/ui/get_unwrap.stderr @@ -19,6 +19,7 @@ LL | let _ = boxed_slice.get(1).unwrap(); = note: if this value is `None`, it will panic = help: consider using `expect()` to provide a better panic message = note: `-D clippy::unwrap-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:37:17 diff --git a/src/tools/clippy/tests/ui/identity_op.stderr b/src/tools/clippy/tests/ui/identity_op.stderr index cb251935b6003..2a61327f15f2a 100644 --- a/src/tools/clippy/tests/ui/identity_op.stderr +++ b/src/tools/clippy/tests/ui/identity_op.stderr @@ -5,6 +5,7 @@ LL | x + 0; | ^^^^^ help: consider reducing it to: `x` | = note: `-D clippy::identity-op` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::identity_op)]` error: this operation has no effect --> $DIR/identity_op.rs:43:5 diff --git a/src/tools/clippy/tests/ui/if_let_mutex.stderr b/src/tools/clippy/tests/ui/if_let_mutex.stderr index 6bbaadbe85539..8934294430b25 100644 --- a/src/tools/clippy/tests/ui/if_let_mutex.stderr +++ b/src/tools/clippy/tests/ui/if_let_mutex.stderr @@ -16,6 +16,7 @@ LL | | }; | = help: move the lock call outside of the `if let ...` expression = note: `-D clippy::if-let-mutex` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::if_let_mutex)]` error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock --> $DIR/if_let_mutex.rs:23:5 diff --git a/src/tools/clippy/tests/ui/if_not_else.stderr b/src/tools/clippy/tests/ui/if_not_else.stderr index 2a7500fdc61a0..8b86f82fa8ee0 100644 --- a/src/tools/clippy/tests/ui/if_not_else.stderr +++ b/src/tools/clippy/tests/ui/if_not_else.stderr @@ -11,6 +11,7 @@ LL | | } | = help: remove the `!` and swap the blocks of the `if`/`else` = note: `-D clippy::if-not-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::if_not_else)]` error: unnecessary `!=` operation --> $DIR/if_not_else.rs:18:5 diff --git a/src/tools/clippy/tests/ui/if_same_then_else.stderr b/src/tools/clippy/tests/ui/if_same_then_else.stderr index 774cc08685a7f..fb33e94e6c3de 100644 --- a/src/tools/clippy/tests/ui/if_same_then_else.stderr +++ b/src/tools/clippy/tests/ui/if_same_then_else.stderr @@ -24,6 +24,7 @@ LL | | foo(); LL | | } | |_____^ = note: `-D clippy::if-same-then-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]` error: this `if` has identical blocks --> $DIR/if_same_then_else.rs:67:21 diff --git a/src/tools/clippy/tests/ui/if_same_then_else2.stderr b/src/tools/clippy/tests/ui/if_same_then_else2.stderr index 56e5f3e45b22c..fe68ef2711b59 100644 --- a/src/tools/clippy/tests/ui/if_same_then_else2.stderr +++ b/src/tools/clippy/tests/ui/if_same_then_else2.stderr @@ -24,6 +24,7 @@ LL | | } LL | | } | |_____^ = note: `-D clippy::if-same-then-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]` error: this `if` has identical blocks --> $DIR/if_same_then_else2.rs:36:13 diff --git a/src/tools/clippy/tests/ui/if_then_some_else_none.stderr b/src/tools/clippy/tests/ui/if_then_some_else_none.stderr index f63298a7fce86..5c97b06da15a8 100644 --- a/src/tools/clippy/tests/ui/if_then_some_else_none.stderr +++ b/src/tools/clippy/tests/ui/if_then_some_else_none.stderr @@ -13,6 +13,7 @@ LL | | }; | = help: consider using `bool::then` like: `foo().then(|| { /* snippet */ "foo" })` = note: `-D clippy::if-then-some-else-none` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::if_then_some_else_none)]` error: this could be simplified with `bool::then` --> $DIR/if_then_some_else_none.rs:14:13 diff --git a/src/tools/clippy/tests/ui/ifs_same_cond.stderr b/src/tools/clippy/tests/ui/ifs_same_cond.stderr index 3f52c10b7620a..c5cd6b2c42e5a 100644 --- a/src/tools/clippy/tests/ui/ifs_same_cond.stderr +++ b/src/tools/clippy/tests/ui/ifs_same_cond.stderr @@ -10,6 +10,7 @@ note: same as this LL | if b { | ^ = note: `-D clippy::ifs-same-cond` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ifs_same_cond)]` error: this `if` has the same condition as a previous `if` --> $DIR/ifs_same_cond.rs:19:15 diff --git a/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr b/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr index 6cb8b60ac0ce8..a8ced22397dbb 100644 --- a/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr +++ b/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr @@ -5,6 +5,7 @@ LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` | = note: `-D clippy::ignored-unit-patterns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ignored_unit_patterns)]` error: matching over `()` is more explicit --> $DIR/ignored_unit_patterns.rs:11:13 diff --git a/src/tools/clippy/tests/ui/impl.stderr b/src/tools/clippy/tests/ui/impl.stderr index 2eac1ce3dd7b5..833a106062a38 100644 --- a/src/tools/clippy/tests/ui/impl.stderr +++ b/src/tools/clippy/tests/ui/impl.stderr @@ -15,6 +15,7 @@ LL | | fn first() {} LL | | } | |_^ = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::multiple_inherent_impl)]` error: multiple implementations of this structure --> $DIR/impl.rs:25:5 diff --git a/src/tools/clippy/tests/ui/impl_trait_in_params.stderr b/src/tools/clippy/tests/ui/impl_trait_in_params.stderr index ad035abc635bb..36b4f27e9a456 100644 --- a/src/tools/clippy/tests/ui/impl_trait_in_params.stderr +++ b/src/tools/clippy/tests/ui/impl_trait_in_params.stderr @@ -5,6 +5,7 @@ LL | pub fn a(_: impl Trait) {} | ^^^^^^^^^^ | = note: `-D clippy::impl-trait-in-params` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::impl_trait_in_params)]` help: add a type parameter | LL | pub fn a<{ /* Generic name */ }: Trait>(_: impl Trait) {} diff --git a/src/tools/clippy/tests/ui/implicit_clone.stderr b/src/tools/clippy/tests/ui/implicit_clone.stderr index 59f000c06e200..64c31e65175ab 100644 --- a/src/tools/clippy/tests/ui/implicit_clone.stderr +++ b/src/tools/clippy/tests/ui/implicit_clone.stderr @@ -5,6 +5,7 @@ LL | let _ = vec.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `vec.clone()` | = note: `-D clippy::implicit-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implicit_clone)]` error: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type --> $DIR/implicit_clone.rs:66:13 diff --git a/src/tools/clippy/tests/ui/implicit_return.stderr b/src/tools/clippy/tests/ui/implicit_return.stderr index a761b42739530..1edc6cc6f7788 100644 --- a/src/tools/clippy/tests/ui/implicit_return.stderr +++ b/src/tools/clippy/tests/ui/implicit_return.stderr @@ -5,6 +5,7 @@ LL | true | ^^^^ help: add `return` as shown: `return true` | = note: `-D clippy::implicit-return` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implicit_return)]` error: missing `return` statement --> $DIR/implicit_return.rs:15:15 diff --git a/src/tools/clippy/tests/ui/implicit_saturating_add.stderr b/src/tools/clippy/tests/ui/implicit_saturating_add.stderr index cfd600c53c362..7119c8bf6fad0 100644 --- a/src/tools/clippy/tests/ui/implicit_saturating_add.stderr +++ b/src/tools/clippy/tests/ui/implicit_saturating_add.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: use instead: `u_8 = u_8.saturating_add(1);` | = note: `-D clippy::implicit-saturating-add` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_add)]` error: manual saturating add detected --> $DIR/implicit_saturating_add.rs:25:5 diff --git a/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr b/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr index 75d8a88e8d43c..6e026d1a69875 100644 --- a/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr +++ b/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: try: `u_8 = u_8.saturating_sub(1);` | = note: `-D clippy::implicit-saturating-sub` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]` error: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:34:13 diff --git a/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr b/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr index 8dffc674444d7..e2b1ecb9f1ec7 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr @@ -5,6 +5,7 @@ LL | fn deref_derefmut(x: T) -> impl Deref + DerefMut | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::implied-bounds-in-impls` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implied_bounds_in_impls)]` help: try removing this bound | LL - fn deref_derefmut(x: T) -> impl Deref + DerefMut { diff --git a/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr b/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr index 485c1fdb9120d..6aeb33edafd3c 100644 --- a/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr +++ b/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr @@ -5,6 +5,7 @@ LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f | ^^^^^^^^ help: consider: `123_456` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:25:26 diff --git a/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr b/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr index a2bee121ebf2f..fc080d7ec057d 100644 --- a/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr +++ b/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr @@ -5,6 +5,7 @@ LL | Foo { y, x, z }; | ^^^^^^^^^^^^^^^ help: try: `Foo { x, y, z }` | = note: `-D clippy::inconsistent-struct-constructor` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inconsistent_struct_constructor)]` error: struct constructor field order is inconsistent with struct definition field order --> $DIR/inconsistent_struct_constructor.rs:55:9 diff --git a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr index edb47d39412ba..64facf208034b 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr +++ b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr @@ -7,6 +7,7 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re = help: consider using `.get(n)` or `.get_mut(n)` instead = note: the suggestion might not be applicable in constant blocks = note: `-D clippy::indexing-slicing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic --> $DIR/indexing_slicing_index.rs:16:24 diff --git a/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr b/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr index 0f83ea52d01ba..eebe67810a024 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr +++ b/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr @@ -6,6 +6,7 @@ LL | &x[index..]; | = help: consider using `.get(n..)` or .get_mut(n..)` instead = note: `-D clippy::indexing-slicing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: slicing may panic --> $DIR/indexing_slicing_slice.rs:14:6 @@ -54,6 +55,7 @@ LL | &x[5..][..10]; | ^ | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: slicing may panic --> $DIR/indexing_slicing_slice.rs:25:6 diff --git a/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr b/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr index ada02741692f5..93851aae82bd7 100644 --- a/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr +++ b/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr @@ -7,6 +7,7 @@ LL | | }; | |______^ help: try: `let SingleVariantEnum::Variant(data) = wrapper;` | = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::infallible_destructuring_match)]` error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` --> $DIR/infallible_destructuring_match.rs:60:5 diff --git a/src/tools/clippy/tests/ui/infinite_loop.stderr b/src/tools/clippy/tests/ui/infinite_loop.stderr index 5ba806be867f5..c32b5e323c09e 100644 --- a/src/tools/clippy/tests/ui/infinite_loop.stderr +++ b/src/tools/clippy/tests/ui/infinite_loop.stderr @@ -98,6 +98,7 @@ LL | fn fn_mutref(i: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: aborting due to 12 previous errors diff --git a/src/tools/clippy/tests/ui/inherent_to_string.stderr b/src/tools/clippy/tests/ui/inherent_to_string.stderr index cfe8600e92606..cf8d09180191b 100644 --- a/src/tools/clippy/tests/ui/inherent_to_string.stderr +++ b/src/tools/clippy/tests/ui/inherent_to_string.stderr @@ -9,6 +9,7 @@ LL | | } | = help: implement trait `Display` for type `A` instead = note: `-D clippy::inherent-to-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inherent_to_string)]` error: type `C` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display` --> $DIR/inherent_to_string.rs:47:5 diff --git a/src/tools/clippy/tests/ui/inline_fn_without_body.stderr b/src/tools/clippy/tests/ui/inline_fn_without_body.stderr index 87d2da71280d8..60f6eb8dff082 100644 --- a/src/tools/clippy/tests/ui/inline_fn_without_body.stderr +++ b/src/tools/clippy/tests/ui/inline_fn_without_body.stderr @@ -7,6 +7,7 @@ LL | | fn default_inline(); | |____- help: remove | = note: `-D clippy::inline-fn-without-body` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inline_fn_without_body)]` error: use of `#[inline]` on trait method `always_inline` which has no body --> $DIR/inline_fn_without_body.rs:8:5 diff --git a/src/tools/clippy/tests/ui/inspect_for_each.stderr b/src/tools/clippy/tests/ui/inspect_for_each.stderr index bdeb1d844609b..80df86ad64ec9 100644 --- a/src/tools/clippy/tests/ui/inspect_for_each.stderr +++ b/src/tools/clippy/tests/ui/inspect_for_each.stderr @@ -12,6 +12,7 @@ LL | | }); | = help: move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)` = note: `-D clippy::inspect-for-each` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inspect_for_each)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/int_plus_one.stderr b/src/tools/clippy/tests/ui/int_plus_one.stderr index a0c5b32a205f4..6a62eac7cc476 100644 --- a/src/tools/clippy/tests/ui/int_plus_one.stderr +++ b/src/tools/clippy/tests/ui/int_plus_one.stderr @@ -5,6 +5,7 @@ LL | let _ = x >= y + 1; | ^^^^^^^^^^ help: change it to: `x > y` | = note: `-D clippy::int-plus-one` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::int_plus_one)]` error: unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:8:13 diff --git a/src/tools/clippy/tests/ui/integer_division.stderr b/src/tools/clippy/tests/ui/integer_division.stderr index 9bc41ef8385e7..420f0f30e77cf 100644 --- a/src/tools/clippy/tests/ui/integer_division.stderr +++ b/src/tools/clippy/tests/ui/integer_division.stderr @@ -6,6 +6,7 @@ LL | let n = 1 / 2; | = help: division of integers may cause loss of precision. consider using floats = note: `-D clippy::integer-division` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::integer_division)]` error: integer division --> $DIR/integer_division.rs:7:13 diff --git a/src/tools/clippy/tests/ui/into_iter_on_ref.stderr b/src/tools/clippy/tests/ui/into_iter_on_ref.stderr index 2c81518d8db4c..481957d50e205 100644 --- a/src/tools/clippy/tests/ui/into_iter_on_ref.stderr +++ b/src/tools/clippy/tests/ui/into_iter_on_ref.stderr @@ -5,6 +5,7 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` | = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::into_iter_on_ref)]` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` --> $DIR/into_iter_on_ref.rs:14:46 diff --git a/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr b/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr index b201db3ddb14e..a57b4b02dce3a 100644 --- a/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr +++ b/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr @@ -5,6 +5,7 @@ LL | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::invalid_upcast_comparisons)]` error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:24:5 diff --git a/src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr b/src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr index 7bc21b216d536..28040c3a9c26d 100644 --- a/src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr +++ b/src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr @@ -5,6 +5,7 @@ LL | let _ = c.is_digit(10); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_digit()` | = note: `-D clippy::is-digit-ascii-radix` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::is_digit_ascii_radix)]` error: use of `char::is_digit` with literal radix of 16 --> $DIR/is_digit_ascii_radix.rs:10:13 diff --git a/src/tools/clippy/tests/ui/issue-7447.stderr b/src/tools/clippy/tests/ui/issue-7447.stderr index 27e102af62fbb..51ecac4559c95 100644 --- a/src/tools/clippy/tests/ui/issue-7447.stderr +++ b/src/tools/clippy/tests/ui/issue-7447.stderr @@ -5,6 +5,7 @@ LL | byte_view(panic!()); | ^^^^^^^^ | = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: sub-expression diverges diff --git a/src/tools/clippy/tests/ui/issue_4266.stderr b/src/tools/clippy/tests/ui/issue_4266.stderr index acfa01e9f2b31..692de2ae58c09 100644 --- a/src/tools/clippy/tests/ui/issue_4266.stderr +++ b/src/tools/clippy/tests/ui/issue_4266.stderr @@ -5,6 +5,7 @@ LL | async fn sink1<'a>(_: &'a str) {} // lint | ^^ ^^ | = note: `-D clippy::needless-lifetimes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` error: the following explicit lifetimes could be elided: 'a --> $DIR/issue_4266.rs:10:21 @@ -20,6 +21,7 @@ LL | pub async fn new(&mut self) -> Self { | = help: consider choosing a less ambiguous name = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: aborting due to 3 previous errors diff --git a/src/tools/clippy/tests/ui/items_after_statement.stderr b/src/tools/clippy/tests/ui/items_after_statement.stderr index 0e043b1742ff0..fa494f2174895 100644 --- a/src/tools/clippy/tests/ui/items_after_statement.stderr +++ b/src/tools/clippy/tests/ui/items_after_statement.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::items-after-statements` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::items_after_statements)]` error: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/items_after_statement.rs:22:5 diff --git a/src/tools/clippy/tests/ui/iter_cloned_collect.stderr b/src/tools/clippy/tests/ui/iter_cloned_collect.stderr index 36f70d5aec295..aa7fb98a7c8ad 100644 --- a/src/tools/clippy/tests/ui/iter_cloned_collect.stderr +++ b/src/tools/clippy/tests/ui/iter_cloned_collect.stderr @@ -5,6 +5,7 @@ LL | let v2: Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` | = note: `-D clippy::iter-cloned-collect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_cloned_collect)]` error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable --> $DIR/iter_cloned_collect.rs:13:38 diff --git a/src/tools/clippy/tests/ui/iter_count.stderr b/src/tools/clippy/tests/ui/iter_count.stderr index 2e3d7fc35de9c..2882b7d28505f 100644 --- a/src/tools/clippy/tests/ui/iter_count.stderr +++ b/src/tools/clippy/tests/ui/iter_count.stderr @@ -5,6 +5,7 @@ LL | &vec[..].iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` | = note: `-D clippy::iter-count` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_count)]` error: called `.iter().count()` on a `Vec` --> $DIR/iter_count.rs:55:5 diff --git a/src/tools/clippy/tests/ui/iter_kv_map.stderr b/src/tools/clippy/tests/ui/iter_kv_map.stderr index 75804af01ce2e..62155b7f838e2 100644 --- a/src/tools/clippy/tests/ui/iter_kv_map.stderr +++ b/src/tools/clippy/tests/ui/iter_kv_map.stderr @@ -5,6 +5,7 @@ LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` | = note: `-D clippy::iter-kv-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_kv_map)]` error: iterating on a map's values --> $DIR/iter_kv_map.rs:15:13 diff --git a/src/tools/clippy/tests/ui/iter_next_slice.stderr b/src/tools/clippy/tests/ui/iter_next_slice.stderr index d8b89061ff895..e6b4bd6c0b480 100644 --- a/src/tools/clippy/tests/ui/iter_next_slice.stderr +++ b/src/tools/clippy/tests/ui/iter_next_slice.stderr @@ -5,6 +5,7 @@ LL | let _ = s.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `s.first()` | = note: `-D clippy::iter-next-slice` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_next_slice)]` error: using `.iter().next()` on a Slice without end index --> $DIR/iter_next_slice.rs:12:13 diff --git a/src/tools/clippy/tests/ui/iter_not_returning_iterator.stderr b/src/tools/clippy/tests/ui/iter_not_returning_iterator.stderr index 3145ade4448ba..c695b1932d356 100644 --- a/src/tools/clippy/tests/ui/iter_not_returning_iterator.stderr +++ b/src/tools/clippy/tests/ui/iter_not_returning_iterator.stderr @@ -5,6 +5,7 @@ LL | fn iter(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iter-not-returning-iterator` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_not_returning_iterator)]` error: this method is named `iter_mut` but its return type does not implement `Iterator` --> $DIR/iter_not_returning_iterator.rs:36:5 diff --git a/src/tools/clippy/tests/ui/iter_nth.stderr b/src/tools/clippy/tests/ui/iter_nth.stderr index 24be814548a29..162e6c3384941 100644 --- a/src/tools/clippy/tests/ui/iter_nth.stderr +++ b/src/tools/clippy/tests/ui/iter_nth.stderr @@ -6,6 +6,7 @@ LL | let bad_vec = some_vec.iter().nth(3); | = help: calling `.get()` is both faster and more readable = note: `-D clippy::iter-nth` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_nth)]` error: called `.iter().nth()` on a slice --> $DIR/iter_nth.rs:35:26 diff --git a/src/tools/clippy/tests/ui/iter_nth_zero.stderr b/src/tools/clippy/tests/ui/iter_nth_zero.stderr index 8338d7f7b93a0..939fd0063c0b1 100644 --- a/src/tools/clippy/tests/ui/iter_nth_zero.stderr +++ b/src/tools/clippy/tests/ui/iter_nth_zero.stderr @@ -5,6 +5,7 @@ LL | let _x = s.iter().nth(0); | ^^^^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `s.iter().next()` | = note: `-D clippy::iter-nth-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_nth_zero)]` error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent --> $DIR/iter_nth_zero.rs:23:14 diff --git a/src/tools/clippy/tests/ui/iter_on_empty_collections.stderr b/src/tools/clippy/tests/ui/iter_on_empty_collections.stderr index c115c1278389b..57a5320199665 100644 --- a/src/tools/clippy/tests/ui/iter_on_empty_collections.stderr +++ b/src/tools/clippy/tests/ui/iter_on_empty_collections.stderr @@ -5,6 +5,7 @@ LL | assert_eq!([].into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^ help: try: `std::iter::empty()` | = note: `-D clippy::iter-on-empty-collections` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_on_empty_collections)]` error: `iter_mut` call on an empty collection --> $DIR/iter_on_empty_collections.rs:6:16 diff --git a/src/tools/clippy/tests/ui/iter_on_single_items.stderr b/src/tools/clippy/tests/ui/iter_on_single_items.stderr index c6714143ba5a8..00398f541e9a1 100644 --- a/src/tools/clippy/tests/ui/iter_on_single_items.stderr +++ b/src/tools/clippy/tests/ui/iter_on_single_items.stderr @@ -5,6 +5,7 @@ LL | assert_eq!([123].into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` | = note: `-D clippy::iter-on-single-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_on_single_items)]` error: `iter_mut` call on a collection with only one item --> $DIR/iter_on_single_items.rs:6:16 diff --git a/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr b/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr index 4417a40a63b8b..fbcd33066d876 100644 --- a/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr +++ b/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr @@ -7,6 +7,7 @@ LL | let _: Option = vec.iter().cloned().last(); | help: try: `.last().cloned()` | = note: `-D clippy::iter-overeager-cloned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_overeager_cloned)]` error: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:9:29 @@ -25,6 +26,7 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); | help: try: `.count()` | = note: `-D clippy::redundant-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:13:21 diff --git a/src/tools/clippy/tests/ui/iter_skip_next.stderr b/src/tools/clippy/tests/ui/iter_skip_next.stderr index ca6970b27f16c..0b6bf652b1f1f 100644 --- a/src/tools/clippy/tests/ui/iter_skip_next.stderr +++ b/src/tools/clippy/tests/ui/iter_skip_next.stderr @@ -5,6 +5,7 @@ LL | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` | = note: `-D clippy::iter-skip-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_skip_next)]` error: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:17:36 diff --git a/src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr b/src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr index 3160dc03a4fdb..09a467793bd12 100644 --- a/src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr +++ b/src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr @@ -10,6 +10,7 @@ help: for this change `sp` has to be mutable LL | let sp = test_string.split('|').map(|s| s.trim()); | ^^ = note: `-D clippy::iter-skip-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_skip_next)]` error: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next_unfixable.rs:12:29 diff --git a/src/tools/clippy/tests/ui/iter_skip_zero.stderr b/src/tools/clippy/tests/ui/iter_skip_zero.stderr index 6616020d0bdc0..6b8b3b1056acf 100644 --- a/src/tools/clippy/tests/ui/iter_skip_zero.stderr +++ b/src/tools/clippy/tests/ui/iter_skip_zero.stderr @@ -6,6 +6,7 @@ LL | let _ = [1, 2, 3].iter().skip(0); | = note: this call to `skip` does nothing and is useless; remove it = note: `-D clippy::iter-skip-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_skip_zero)]` error: usage of `.skip(0)` --> $DIR/iter_skip_zero.rs:12:39 diff --git a/src/tools/clippy/tests/ui/iter_with_drain.stderr b/src/tools/clippy/tests/ui/iter_with_drain.stderr index 0a3026570882b..ac04f9396f5d2 100644 --- a/src/tools/clippy/tests/ui/iter_with_drain.stderr +++ b/src/tools/clippy/tests/ui/iter_with_drain.stderr @@ -5,6 +5,7 @@ LL | let mut a: BinaryHeap<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try: `into_iter()` | = note: `-D clippy::iter-with-drain` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iter_with_drain)]` error: `drain(..)` used on a `VecDeque` --> $DIR/iter_with_drain.rs:13:27 diff --git a/src/tools/clippy/tests/ui/iterator_step_by_zero.stderr b/src/tools/clippy/tests/ui/iterator_step_by_zero.stderr index fcf2930c26b29..20ea29322e858 100644 --- a/src/tools/clippy/tests/ui/iterator_step_by_zero.stderr +++ b/src/tools/clippy/tests/ui/iterator_step_by_zero.stderr @@ -5,6 +5,7 @@ LL | let _ = vec!["A", "B", "B"].iter().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::iterator_step_by_zero)]` error: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:7:13 diff --git a/src/tools/clippy/tests/ui/large_const_arrays.stderr b/src/tools/clippy/tests/ui/large_const_arrays.stderr index e2348629088d1..e522550ffcbdc 100644 --- a/src/tools/clippy/tests/ui/large_const_arrays.stderr +++ b/src/tools/clippy/tests/ui/large_const_arrays.stderr @@ -7,6 +7,7 @@ LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` | = note: `-D clippy::large-const-arrays` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]` error: large array defined as const --> $DIR/large_const_arrays.rs:11:1 diff --git a/src/tools/clippy/tests/ui/large_digit_groups.stderr b/src/tools/clippy/tests/ui/large_digit_groups.stderr index 7e5ce7ad8d539..e5f37a6cce96b 100644 --- a/src/tools/clippy/tests/ui/large_digit_groups.stderr +++ b/src/tools/clippy/tests/ui/large_digit_groups.stderr @@ -5,6 +5,7 @@ LL | 0xd_e_adbee_f_usize, | ^^^^^^^^^^^^^^^^^^^ help: consider: `0xdead_beef_usize` | = note: `-D clippy::unusual-byte-groupings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:23:9 @@ -13,6 +14,7 @@ LL | 1_23456_f32, | ^^^^^^^^^^^ help: consider: `123_456_f32` | = note: `-D clippy::large-digit-groups` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_digit_groups)]` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:24:9 diff --git a/src/tools/clippy/tests/ui/large_enum_variant.stderr b/src/tools/clippy/tests/ui/large_enum_variant.stderr index 709972b4a6e49..7026ca785f34c 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.stderr +++ b/src/tools/clippy/tests/ui/large_enum_variant.stderr @@ -10,6 +10,7 @@ LL | | } | |_^ the entire enum is at least 32004 bytes | = note: `-D clippy::large-enum-variant` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]` help: consider boxing the large fields to reduce the total size of the enum | LL | B(Box<[i32; 8000]>), diff --git a/src/tools/clippy/tests/ui/large_futures.stderr b/src/tools/clippy/tests/ui/large_futures.stderr index 5a0f00b67ec4d..861366dafac6d 100644 --- a/src/tools/clippy/tests/ui/large_futures.stderr +++ b/src/tools/clippy/tests/ui/large_futures.stderr @@ -5,6 +5,7 @@ LL | big_fut([0u8; 1024 * 16]).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(big_fut([0u8; 1024 * 16]))` | = note: `-D clippy::large-futures` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_futures)]` error: large future with a size of 16386 bytes --> $DIR/large_futures.rs:15:5 diff --git a/src/tools/clippy/tests/ui/large_stack_arrays.stderr b/src/tools/clippy/tests/ui/large_stack_arrays.stderr index 5126f45278554..0dfb6732b02a5 100644 --- a/src/tools/clippy/tests/ui/large_stack_arrays.stderr +++ b/src/tools/clippy/tests/ui/large_stack_arrays.stderr @@ -6,6 +6,7 @@ LL | let _x = [build(); 3]; | = help: consider allocating on the heap with `vec![build(); 3].into_boxed_slice()` = note: `-D clippy::large-stack-arrays` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]` error: allocating a local array larger than 512000 bytes --> $DIR/large_stack_arrays.rs:32:14 diff --git a/src/tools/clippy/tests/ui/large_stack_frames.stderr b/src/tools/clippy/tests/ui/large_stack_frames.stderr index 6b14badca69ff..12a458db807e1 100644 --- a/src/tools/clippy/tests/ui/large_stack_frames.stderr +++ b/src/tools/clippy/tests/ui/large_stack_frames.stderr @@ -12,6 +12,7 @@ LL | | } | = note: allocating large amounts of stack space can overflow the stack = note: `-D clippy::large-stack-frames` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]` error: this function allocates a large amount of stack space --> $DIR/large_stack_frames.rs:36:1 diff --git a/src/tools/clippy/tests/ui/large_types_passed_by_value.stderr b/src/tools/clippy/tests/ui/large_types_passed_by_value.stderr index 5f42dcfb9b521..b3f102cc498d8 100644 --- a/src/tools/clippy/tests/ui/large_types_passed_by_value.stderr +++ b/src/tools/clippy/tests/ui/large_types_passed_by_value.stderr @@ -5,6 +5,7 @@ LL | fn bad(a: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` | = note: `-D clippy::large-types-passed-by-value` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_types_passed_by_value)]` error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:25:37 diff --git a/src/tools/clippy/tests/ui/len_without_is_empty.stderr b/src/tools/clippy/tests/ui/len_without_is_empty.stderr index 1042ea2e1b389..4815ce6a04b29 100644 --- a/src/tools/clippy/tests/ui/len_without_is_empty.stderr +++ b/src/tools/clippy/tests/ui/len_without_is_empty.stderr @@ -5,6 +5,7 @@ LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::len-without-is-empty` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::len_without_is_empty)]` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method --> $DIR/len_without_is_empty.rs:57:1 @@ -96,6 +97,7 @@ LL | pub fn len(&self) -> Result { | = help: use a custom `Error` type instead = note: `-D clippy::result-unit-err` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` --> $DIR/len_without_is_empty.rs:250:5 diff --git a/src/tools/clippy/tests/ui/len_zero.stderr b/src/tools/clippy/tests/ui/len_zero.stderr index 45130a3008d3d..e1f2434415d0f 100644 --- a/src/tools/clippy/tests/ui/len_zero.stderr +++ b/src/tools/clippy/tests/ui/len_zero.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::len_zero)]` error: length comparison to zero --> $DIR/len_zero.rs:86:8 @@ -19,6 +20,7 @@ LL | println!("{}", *s1 == ""); | ^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s1.is_empty()` | = note: `-D clippy::comparison-to-empty` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]` error: comparison to empty slice --> $DIR/len_zero.rs:96:20 diff --git a/src/tools/clippy/tests/ui/len_zero_ranges.stderr b/src/tools/clippy/tests/ui/len_zero_ranges.stderr index 25a940181d498..1922e9b304443 100644 --- a/src/tools/clippy/tests/ui/len_zero_ranges.stderr +++ b/src/tools/clippy/tests/ui/len_zero_ranges.stderr @@ -5,6 +5,7 @@ LL | let _ = (0..42).len() == 0; | ^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0..42).is_empty()` | = note: `-D clippy::len-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::len_zero)]` error: length comparison to zero --> $DIR/len_zero_ranges.rs:11:17 diff --git a/src/tools/clippy/tests/ui/let_and_return.stderr b/src/tools/clippy/tests/ui/let_and_return.stderr index 3f60b69df4567..c09c2b32aad0d 100644 --- a/src/tools/clippy/tests/ui/let_and_return.stderr +++ b/src/tools/clippy/tests/ui/let_and_return.stderr @@ -7,6 +7,7 @@ LL | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_and_return)]` help: return the expression directly | LL ~ diff --git a/src/tools/clippy/tests/ui/let_if_seq.stderr b/src/tools/clippy/tests/ui/let_if_seq.stderr index b739268dacd55..bfb4bb9d0d2fd 100644 --- a/src/tools/clippy/tests/ui/let_if_seq.stderr +++ b/src/tools/clippy/tests/ui/let_if_seq.stderr @@ -11,6 +11,7 @@ LL | | } | = note: you might not need `mut` at all = note: `-D clippy::useless-let-if-seq` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::useless_let_if_seq)]` error: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:73:5 diff --git a/src/tools/clippy/tests/ui/let_underscore_future.stderr b/src/tools/clippy/tests/ui/let_underscore_future.stderr index e3a628236e708..3ba99c6377b73 100644 --- a/src/tools/clippy/tests/ui/let_underscore_future.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_future.stderr @@ -6,6 +6,7 @@ LL | let _ = some_async_fn(); | = help: consider awaiting the future or dropping explicitly with `std::mem::drop` = note: `-D clippy::let-underscore-future` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_underscore_future)]` error: non-binding `let` on a future --> $DIR/let_underscore_future.rs:18:5 @@ -30,6 +31,7 @@ LL | fn do_something_to_future(future: &mut impl Future) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&impl Future` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: aborting due to 4 previous errors diff --git a/src/tools/clippy/tests/ui/let_underscore_lock.stderr b/src/tools/clippy/tests/ui/let_underscore_lock.stderr index 9c9ff9c917c87..ac6e0978e637b 100644 --- a/src/tools/clippy/tests/ui/let_underscore_lock.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_lock.stderr @@ -6,6 +6,7 @@ LL | let _ = p_m.lock(); | = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` = note: `-D clippy::let-underscore-lock` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_underscore_lock)]` error: non-binding `let` on a synchronization lock --> $DIR/let_underscore_lock.rs:14:5 diff --git a/src/tools/clippy/tests/ui/let_underscore_must_use.stderr b/src/tools/clippy/tests/ui/let_underscore_must_use.stderr index 5cd02a6e81221..83d0372e668cc 100644 --- a/src/tools/clippy/tests/ui/let_underscore_must_use.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_must_use.stderr @@ -6,6 +6,7 @@ LL | let _ = f(); | = help: consider explicitly using function result = note: `-D clippy::let-underscore-must-use` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_underscore_must_use)]` error: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:69:5 diff --git a/src/tools/clippy/tests/ui/let_underscore_untyped.stderr b/src/tools/clippy/tests/ui/let_underscore_untyped.stderr index e0c39b6eeafef..0e5647fa1e92c 100644 --- a/src/tools/clippy/tests/ui/let_underscore_untyped.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_untyped.stderr @@ -10,6 +10,7 @@ help: consider adding a type annotation LL | let _ = a(); | ^ = note: `-D clippy::let-underscore-untyped` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_underscore_untyped)]` error: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:52:5 diff --git a/src/tools/clippy/tests/ui/let_unit.stderr b/src/tools/clippy/tests/ui/let_unit.stderr index c54d4392a3469..de106f50e0e7c 100644 --- a/src/tools/clippy/tests/ui/let_unit.stderr +++ b/src/tools/clippy/tests/ui/let_unit.stderr @@ -5,6 +5,7 @@ LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `println!("x");` | = note: `-D clippy::let-unit-value` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]` error: this let-binding has unit value --> $DIR/let_unit.rs:16:9 diff --git a/src/tools/clippy/tests/ui/let_with_type_underscore.stderr b/src/tools/clippy/tests/ui/let_with_type_underscore.stderr index a749552c7fac8..d4c9ba19c39f5 100644 --- a/src/tools/clippy/tests/ui/let_with_type_underscore.stderr +++ b/src/tools/clippy/tests/ui/let_with_type_underscore.stderr @@ -10,6 +10,7 @@ help: remove the explicit type `_` declaration LL | let x: _ = 1; | ^^^ = note: `-D clippy::let-with-type-underscore` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::let_with_type_underscore)]` error: variable declared with type underscore --> $DIR/let_with_type_underscore.rs:16:5 diff --git a/src/tools/clippy/tests/ui/lines_filter_map_ok.stderr b/src/tools/clippy/tests/ui/lines_filter_map_ok.stderr index 4244d85b448ad..fa2ba0a9a4625 100644 --- a/src/tools/clippy/tests/ui/lines_filter_map_ok.stderr +++ b/src/tools/clippy/tests/ui/lines_filter_map_ok.stderr @@ -10,6 +10,7 @@ note: this expression returning a `std::io::Lines` may produce an infinite numbe LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::lines-filter-map-ok` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::lines_filter_map_ok)]` error: `flat_map()` will run forever if the iterator repeatedly produces an `Err` --> $DIR/lines_filter_map_ok.rs:12:31 diff --git a/src/tools/clippy/tests/ui/linkedlist.stderr b/src/tools/clippy/tests/ui/linkedlist.stderr index b31b0cd9314e6..792af4dd06e8d 100644 --- a/src/tools/clippy/tests/ui/linkedlist.stderr +++ b/src/tools/clippy/tests/ui/linkedlist.stderr @@ -6,6 +6,7 @@ LL | const C: LinkedList = LinkedList::new(); | = help: a `VecDeque` might work = note: `-D clippy::linkedlist` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::linkedlist)]` error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:10:11 diff --git a/src/tools/clippy/tests/ui/literals.stderr b/src/tools/clippy/tests/ui/literals.stderr index 7c79436752fca..bc755b1123db3 100644 --- a/src/tools/clippy/tests/ui/literals.stderr +++ b/src/tools/clippy/tests/ui/literals.stderr @@ -5,6 +5,7 @@ LL | let ok4 = 0xab_cd_i32; | ^^^^^^^^^^^ help: remove the underscore: `0xab_cdi32` | = note: `-D clippy::separated-literal-suffix` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::separated_literal_suffix)]` error: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:16:15 @@ -25,6 +26,7 @@ LL | let fail1 = 0xabCD; | ^^^^^^ | = note: `-D clippy::mixed-case-hex-literals` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mixed_case_hex_literals)]` error: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:23:17 @@ -57,6 +59,7 @@ LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ help: add an underscore: `000_123_usize` | = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unseparated_literal_suffix)]` error: this is a decimal constant --> $DIR/literals.rs:29:27 @@ -65,6 +68,7 @@ LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ | = note: `-D clippy::zero-prefixed-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::zero_prefixed_literal)]` help: if you mean to use a decimal constant, remove the `0` to avoid confusion | LL | let fail_multi_zero = 123usize; @@ -108,6 +112,7 @@ LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores --> $DIR/literals.rs:55:18 @@ -128,6 +133,7 @@ LL | let fail24 = 0xAB_ABC_AB; | ^^^^^^^^^^^ help: consider: `0x0ABA_BCAB` | = note: `-D clippy::unusual-byte-groupings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: this is a decimal constant --> $DIR/literals.rs:70:13 diff --git a/src/tools/clippy/tests/ui/lossy_float_literal.stderr b/src/tools/clippy/tests/ui/lossy_float_literal.stderr index d2193c0c81955..ea787f5726aaf 100644 --- a/src/tools/clippy/tests/ui/lossy_float_literal.stderr +++ b/src/tools/clippy/tests/ui/lossy_float_literal.stderr @@ -5,6 +5,7 @@ LL | let _: f32 = 16_777_217.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_216.0` | = note: `-D clippy::lossy-float-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::lossy_float_literal)]` error: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:7:18 diff --git a/src/tools/clippy/tests/ui/macro_use_imports.stderr b/src/tools/clippy/tests/ui/macro_use_imports.stderr index 2259e5abf2f37..6de869699ec6d 100644 --- a/src/tools/clippy/tests/ui/macro_use_imports.stderr +++ b/src/tools/clippy/tests/ui/macro_use_imports.stderr @@ -5,6 +5,7 @@ LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` | = note: `-D clippy::macro-use-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::macro_use_imports)]` error: `macro_use` attributes are no longer needed in the Rust 2018 edition --> $DIR/macro_use_imports.rs:23:5 diff --git a/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr b/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr index 1bf61fa33bf04..b19cca4d5f91d 100644 --- a/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr +++ b/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qaqaq{:?}", a);` | = note: `-D clippy::manual-assert` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_assert)]` error: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:33:5 diff --git a/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr b/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr index 1bf61fa33bf04..b19cca4d5f91d 100644 --- a/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr +++ b/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qaqaq{:?}", a);` | = note: `-D clippy::manual-assert` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_assert)]` error: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:33:5 diff --git a/src/tools/clippy/tests/ui/manual_async_fn.stderr b/src/tools/clippy/tests/ui/manual_async_fn.stderr index b196614dff96b..c0c471912e494 100644 --- a/src/tools/clippy/tests/ui/manual_async_fn.stderr +++ b/src/tools/clippy/tests/ui/manual_async_fn.stderr @@ -5,6 +5,7 @@ LL | fn fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::manual-async-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_async_fn)]` help: make the function `async` and return the output of the future directly | LL | async fn fut() -> i32 { diff --git a/src/tools/clippy/tests/ui/manual_bits.stderr b/src/tools/clippy/tests/ui/manual_bits.stderr index 95910650da93b..2f2ed5909c1a5 100644 --- a/src/tools/clippy/tests/ui/manual_bits.stderr +++ b/src/tools/clippy/tests/ui/manual_bits.stderr @@ -5,6 +5,7 @@ LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` | = note: `-D clippy::manual-bits` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_bits)]` error: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:15:5 diff --git a/src/tools/clippy/tests/ui/manual_clamp.stderr b/src/tools/clippy/tests/ui/manual_clamp.stderr index 95e0cf5d4ec51..2fa68ede12614 100644 --- a/src/tools/clippy/tests/ui/manual_clamp.stderr +++ b/src/tools/clippy/tests/ui/manual_clamp.stderr @@ -12,6 +12,7 @@ LL | | } | = note: clamp will panic if max < min = note: `-D clippy::manual-clamp` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_clamp)]` error: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:113:5 diff --git a/src/tools/clippy/tests/ui/manual_filter.stderr b/src/tools/clippy/tests/ui/manual_filter.stderr index a2d56f87b64ab..1490f209735a9 100644 --- a/src/tools/clippy/tests/ui/manual_filter.stderr +++ b/src/tools/clippy/tests/ui/manual_filter.stderr @@ -11,6 +11,7 @@ LL | | }; | |_____^ help: try: `Some(0).filter(|&x| x <= 0)` | = note: `-D clippy::manual-filter` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_filter)]` error: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:16:5 diff --git a/src/tools/clippy/tests/ui/manual_filter_map.stderr b/src/tools/clippy/tests/ui/manual_filter_map.stderr index 5b8a553f84f9e..0bfc1f5c7450b 100644 --- a/src/tools/clippy/tests/ui/manual_filter_map.stderr +++ b/src/tools/clippy/tests/ui/manual_filter_map.stderr @@ -10,6 +10,7 @@ note: the suggestion might change the behavior of the program when merging `filt LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^ = note: `-D clippy::manual-filter-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_filter_map)]` error: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:11:19 @@ -98,6 +99,7 @@ LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` | = note: `-D clippy::manual-find-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_find_map)]` error: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:34:28 diff --git a/src/tools/clippy/tests/ui/manual_find.stderr b/src/tools/clippy/tests/ui/manual_find.stderr index 41aa00a8bc14b..286ad54625d7d 100644 --- a/src/tools/clippy/tests/ui/manual_find.stderr +++ b/src/tools/clippy/tests/ui/manual_find.stderr @@ -12,6 +12,7 @@ LL | | None | = note: you may need to dereference some variables = note: `-D clippy::manual-find` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` --> $DIR/manual_find.rs:16:5 diff --git a/src/tools/clippy/tests/ui/manual_find_fixable.stderr b/src/tools/clippy/tests/ui/manual_find_fixable.stderr index 2c6f79e928a61..387d1509c136c 100644 --- a/src/tools/clippy/tests/ui/manual_find_fixable.stderr +++ b/src/tools/clippy/tests/ui/manual_find_fixable.stderr @@ -10,6 +10,7 @@ LL | | None | |________^ help: replace with an iterator: `ARRAY.iter().find(|&&v| v == n).copied()` | = note: `-D clippy::manual-find` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:19:5 diff --git a/src/tools/clippy/tests/ui/manual_find_map.stderr b/src/tools/clippy/tests/ui/manual_find_map.stderr index 67523711cc8e4..0dc9ae1df035f 100644 --- a/src/tools/clippy/tests/ui/manual_find_map.stderr +++ b/src/tools/clippy/tests/ui/manual_find_map.stderr @@ -10,6 +10,7 @@ note: the suggestion might change the behavior of the program when merging `filt LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^ = note: `-D clippy::manual-find-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_find_map)]` error: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:11:19 diff --git a/src/tools/clippy/tests/ui/manual_flatten.stderr b/src/tools/clippy/tests/ui/manual_flatten.stderr index 227bf3c5eaedf..aa5c2104f6548 100644 --- a/src/tools/clippy/tests/ui/manual_flatten.stderr +++ b/src/tools/clippy/tests/ui/manual_flatten.stderr @@ -20,6 +20,7 @@ LL | | println!("{}", y); LL | | } | |_________^ = note: `-D clippy::manual-flatten` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_flatten)]` error: unnecessary `if let` since only the `Ok` variant of the iterator element is used --> $DIR/manual_flatten.rs:16:5 diff --git a/src/tools/clippy/tests/ui/manual_float_methods.stderr b/src/tools/clippy/tests/ui/manual_float_methods.stderr index 35beb6fec7334..680ab2efa094f 100644 --- a/src/tools/clippy/tests/ui/manual_float_methods.stderr +++ b/src/tools/clippy/tests/ui/manual_float_methods.stderr @@ -5,6 +5,7 @@ LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` | = note: `-D clippy::manual-is-infinite` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_is_infinite)]` error: manually checking if a float is finite --> $DIR/manual_float_methods.rs:24:8 @@ -13,6 +14,7 @@ LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::manual-is-finite` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_is_finite)]` help: use the dedicated method instead | LL | if x.is_finite() {} diff --git a/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr b/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr index 5537f5642a23c..56d0b9cd77b26 100644 --- a/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr +++ b/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr @@ -5,6 +5,7 @@ LL | let duration = Instant::now() - prev_instant; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `prev_instant.elapsed()` | = note: `-D clippy::manual-instant-elapsed` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_instant_elapsed)]` error: manual implementation of `Instant::elapsed` --> $DIR/manual_instant_elapsed.rs:26:5 diff --git a/src/tools/clippy/tests/ui/manual_is_ascii_check.stderr b/src/tools/clippy/tests/ui/manual_is_ascii_check.stderr index 0497259b69b4d..e0fb46e59fa14 100644 --- a/src/tools/clippy/tests/ui/manual_is_ascii_check.stderr +++ b/src/tools/clippy/tests/ui/manual_is_ascii_check.stderr @@ -5,6 +5,7 @@ LL | assert!(matches!('x', 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_lowercase()` | = note: `-D clippy::manual-is-ascii-check` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_is_ascii_check)]` error: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:6:13 diff --git a/src/tools/clippy/tests/ui/manual_let_else.stderr b/src/tools/clippy/tests/ui/manual_let_else.stderr index 309ce3986f370..49dbd7615e027 100644 --- a/src/tools/clippy/tests/ui/manual_let_else.stderr +++ b/src/tools/clippy/tests/ui/manual_let_else.stderr @@ -5,6 +5,7 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };` | = note: `-D clippy::manual-let-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:28:5 diff --git a/src/tools/clippy/tests/ui/manual_let_else_match.stderr b/src/tools/clippy/tests/ui/manual_let_else_match.stderr index fb7d83f32440b..8ca2c84072d0f 100644 --- a/src/tools/clippy/tests/ui/manual_let_else_match.stderr +++ b/src/tools/clippy/tests/ui/manual_let_else_match.stderr @@ -10,6 +10,7 @@ LL | | }; | |______^ help: consider writing: `let Some(v) = g() else { return };` | = note: `-D clippy::manual-let-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:43:5 diff --git a/src/tools/clippy/tests/ui/manual_let_else_question_mark.stderr b/src/tools/clippy/tests/ui/manual_let_else_question_mark.stderr index ea35618e3c108..bf0b1bbf0dd3b 100644 --- a/src/tools/clippy/tests/ui/manual_let_else_question_mark.stderr +++ b/src/tools/clippy/tests/ui/manual_let_else_question_mark.stderr @@ -5,6 +5,7 @@ LL | let Some(v) = g() else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let v = g()?;` | = note: `-D clippy::question-mark` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::question_mark)]` error: this `let...else` may be rewritten with the `?` operator --> $DIR/manual_let_else_question_mark.rs:35:5 @@ -29,6 +30,7 @@ LL | | }; | |______^ | = note: `-D clippy::manual-let-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` help: consider writing | LL ~ let Some(v) = g() else { diff --git a/src/tools/clippy/tests/ui/manual_main_separator_str.stderr b/src/tools/clippy/tests/ui/manual_main_separator_str.stderr index f7612efa5006e..3e92bd0238c3a 100644 --- a/src/tools/clippy/tests/ui/manual_main_separator_str.stderr +++ b/src/tools/clippy/tests/ui/manual_main_separator_str.stderr @@ -5,6 +5,7 @@ LL | let _: &str = &MAIN_SEPARATOR.to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` | = note: `-D clippy::manual-main-separator-str` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_main_separator_str)]` error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` --> $DIR/manual_main_separator_str.rs:22:17 diff --git a/src/tools/clippy/tests/ui/manual_map_option.stderr b/src/tools/clippy/tests/ui/manual_map_option.stderr index 3e5fd923df826..ff6ed974d4a12 100644 --- a/src/tools/clippy/tests/ui/manual_map_option.stderr +++ b/src/tools/clippy/tests/ui/manual_map_option.stderr @@ -8,6 +8,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|_| 2)` | = note: `-D clippy::manual-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_map)]` error: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:18:5 diff --git a/src/tools/clippy/tests/ui/manual_map_option_2.stderr b/src/tools/clippy/tests/ui/manual_map_option_2.stderr index e71000dd5d540..bf242c0416c27 100644 --- a/src/tools/clippy/tests/ui/manual_map_option_2.stderr +++ b/src/tools/clippy/tests/ui/manual_map_option_2.stderr @@ -12,6 +12,7 @@ LL | | }; | |_____^ | = note: `-D clippy::manual-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_map)]` help: try | LL ~ let _ = Some(0).map(|x| { diff --git a/src/tools/clippy/tests/ui/manual_memcpy/with_loop_counters.stderr b/src/tools/clippy/tests/ui/manual_memcpy/with_loop_counters.stderr index e23c95dc8a4af..3f000fbab6994 100644 --- a/src/tools/clippy/tests/ui/manual_memcpy/with_loop_counters.stderr +++ b/src/tools/clippy/tests/ui/manual_memcpy/with_loop_counters.stderr @@ -10,6 +10,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..src.len()].copy_from_slice(&src[..(src.len() - 3)]);` | = note: `-D clippy::manual-memcpy` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:13:5 diff --git a/src/tools/clippy/tests/ui/manual_memcpy/without_loop_counters.stderr b/src/tools/clippy/tests/ui/manual_memcpy/without_loop_counters.stderr index 4f02c698a0d6b..b9dbda6ede71f 100644 --- a/src/tools/clippy/tests/ui/manual_memcpy/without_loop_counters.stderr +++ b/src/tools/clippy/tests/ui/manual_memcpy/without_loop_counters.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[..]);` | = note: `-D clippy::manual-memcpy` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:15:5 diff --git a/src/tools/clippy/tests/ui/manual_next_back.stderr b/src/tools/clippy/tests/ui/manual_next_back.stderr index d2e52b40b4f4e..a63d266dd623f 100644 --- a/src/tools/clippy/tests/ui/manual_next_back.stderr +++ b/src/tools/clippy/tests/ui/manual_next_back.stderr @@ -5,6 +5,7 @@ LL | let _ = (0..10).rev().next().unwrap(); | ^^^^^^^^^^^^^ help: use: `.next_back()` | = note: `-D clippy::manual-next-back` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_next_back)]` error: manual backwards iteration --> $DIR/manual_next_back.rs:33:32 diff --git a/src/tools/clippy/tests/ui/manual_non_exhaustive_enum.stderr b/src/tools/clippy/tests/ui/manual_non_exhaustive_enum.stderr index ab068d4827e71..ce7e21c94bbdc 100644 --- a/src/tools/clippy/tests/ui/manual_non_exhaustive_enum.stderr +++ b/src/tools/clippy/tests/ui/manual_non_exhaustive_enum.stderr @@ -20,6 +20,7 @@ help: remove this variant LL | _C, | ^^ = note: `-D clippy::manual-non-exhaustive` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_non_exhaustive)]` error: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_enum.rs:15:1 diff --git a/src/tools/clippy/tests/ui/manual_non_exhaustive_struct.stderr b/src/tools/clippy/tests/ui/manual_non_exhaustive_struct.stderr index c062af6356c46..028b8ff763915 100644 --- a/src/tools/clippy/tests/ui/manual_non_exhaustive_struct.stderr +++ b/src/tools/clippy/tests/ui/manual_non_exhaustive_struct.stderr @@ -19,6 +19,7 @@ help: remove this field LL | _c: (), | ^^^^^^ = note: `-D clippy::manual-non-exhaustive` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_non_exhaustive)]` error: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_struct.rs:14:5 diff --git a/src/tools/clippy/tests/ui/manual_ok_or.stderr b/src/tools/clippy/tests/ui/manual_ok_or.stderr index 65459a097384b..ddb2cf261e404 100644 --- a/src/tools/clippy/tests/ui/manual_ok_or.stderr +++ b/src/tools/clippy/tests/ui/manual_ok_or.stderr @@ -5,6 +5,7 @@ LL | foo.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` | = note: `-D clippy::manual-ok-or` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_ok_or)]` error: this pattern reimplements `Option::ok_or` --> $DIR/manual_ok_or.rs:14:5 diff --git a/src/tools/clippy/tests/ui/manual_range_patterns.stderr b/src/tools/clippy/tests/ui/manual_range_patterns.stderr index 1cf58d7df6a3f..3eee39af86e7b 100644 --- a/src/tools/clippy/tests/ui/manual_range_patterns.stderr +++ b/src/tools/clippy/tests/ui/manual_range_patterns.stderr @@ -5,6 +5,7 @@ LL | let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` | = note: `-D clippy::manual-range-patterns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_range_patterns)]` error: this OR pattern can be rewritten using a range --> $DIR/manual_range_patterns.rs:9:25 diff --git a/src/tools/clippy/tests/ui/manual_rem_euclid.stderr b/src/tools/clippy/tests/ui/manual_rem_euclid.stderr index c93d37a8bd4d7..f296f264665ca 100644 --- a/src/tools/clippy/tests/ui/manual_rem_euclid.stderr +++ b/src/tools/clippy/tests/ui/manual_rem_euclid.stderr @@ -5,6 +5,7 @@ LL | let _: i32 = ((value % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` | = note: `-D clippy::manual-rem-euclid` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_rem_euclid)]` error: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:14:18 diff --git a/src/tools/clippy/tests/ui/manual_retain.stderr b/src/tools/clippy/tests/ui/manual_retain.stderr index cc1b449d25ab1..0c5b1383b6aed 100644 --- a/src/tools/clippy/tests/ui/manual_retain.stderr +++ b/src/tools/clippy/tests/ui/manual_retain.stderr @@ -5,6 +5,7 @@ LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` | = note: `-D clippy::manual-retain` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_retain)]` error: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:23:5 diff --git a/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr b/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr index 06f578b3c1d8c..dc36a5ee7c692 100644 --- a/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr +++ b/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr @@ -5,6 +5,7 @@ LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u32.saturating_add(1)` | = note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]` error: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:7:13 diff --git a/src/tools/clippy/tests/ui/manual_slice_size_calculation.stderr b/src/tools/clippy/tests/ui/manual_slice_size_calculation.stderr index 812d02c96fcec..ebdb748137a90 100644 --- a/src/tools/clippy/tests/ui/manual_slice_size_calculation.stderr +++ b/src/tools/clippy/tests/ui/manual_slice_size_calculation.stderr @@ -5,6 +5,7 @@ LL | let _ = s_i32.len() * size_of::(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` | = note: `-D clippy::manual-slice-size-calculation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_slice_size_calculation)]` error: manual slice size calculation --> $DIR/manual_slice_size_calculation.rs:16:13 diff --git a/src/tools/clippy/tests/ui/manual_split_once.stderr b/src/tools/clippy/tests/ui/manual_split_once.stderr index d425f0881c0b6..494a035edc3ab 100644 --- a/src/tools/clippy/tests/ui/manual_split_once.stderr +++ b/src/tools/clippy/tests/ui/manual_split_once.stderr @@ -5,6 +5,7 @@ LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` | = note: `-D clippy::manual-split-once` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_split_once)]` error: manual implementation of `split_once` --> $DIR/manual_split_once.rs:12:13 diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.stderr b/src/tools/clippy/tests/ui/manual_str_repeat.stderr index b92835884d9c1..9a13aa9722737 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.stderr +++ b/src/tools/clippy/tests/ui/manual_str_repeat.stderr @@ -5,6 +5,7 @@ LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` | = note: `-D clippy::manual-str-repeat` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_str_repeat)]` error: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:8:21 diff --git a/src/tools/clippy/tests/ui/manual_string_new.stderr b/src/tools/clippy/tests/ui/manual_string_new.stderr index 02aac6fdfeb04..399652d3fecba 100644 --- a/src/tools/clippy/tests/ui/manual_string_new.stderr +++ b/src/tools/clippy/tests/ui/manual_string_new.stderr @@ -5,6 +5,7 @@ LL | let _ = "".to_string(); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` | = note: `-D clippy::manual-string-new` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_string_new)]` error: empty String is being created manually --> $DIR/manual_string_new.rs:16:13 diff --git a/src/tools/clippy/tests/ui/manual_strip.stderr b/src/tools/clippy/tests/ui/manual_strip.stderr index e7be2b4b9cec2..0bf6975b1e363 100644 --- a/src/tools/clippy/tests/ui/manual_strip.stderr +++ b/src/tools/clippy/tests/ui/manual_strip.stderr @@ -10,6 +10,7 @@ note: the prefix was tested here LL | if s.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::manual-strip` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_strip)]` help: try using the `strip_prefix` method | LL ~ if let Some() = s.strip_prefix("ab") { diff --git a/src/tools/clippy/tests/ui/manual_try_fold.stderr b/src/tools/clippy/tests/ui/manual_try_fold.stderr index f1bb97c6d0f3c..4eb3e302b2143 100644 --- a/src/tools/clippy/tests/ui/manual_try_fold.stderr +++ b/src/tools/clippy/tests/ui/manual_try_fold.stderr @@ -5,6 +5,7 @@ LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` | = note: `-D clippy::manual-try-fold` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_try_fold)]` error: usage of `Iterator::fold` on a type that implements `Try` --> $DIR/manual_try_fold.rs:63:10 diff --git a/src/tools/clippy/tests/ui/manual_unwrap_or.stderr b/src/tools/clippy/tests/ui/manual_unwrap_or.stderr index 8b6de5d18bf82..3a0759dccaf20 100644 --- a/src/tools/clippy/tests/ui/manual_unwrap_or.stderr +++ b/src/tools/clippy/tests/ui/manual_unwrap_or.stderr @@ -8,6 +8,7 @@ LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(42)` | = note: `-D clippy::manual-unwrap-or` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or)]` error: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:12:5 diff --git a/src/tools/clippy/tests/ui/manual_while_let_some.stderr b/src/tools/clippy/tests/ui/manual_while_let_some.stderr index 33dd313b21a51..37387c8c320f2 100644 --- a/src/tools/clippy/tests/ui/manual_while_let_some.stderr +++ b/src/tools/clippy/tests/ui/manual_while_let_some.stderr @@ -5,6 +5,7 @@ LL | let number = numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::manual-while-let-some` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_while_let_some)]` help: consider using a `while..let` loop | LL ~ while let Some(number) = numbers.pop() { diff --git a/src/tools/clippy/tests/ui/many_single_char_names.stderr b/src/tools/clippy/tests/ui/many_single_char_names.stderr index 4f5a69a9b6092..688158cff6b03 100644 --- a/src/tools/clippy/tests/ui/many_single_char_names.stderr +++ b/src/tools/clippy/tests/ui/many_single_char_names.stderr @@ -11,6 +11,7 @@ LL | let e: i32; | ^ | = note: `-D clippy::many-single-char-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::many_single_char_names)]` error: 6 bindings with single-character names in scope --> $DIR/many_single_char_names.rs:5:9 diff --git a/src/tools/clippy/tests/ui/map_clone.stderr b/src/tools/clippy/tests/ui/map_clone.stderr index d84a5bf8d4de6..eb11f084887d6 100644 --- a/src/tools/clippy/tests/ui/map_clone.stderr +++ b/src/tools/clippy/tests/ui/map_clone.stderr @@ -5,6 +5,7 @@ LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()` | = note: `-D clippy::map-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_clone)]` error: you are using an explicit closure for cloning elements --> $DIR/map_clone.rs:12:26 diff --git a/src/tools/clippy/tests/ui/map_collect_result_unit.stderr b/src/tools/clippy/tests/ui/map_collect_result_unit.stderr index 3108582aa43be..1a505d4cecc32 100644 --- a/src/tools/clippy/tests/ui/map_collect_result_unit.stderr +++ b/src/tools/clippy/tests/ui/map_collect_result_unit.stderr @@ -5,6 +5,7 @@ LL | let _ = (0..3).map(|t| Err(t + 1)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))` | = note: `-D clippy::map-collect-result-unit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_collect_result_unit)]` error: `.map().collect()` can be replaced with `.try_for_each()` --> $DIR/map_collect_result_unit.rs:6:32 diff --git a/src/tools/clippy/tests/ui/map_err.stderr b/src/tools/clippy/tests/ui/map_err.stderr index d44403a84a564..6a845c84a2a9d 100644 --- a/src/tools/clippy/tests/ui/map_err.stderr +++ b/src/tools/clippy/tests/ui/map_err.stderr @@ -6,6 +6,7 @@ LL | println!("{:?}", x.map_err(|_| Errors::Ignored)); | = help: consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`) = note: `-D clippy::map-err-ignore` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_err_ignore)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/map_flatten.stderr b/src/tools/clippy/tests/ui/map_flatten.stderr index 88fdd04c02367..a65d8f75ddd2a 100644 --- a/src/tools/clippy/tests/ui/map_flatten.stderr +++ b/src/tools/clippy/tests/ui/map_flatten.stderr @@ -12,6 +12,7 @@ LL | | .flatten(); | |__________________^ | = note: `-D clippy::map-flatten` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_flatten)]` help: try replacing `map` with `and_then` and remove the `.flatten()` | LL ~ .and_then(|x| { diff --git a/src/tools/clippy/tests/ui/map_flatten_fixable.stderr b/src/tools/clippy/tests/ui/map_flatten_fixable.stderr index 865929421532c..e5387eead2e0c 100644 --- a/src/tools/clippy/tests/ui/map_flatten_fixable.stderr +++ b/src/tools/clippy/tests/ui/map_flatten_fixable.stderr @@ -5,6 +5,7 @@ LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().coll | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)` | = note: `-D clippy::map-flatten` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_flatten)]` error: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:17:47 diff --git a/src/tools/clippy/tests/ui/map_identity.stderr b/src/tools/clippy/tests/ui/map_identity.stderr index 97ff7ea70d78b..8942fd7c0d263 100644 --- a/src/tools/clippy/tests/ui/map_identity.stderr +++ b/src/tools/clippy/tests/ui/map_identity.stderr @@ -5,6 +5,7 @@ LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect(); | ^^^^^^^^^^^^^^^^^^ help: remove the call to `map` | = note: `-D clippy::map-identity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_identity)]` error: unnecessary map of the identity function --> $DIR/map_identity.rs:8:57 diff --git a/src/tools/clippy/tests/ui/map_unwrap_or.stderr b/src/tools/clippy/tests/ui/map_unwrap_or.stderr index 5b3c61acf7477..7b7eeb322a55b 100644 --- a/src/tools/clippy/tests/ui/map_unwrap_or.stderr +++ b/src/tools/clippy/tests/ui/map_unwrap_or.stderr @@ -8,6 +8,7 @@ LL | | .unwrap_or(0); | |_____________________^ | = note: `-D clippy::map-unwrap-or` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_unwrap_or)]` help: use `map_or(, )` instead | LL - let _ = opt.map(|x| x + 1) diff --git a/src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr b/src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr index 0635a8c79bdc1..ca611ac9d7ff1 100644 --- a/src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr +++ b/src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr @@ -8,6 +8,7 @@ LL | | .unwrap_or_else(|| 0); | |_____________________________^ help: try: `opt.map_or_else(|| 0, |x| x + 1)` | = note: `-D clippy::map-unwrap-or` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::map_unwrap_or)]` error: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead --> $DIR/map_unwrap_or_fixable.rs:46:13 diff --git a/src/tools/clippy/tests/ui/match_as_ref.stderr b/src/tools/clippy/tests/ui/match_as_ref.stderr index 79ca203ee13a6..cb0191370eaa0 100644 --- a/src/tools/clippy/tests/ui/match_as_ref.stderr +++ b/src/tools/clippy/tests/ui/match_as_ref.stderr @@ -9,6 +9,7 @@ LL | | }; | |_____^ help: try: `owned.as_ref()` | = note: `-D clippy::match-as-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_as_ref)]` error: use `as_mut()` instead --> $DIR/match_as_ref.rs:12:39 diff --git a/src/tools/clippy/tests/ui/match_bool.stderr b/src/tools/clippy/tests/ui/match_bool.stderr index 351ebfc08cdbd..369f4e1c6fab3 100644 --- a/src/tools/clippy/tests/ui/match_bool.stderr +++ b/src/tools/clippy/tests/ui/match_bool.stderr @@ -5,6 +5,7 @@ LL | match test && test { | ^^^^^^^^^^^^ help: try: `test` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:7:5 diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr index 06006e26aff21..c702523783e73 100644 --- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr +++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr @@ -9,6 +9,7 @@ LL | | }; | |_____^ help: try: `matches!(x, Some(0))` | = note: `-D clippy::match-like-matches-macro` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` error: redundant pattern matching, consider using `is_some()` --> $DIR/match_expr_like_matches_macro.rs:20:14 @@ -21,6 +22,7 @@ LL | | }; | |_____^ help: try: `x.is_some()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` --> $DIR/match_expr_like_matches_macro.rs:26:14 diff --git a/src/tools/clippy/tests/ui/match_on_vec_items.stderr b/src/tools/clippy/tests/ui/match_on_vec_items.stderr index 71038aaad49fb..140a458cb9a4c 100644 --- a/src/tools/clippy/tests/ui/match_on_vec_items.stderr +++ b/src/tools/clippy/tests/ui/match_on_vec_items.stderr @@ -5,6 +5,7 @@ LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` | = note: `-D clippy::match-on-vec-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_on_vec_items)]` error: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:19:11 diff --git a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr index ceec40e8def0f..322c704f2aa28 100644 --- a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr +++ b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr @@ -10,6 +10,7 @@ note: overlaps with this LL | 0..=11 => println!("0..=11"), | ^^^^^^ = note: `-D clippy::match-overlapping-arm` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_overlapping_arm)]` error: some ranges overlap --> $DIR/match_overlapping_arm.rs:19:9 diff --git a/src/tools/clippy/tests/ui/match_ref_pats.stderr b/src/tools/clippy/tests/ui/match_ref_pats.stderr index c65a2d100bee9..e3bb2824aa070 100644 --- a/src/tools/clippy/tests/ui/match_ref_pats.stderr +++ b/src/tools/clippy/tests/ui/match_ref_pats.stderr @@ -8,6 +8,7 @@ LL | | } | |_________^ | = note: `-D clippy::match-ref-pats` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_ref_pats)]` help: instead of prefixing all patterns with `&`, you can dereference the expression | LL ~ match *v { @@ -38,6 +39,7 @@ LL | if let &None = a { | -------^^^^^---- help: try: `if a.is_none()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` --> $DIR/match_ref_pats.rs:42:12 diff --git a/src/tools/clippy/tests/ui/match_result_ok.stderr b/src/tools/clippy/tests/ui/match_result_ok.stderr index 2cf38624e576d..de0361bd6b41e 100644 --- a/src/tools/clippy/tests/ui/match_result_ok.stderr +++ b/src/tools/clippy/tests/ui/match_result_ok.stderr @@ -5,6 +5,7 @@ LL | if let Some(y) = x.parse().ok() { y } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::match-result-ok` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_result_ok)]` help: consider matching on `Ok(y)` and removing the call to `ok` instead | LL | if let Ok(y) = x.parse() { y } else { 0 } diff --git a/src/tools/clippy/tests/ui/match_same_arms.stderr b/src/tools/clippy/tests/ui/match_same_arms.stderr index 5f7e2b4755675..824dcfdce8374 100644 --- a/src/tools/clippy/tests/ui/match_same_arms.stderr +++ b/src/tools/clippy/tests/ui/match_same_arms.stderr @@ -11,6 +11,7 @@ note: `_` wildcard arm here LL | _ => 0, | ^^^^^^ = note: `-D clippy::match-same-arms` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm --> $DIR/match_same_arms.rs:18:9 diff --git a/src/tools/clippy/tests/ui/match_same_arms2.stderr b/src/tools/clippy/tests/ui/match_same_arms2.stderr index a734818757385..40b20c7e16d28 100644 --- a/src/tools/clippy/tests/ui/match_same_arms2.stderr +++ b/src/tools/clippy/tests/ui/match_same_arms2.stderr @@ -23,6 +23,7 @@ LL | | a LL | | }, | |_________^ = note: `-D clippy::match-same-arms` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm --> $DIR/match_same_arms2.rs:38:9 @@ -147,6 +148,7 @@ LL | | }; | |_____^ help: try: `!matches!(x, E::A | E::B)` | = note: `-D clippy::match-like-matches-macro` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` error: this match arm has an identical body to another arm --> $DIR/match_same_arms2.rs:199:9 diff --git a/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.stderr b/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.stderr index 9ee8f14ad90e2..a039536338bcb 100644 --- a/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.stderr +++ b/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.stderr @@ -11,6 +11,7 @@ note: `_` wildcard arm here LL | _ => panic!(), | ^^^^^^^^^^^^^ = note: `-D clippy::match-same-arms` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to the `_` wildcard arm --> $DIR/match_same_arms_non_exhaustive.rs:55:13 diff --git a/src/tools/clippy/tests/ui/match_single_binding.stderr b/src/tools/clippy/tests/ui/match_single_binding.stderr index 9d16af76c6af9..81ec200dfc7a0 100644 --- a/src/tools/clippy/tests/ui/match_single_binding.stderr +++ b/src/tools/clippy/tests/ui/match_single_binding.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::match-single-binding` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_single_binding)]` help: consider using a `let` statement | LL ~ let (x, y, z) = (a, b, c); diff --git a/src/tools/clippy/tests/ui/match_single_binding2.stderr b/src/tools/clippy/tests/ui/match_single_binding2.stderr index 17ef9c36767b8..e7b9ef8a1cda9 100644 --- a/src/tools/clippy/tests/ui/match_single_binding2.stderr +++ b/src/tools/clippy/tests/ui/match_single_binding2.stderr @@ -8,6 +8,7 @@ LL | | }, | |_____________^ | = note: `-D clippy::match-single-binding` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_single_binding)]` help: consider using a `let` statement | LL ~ Some((iter, _item)) => { diff --git a/src/tools/clippy/tests/ui/match_str_case_mismatch.stderr b/src/tools/clippy/tests/ui/match_str_case_mismatch.stderr index 3c946b30a90ec..f799a4698b943 100644 --- a/src/tools/clippy/tests/ui/match_str_case_mismatch.stderr +++ b/src/tools/clippy/tests/ui/match_str_case_mismatch.stderr @@ -5,6 +5,7 @@ LL | "Bar" => {}, | ^^^^^ | = note: `-D clippy::match-str-case-mismatch` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_str_case_mismatch)]` help: consider changing the case of this arm to respect `to_ascii_lowercase` | LL | "bar" => {}, diff --git a/src/tools/clippy/tests/ui/match_wild_err_arm.stderr b/src/tools/clippy/tests/ui/match_wild_err_arm.stderr index 696ba7303a96c..c120aec5b23b3 100644 --- a/src/tools/clippy/tests/ui/match_wild_err_arm.stderr +++ b/src/tools/clippy/tests/ui/match_wild_err_arm.stderr @@ -6,6 +6,7 @@ LL | Err(_) => panic!("err"), | = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_wild_err_arm)]` error: `Err(_)` matches all errors --> $DIR/match_wild_err_arm.rs:32:9 diff --git a/src/tools/clippy/tests/ui/match_wildcard_for_single_variants.stderr b/src/tools/clippy/tests/ui/match_wildcard_for_single_variants.stderr index dfb6e695aa999..e07d3bdd32e6b 100644 --- a/src/tools/clippy/tests/ui/match_wildcard_for_single_variants.stderr +++ b/src/tools/clippy/tests/ui/match_wildcard_for_single_variants.stderr @@ -5,6 +5,7 @@ LL | _ => (), | ^ help: try: `Self::Rgb(..)` | = note: `-D clippy::match-wildcard-for-single-variants` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::match_wildcard_for_single_variants)]` error: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:32:9 diff --git a/src/tools/clippy/tests/ui/mem_forget.stderr b/src/tools/clippy/tests/ui/mem_forget.stderr index dd2ea7518559f..a5ab150317a1b 100644 --- a/src/tools/clippy/tests/ui/mem_forget.stderr +++ b/src/tools/clippy/tests/ui/mem_forget.stderr @@ -6,6 +6,7 @@ LL | memstuff::forget(six); | = note: argument has type `std::sync::Arc` = note: `-D clippy::mem-forget` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mem_forget)]` error: usage of `mem::forget` on `Drop` type --> $DIR/mem_forget.rs:19:5 diff --git a/src/tools/clippy/tests/ui/mem_replace.stderr b/src/tools/clippy/tests/ui/mem_replace.stderr index 00f3ccbdbea6c..ae5f4e5340a2a 100644 --- a/src/tools/clippy/tests/ui/mem_replace.stderr +++ b/src/tools/clippy/tests/ui/mem_replace.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::mem_replace_option_with_none)]` error: replacing an `Option` with `None` --> $DIR/mem_replace.rs:16:13 @@ -19,6 +20,7 @@ LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` | = note: `-D clippy::mem-replace-with-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_default)]` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:24:13 diff --git a/src/tools/clippy/tests/ui/mem_replace_macro.stderr b/src/tools/clippy/tests/ui/mem_replace_macro.stderr index 35dda93da3d03..842ad3a8565cd 100644 --- a/src/tools/clippy/tests/ui/mem_replace_macro.stderr +++ b/src/tools/clippy/tests/ui/mem_replace_macro.stderr @@ -5,6 +5,7 @@ LL | inline!(std::mem::replace($s, Default::default())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::mem-replace-with-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_default)]` = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/methods.stderr b/src/tools/clippy/tests/ui/methods.stderr index 6be38b24fbda2..e32b3b336af65 100644 --- a/src/tools/clippy/tests/ui/methods.stderr +++ b/src/tools/clippy/tests/ui/methods.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ | = note: `-D clippy::new-ret-no-self` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::new_ret_no_self)]` error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> $DIR/methods.rs:124:13 @@ -19,6 +20,7 @@ LL | | ).next(); | |___________________________^ | = note: `-D clippy::filter-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_next)]` error: aborting due to 2 previous errors diff --git a/src/tools/clippy/tests/ui/methods_fixable.stderr b/src/tools/clippy/tests/ui/methods_fixable.stderr index e4e626192ca2f..1bfe56d912b78 100644 --- a/src/tools/clippy/tests/ui/methods_fixable.stderr +++ b/src/tools/clippy/tests/ui/methods_fixable.stderr @@ -5,6 +5,7 @@ LL | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `v.iter().find(|&x| *x < 0)` | = note: `-D clippy::filter-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_next)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/methods_unfixable.stderr b/src/tools/clippy/tests/ui/methods_unfixable.stderr index 6e101fe16b09b..581a985e0b571 100644 --- a/src/tools/clippy/tests/ui/methods_unfixable.stderr +++ b/src/tools/clippy/tests/ui/methods_unfixable.stderr @@ -10,6 +10,7 @@ help: you will also need to make `iter` mutable, because `find` takes `&mut self LL | let iter = (0..10); | ^^^^ = note: `-D clippy::filter-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::filter_next)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/min_ident_chars.stderr b/src/tools/clippy/tests/ui/min_ident_chars.stderr index 4dff6588bb18b..253636cf91da1 100644 --- a/src/tools/clippy/tests/ui/min_ident_chars.stderr +++ b/src/tools/clippy/tests/ui/min_ident_chars.stderr @@ -5,6 +5,7 @@ LL | struct A { | ^ | = note: `-D clippy::min-ident-chars` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` error: this ident consists of a single char --> $DIR/min_ident_chars.rs:9:5 diff --git a/src/tools/clippy/tests/ui/min_max.stderr b/src/tools/clippy/tests/ui/min_max.stderr index 128394e627ca9..e9c64e56b619e 100644 --- a/src/tools/clippy/tests/ui/min_max.stderr +++ b/src/tools/clippy/tests/ui/min_max.stderr @@ -5,6 +5,7 @@ LL | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::min-max` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::min_max)]` error: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:25:5 diff --git a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr index 3d41510a8563c..795d043e2ac76 100644 --- a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr +++ b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr @@ -7,6 +7,7 @@ LL | #[cfg(hermit)] | help: try: `target_os = "hermit"` | = note: `-D clippy::mismatched-target-os` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mismatched_target_os)]` error: operating system used in target family position --> $DIR/mismatched_target_os_non_unix.rs:7:1 diff --git a/src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr b/src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr index 8f4c60fc9ca6d..261c33754e70e 100644 --- a/src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr +++ b/src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr @@ -8,6 +8,7 @@ LL | #[cfg(linux)] | = help: did you mean `unix`? = note: `-D clippy::mismatched-target-os` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mismatched_target_os)]` error: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:7:1 diff --git a/src/tools/clippy/tests/ui/mismatching_type_param_order.stderr b/src/tools/clippy/tests/ui/mismatching_type_param_order.stderr index b3200a51d7857..8edbe329503ac 100644 --- a/src/tools/clippy/tests/ui/mismatching_type_param_order.stderr +++ b/src/tools/clippy/tests/ui/mismatching_type_param_order.stderr @@ -6,6 +6,7 @@ LL | impl Foo {} | = help: try `A`, or a name that does not conflict with `Foo`'s generic params = note: `-D clippy::mismatching-type-param-order` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mismatching_type_param_order)]` error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:11:23 diff --git a/src/tools/clippy/tests/ui/misnamed_getters.stderr b/src/tools/clippy/tests/ui/misnamed_getters.stderr index 58f6f3eb7387c..aadec65490836 100644 --- a/src/tools/clippy/tests/ui/misnamed_getters.stderr +++ b/src/tools/clippy/tests/ui/misnamed_getters.stderr @@ -10,6 +10,7 @@ LL | | } | |_____^ | = note: `-D clippy::misnamed-getters` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::misnamed_getters)]` error: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:16:5 diff --git a/src/tools/clippy/tests/ui/missing_assert_message.stderr b/src/tools/clippy/tests/ui/missing_assert_message.stderr index 00b9a36e9091f..e07f52e3f66c6 100644 --- a/src/tools/clippy/tests/ui/missing_assert_message.stderr +++ b/src/tools/clippy/tests/ui/missing_assert_message.stderr @@ -6,6 +6,7 @@ LL | assert!(foo()); | = help: consider describing why the failing assert is problematic = note: `-D clippy::missing-assert-message` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_assert_message)]` error: assert without any message --> $DIR/missing_assert_message.rs:14:5 diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr index 5c6f9e8a7f0d6..b3a8ad8fa717e 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::missing-const-for-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_const_for_fn)]` error: this could be a `const fn` --> $DIR/could_be_const.rs:20:5 diff --git a/src/tools/clippy/tests/ui/missing_doc.stderr b/src/tools/clippy/tests/ui/missing_doc.stderr index 4e8a49bf1cd71..1d8007fa5b0fc 100644 --- a/src/tools/clippy/tests/ui/missing_doc.stderr +++ b/src/tools/clippy/tests/ui/missing_doc.stderr @@ -5,6 +5,7 @@ LL | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a module --> $DIR/missing_doc.rs:19:1 diff --git a/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr b/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr index 75e033cc94b48..c684bc8e70723 100644 --- a/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr +++ b/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr @@ -9,6 +9,7 @@ LL | | fn main() {} | |____________^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/missing_doc_impl.stderr b/src/tools/clippy/tests/ui/missing_doc_impl.stderr index 111d65469660b..e303b7b7d9fdb 100644 --- a/src/tools/clippy/tests/ui/missing_doc_impl.stderr +++ b/src/tools/clippy/tests/ui/missing_doc_impl.stderr @@ -8,6 +8,7 @@ LL | | } | |_^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_docs_in_private_items)]` error: missing documentation for a struct field --> $DIR/missing_doc_impl.rs:14:5 diff --git a/src/tools/clippy/tests/ui/missing_fields_in_debug.stderr b/src/tools/clippy/tests/ui/missing_fields_in_debug.stderr index 51b5e7b314ace..481b2c6321778 100644 --- a/src/tools/clippy/tests/ui/missing_fields_in_debug.stderr +++ b/src/tools/clippy/tests/ui/missing_fields_in_debug.stderr @@ -18,6 +18,7 @@ LL | hidden: u32, = help: consider including all fields in this `Debug` impl = help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields = note: `-D clippy::missing-fields-in-debug` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_fields_in_debug)]` error: manual `Debug` impl does not include all fields --> $DIR/missing_fields_in_debug.rs:32:1 diff --git a/src/tools/clippy/tests/ui/missing_inline.stderr b/src/tools/clippy/tests/ui/missing_inline.stderr index be24af49273f2..da2a2a7fedd46 100644 --- a/src/tools/clippy/tests/ui/missing_inline.stderr +++ b/src/tools/clippy/tests/ui/missing_inline.stderr @@ -5,6 +5,7 @@ LL | pub fn pub_foo() {} | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_inline_in_public_items)]` error: missing `#[inline]` for a default trait method --> $DIR/missing_inline.rs:39:5 diff --git a/src/tools/clippy/tests/ui/missing_panics_doc.stderr b/src/tools/clippy/tests/ui/missing_panics_doc.stderr index 3dbe2dfbd88fd..efee485508ec8 100644 --- a/src/tools/clippy/tests/ui/missing_panics_doc.stderr +++ b/src/tools/clippy/tests/ui/missing_panics_doc.stderr @@ -10,6 +10,7 @@ note: first possible panic found here LL | result.unwrap() | ^^^^^^^^^^^^^^^ = note: `-D clippy::missing-panics-doc` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_panics_doc)]` error: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:19:1 diff --git a/src/tools/clippy/tests/ui/missing_spin_loop.stderr b/src/tools/clippy/tests/ui/missing_spin_loop.stderr index b525406bbf0ba..a84c19d592617 100644 --- a/src/tools/clippy/tests/ui/missing_spin_loop.stderr +++ b/src/tools/clippy/tests/ui/missing_spin_loop.stderr @@ -5,6 +5,7 @@ LL | while b.load(Ordering::Acquire) {} | ^^ help: try: `{ std::hint::spin_loop() }` | = note: `-D clippy::missing-spin-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_spin_loop)]` error: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:12:37 diff --git a/src/tools/clippy/tests/ui/missing_spin_loop_no_std.stderr b/src/tools/clippy/tests/ui/missing_spin_loop_no_std.stderr index 33e5d32fe88d6..0b7be46165111 100644 --- a/src/tools/clippy/tests/ui/missing_spin_loop_no_std.stderr +++ b/src/tools/clippy/tests/ui/missing_spin_loop_no_std.stderr @@ -5,6 +5,7 @@ LL | while b.load(Ordering::Acquire) {} | ^^ help: try: `{ core::hint::spin_loop() }` | = note: `-D clippy::missing-spin-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_spin_loop)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/missing_trait_methods.stderr b/src/tools/clippy/tests/ui/missing_trait_methods.stderr index 8f50e76135c4d..3e20a51e0842f 100644 --- a/src/tools/clippy/tests/ui/missing_trait_methods.stderr +++ b/src/tools/clippy/tests/ui/missing_trait_methods.stderr @@ -10,6 +10,7 @@ help: implement the method LL | fn provided() {} | ^^^^^^^^^^^^^ = note: `-D clippy::missing-trait-methods` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::missing_trait_methods)]` error: missing trait method provided by default: `b` --> $DIR/missing_trait_methods.rs:25:1 diff --git a/src/tools/clippy/tests/ui/mixed_read_write_in_expression.stderr b/src/tools/clippy/tests/ui/mixed_read_write_in_expression.stderr index e0b405ddece9b..3dad98815c618 100644 --- a/src/tools/clippy/tests/ui/mixed_read_write_in_expression.stderr +++ b/src/tools/clippy/tests/ui/mixed_read_write_in_expression.stderr @@ -10,6 +10,7 @@ note: whether read occurs before this write depends on evaluation order LL | x = 1; | ^^^^^ = note: `-D clippy::mixed-read-write-in-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mixed_read_write_in_expression)]` error: unsequenced read of `x` --> $DIR/mixed_read_write_in_expression.rs:18:5 diff --git a/src/tools/clippy/tests/ui/module_inception.stderr b/src/tools/clippy/tests/ui/module_inception.stderr index b4f80a5bc7c2f..d5856614f91f1 100644 --- a/src/tools/clippy/tests/ui/module_inception.stderr +++ b/src/tools/clippy/tests/ui/module_inception.stderr @@ -9,6 +9,7 @@ LL | | } | |_________^ | = note: `-D clippy::module-inception` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::module_inception)]` error: module has the same name as its containing module --> $DIR/module_inception.rs:12:5 diff --git a/src/tools/clippy/tests/ui/module_name_repetitions.stderr b/src/tools/clippy/tests/ui/module_name_repetitions.stderr index 3c7fa1def2ba2..1854d3a859a7a 100644 --- a/src/tools/clippy/tests/ui/module_name_repetitions.stderr +++ b/src/tools/clippy/tests/ui/module_name_repetitions.stderr @@ -5,6 +5,7 @@ LL | pub fn foo_bar() {} | ^^^^^^^ | = note: `-D clippy::module-name-repetitions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::module_name_repetitions)]` error: item name ends with its containing module's name --> $DIR/module_name_repetitions.rs:11:12 diff --git a/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr b/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr index 3faf8c5aee1c1..46c8d0288a358 100644 --- a/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr +++ b/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr @@ -6,6 +6,7 @@ LL | -1.6 % 2.1; | = note: double check for expected result especially when interoperating with different languages = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on constants with different signs: `1.600 % -2.100` --> $DIR/modulo_arithmetic_float.rs:9:5 diff --git a/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr b/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr index 6d61afa0c3114..033a016c0e6f1 100644 --- a/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr +++ b/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr @@ -7,6 +7,7 @@ LL | a % b; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:11:5 diff --git a/src/tools/clippy/tests/ui/modulo_arithmetic_integral_const.stderr b/src/tools/clippy/tests/ui/modulo_arithmetic_integral_const.stderr index 59267b0e79696..47ed2261a7b66 100644 --- a/src/tools/clippy/tests/ui/modulo_arithmetic_integral_const.stderr +++ b/src/tools/clippy/tests/ui/modulo_arithmetic_integral_const.stderr @@ -7,6 +7,7 @@ LL | -1 % 2; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:14:5 diff --git a/src/tools/clippy/tests/ui/modulo_one.stderr b/src/tools/clippy/tests/ui/modulo_one.stderr index 62e23ee9a595f..cc211ab6cd345 100644 --- a/src/tools/clippy/tests/ui/modulo_one.stderr +++ b/src/tools/clippy/tests/ui/modulo_one.stderr @@ -25,6 +25,7 @@ LL | 10 % 1; | ^^^^^^ | = note: `-D clippy::modulo-one` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::modulo_one)]` error: any number modulo -1 will panic/overflow or result in 0 --> $DIR/modulo_one.rs:11:5 diff --git a/src/tools/clippy/tests/ui/multi_assignments.stderr b/src/tools/clippy/tests/ui/multi_assignments.stderr index 813e920f74d74..9719b5e66847b 100644 --- a/src/tools/clippy/tests/ui/multi_assignments.stderr +++ b/src/tools/clippy/tests/ui/multi_assignments.stderr @@ -5,6 +5,7 @@ LL | a = b = c; | ^^^^^^^^^ | = note: `-D clippy::multi-assignments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::multi_assignments)]` error: assignments don't nest intuitively --> $DIR/multi_assignments.rs:7:5 diff --git a/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.stderr b/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.stderr index badc284ec423e..4803a5089ab25 100644 --- a/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.stderr +++ b/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.stderr @@ -18,6 +18,7 @@ note: unsafe function call occurs here LL | not_very_safe(); | ^^^^^^^^^^^^^^^ = note: `-D clippy::multiple-unsafe-ops-per-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::multiple_unsafe_ops_per_block)]` error: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:45:5 diff --git a/src/tools/clippy/tests/ui/must_use_candidates.stderr b/src/tools/clippy/tests/ui/must_use_candidates.stderr index 35da27d83a401..581399f3e4868 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.stderr +++ b/src/tools/clippy/tests/ui/must_use_candidates.stderr @@ -5,6 +5,7 @@ LL | pub fn pure(i: u8) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8` | = note: `-D clippy::must-use-candidate` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::must_use_candidate)]` error: this method could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:21:5 diff --git a/src/tools/clippy/tests/ui/must_use_unit.stderr b/src/tools/clippy/tests/ui/must_use_unit.stderr index bb421abc663c8..e67d9b5b9d8d3 100644 --- a/src/tools/clippy/tests/ui/must_use_unit.stderr +++ b/src/tools/clippy/tests/ui/must_use_unit.stderr @@ -7,6 +7,7 @@ LL | pub fn must_use_default() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::must-use-unit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]` error: this unit-returning function has a `#[must_use]` attribute --> $DIR/must_use_unit.rs:13:1 diff --git a/src/tools/clippy/tests/ui/mut_from_ref.stderr b/src/tools/clippy/tests/ui/mut_from_ref.stderr index 1c3df2b54fca0..38f47b9ad7b52 100644 --- a/src/tools/clippy/tests/ui/mut_from_ref.stderr +++ b/src/tools/clippy/tests/ui/mut_from_ref.stderr @@ -10,6 +10,7 @@ note: immutable borrow here LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ = note: `-D clippy::mut-from-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mut_from_ref)]` error: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:14:25 diff --git a/src/tools/clippy/tests/ui/mut_key.stderr b/src/tools/clippy/tests/ui/mut_key.stderr index bce9d4b589274..3701769a9ca7f 100644 --- a/src/tools/clippy/tests/ui/mut_key.stderr +++ b/src/tools/clippy/tests/ui/mut_key.stderr @@ -5,6 +5,7 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutable-key-type` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mutable_key_type)]` error: mutable key type --> $DIR/mut_key.rs:31:72 @@ -109,6 +110,7 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&HashMap` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: aborting due to 18 previous errors diff --git a/src/tools/clippy/tests/ui/mut_mut.stderr b/src/tools/clippy/tests/ui/mut_mut.stderr index 58a1c4e683c96..5ed9cd1aff99e 100644 --- a/src/tools/clippy/tests/ui/mut_mut.stderr +++ b/src/tools/clippy/tests/ui/mut_mut.stderr @@ -5,6 +5,7 @@ LL | fn fun(x: &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ | = note: `-D clippy::mut-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mut_mut)]` error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:31:17 diff --git a/src/tools/clippy/tests/ui/mut_mutex_lock.stderr b/src/tools/clippy/tests/ui/mut_mutex_lock.stderr index f7b371822de8f..9b20016be799e 100644 --- a/src/tools/clippy/tests/ui/mut_mutex_lock.stderr +++ b/src/tools/clippy/tests/ui/mut_mutex_lock.stderr @@ -5,6 +5,7 @@ LL | let mut value = value_mutex.lock().unwrap(); | ^^^^ help: change this to: `get_mut` | = note: `-D clippy::mut-mutex-lock` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mut_mutex_lock)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/mut_range_bound.stderr b/src/tools/clippy/tests/ui/mut_range_bound.stderr index c9de5393a2b17..42f8a161f74f7 100644 --- a/src/tools/clippy/tests/ui/mut_range_bound.stderr +++ b/src/tools/clippy/tests/ui/mut_range_bound.stderr @@ -6,6 +6,7 @@ LL | m = 5; | = note: the range of the loop is unchanged = note: `-D clippy::mut-range-bound` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mut_range_bound)]` error: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:17:9 diff --git a/src/tools/clippy/tests/ui/mut_reference.stderr b/src/tools/clippy/tests/ui/mut_reference.stderr index 4346560cea51e..d7a0d0c225250 100644 --- a/src/tools/clippy/tests/ui/mut_reference.stderr +++ b/src/tools/clippy/tests/ui/mut_reference.stderr @@ -5,6 +5,7 @@ LL | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]` error: the function `as_ptr` doesn't need a mutable reference --> $DIR/mut_reference.rs:36:12 @@ -25,6 +26,7 @@ LL | fn takes_a_mutable_reference(&self, a: &mut i32) {} | ^^^^^^^^ help: consider changing to: `&i32` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: aborting due to 4 previous errors diff --git a/src/tools/clippy/tests/ui/mutex_atomic.stderr b/src/tools/clippy/tests/ui/mutex_atomic.stderr index 2f669067da6fa..483e1ce15f6fb 100644 --- a/src/tools/clippy/tests/ui/mutex_atomic.stderr +++ b/src/tools/clippy/tests/ui/mutex_atomic.stderr @@ -5,6 +5,7 @@ LL | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-atomic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mutex_atomic)]` error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:11:5 @@ -37,6 +38,7 @@ LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-integer` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mutex_integer)]` error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:23:5 diff --git a/src/tools/clippy/tests/ui/needless_arbitrary_self_type.stderr b/src/tools/clippy/tests/ui/needless_arbitrary_self_type.stderr index c5b0b25c10b64..fe2ac34f79f67 100644 --- a/src/tools/clippy/tests/ui/needless_arbitrary_self_type.stderr +++ b/src/tools/clippy/tests/ui/needless_arbitrary_self_type.stderr @@ -5,6 +5,7 @@ LL | pub fn bad(self: Self) { | ^^^^^^^^^^ help: consider to change this parameter to: `self` | = note: `-D clippy::needless-arbitrary-self-type` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_arbitrary_self_type)]` error: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:18:20 diff --git a/src/tools/clippy/tests/ui/needless_arbitrary_self_type_unfixable.stderr b/src/tools/clippy/tests/ui/needless_arbitrary_self_type_unfixable.stderr index c7df5936d706a..183e2dbc8c16e 100644 --- a/src/tools/clippy/tests/ui/needless_arbitrary_self_type_unfixable.stderr +++ b/src/tools/clippy/tests/ui/needless_arbitrary_self_type_unfixable.stderr @@ -5,6 +5,7 @@ LL | fn call_with_mut_self(self: &mut Self) {} | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` | = note: `-D clippy::needless-arbitrary-self-type` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_arbitrary_self_type)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr b/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr index 9752624902cce..2ed9208e62306 100644 --- a/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr +++ b/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr @@ -5,6 +5,7 @@ LL | if y & !x { | ^^^^^^ help: try: `y && !x` | = note: `-D clippy::needless-bitwise-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_bitwise_bool)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/needless_bool/fixable.stderr b/src/tools/clippy/tests/ui/needless_bool/fixable.stderr index a2dfa2fd4827d..2b189c898512d 100644 --- a/src/tools/clippy/tests/ui/needless_bool/fixable.stderr +++ b/src/tools/clippy/tests/ui/needless_bool/fixable.stderr @@ -9,6 +9,7 @@ LL | | }; | |_____^ help: you can reduce it to: `x` | = note: `-D clippy::needless-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:45:5 @@ -137,6 +138,7 @@ LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` | = note: `-D clippy::bool-comparison` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against false can be replaced by a negation --> $DIR/fixable.rs:147:8 diff --git a/src/tools/clippy/tests/ui/needless_bool/simple.stderr b/src/tools/clippy/tests/ui/needless_bool/simple.stderr index 0ccc9416bcd58..a44205c59b75b 100644 --- a/src/tools/clippy/tests/ui/needless_bool/simple.stderr +++ b/src/tools/clippy/tests/ui/needless_bool/simple.stderr @@ -9,6 +9,7 @@ LL | | }; | |_____^ | = note: `-D clippy::needless-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression will always return false --> $DIR/simple.rs:19:5 diff --git a/src/tools/clippy/tests/ui/needless_bool_assign.stderr b/src/tools/clippy/tests/ui/needless_bool_assign.stderr index 8e7ea615c7d74..7866c89bd618c 100644 --- a/src/tools/clippy/tests/ui/needless_bool_assign.stderr +++ b/src/tools/clippy/tests/ui/needless_bool_assign.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ help: you can reduce it to: `a.field = random() && random();` | = note: `-D clippy::needless-bool-assign` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_bool_assign)]` error: this if-then-else expression assigns a bool literal --> $DIR/needless_bool_assign.rs:18:5 diff --git a/src/tools/clippy/tests/ui/needless_borrow.stderr b/src/tools/clippy/tests/ui/needless_borrow.stderr index d26c317124b8d..8e27014d53c3e 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.stderr +++ b/src/tools/clippy/tests/ui/needless_borrow.stderr @@ -5,6 +5,7 @@ LL | let _ = x(&&a); // warn | ^^^ help: change this to: `&a` | = note: `-D clippy::needless-borrow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` error: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:19:13 diff --git a/src/tools/clippy/tests/ui/needless_borrow_pat.stderr b/src/tools/clippy/tests/ui/needless_borrow_pat.stderr index 4eac32fcd9cfa..ce3a36e35b857 100644 --- a/src/tools/clippy/tests/ui/needless_borrow_pat.stderr +++ b/src/tools/clippy/tests/ui/needless_borrow_pat.stderr @@ -5,6 +5,7 @@ LL | Some(ref x) => x, | ^^^^^ help: try: `x` | = note: `-D clippy::needless-borrow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` error: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:67:14 diff --git a/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr b/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr index 553b068c6b43d..15261cfce0c35 100644 --- a/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr +++ b/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr @@ -5,6 +5,7 @@ LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_borrowed_reference)]` help: try removing the `&ref` part | LL - let _ = v.iter_mut().filter(|&ref a| a.is_empty()); diff --git a/src/tools/clippy/tests/ui/needless_collect.stderr b/src/tools/clippy/tests/ui/needless_collect.stderr index c24568bba9c82..2c21fc5965d56 100644 --- a/src/tools/clippy/tests/ui/needless_collect.stderr +++ b/src/tools/clippy/tests/ui/needless_collect.stderr @@ -5,6 +5,7 @@ LL | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` | = note: `-D clippy::needless-collect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_collect)]` error: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:10:22 diff --git a/src/tools/clippy/tests/ui/needless_collect_indirect.stderr b/src/tools/clippy/tests/ui/needless_collect_indirect.stderr index 9337a7412425a..3d1ad2a1cfa55 100644 --- a/src/tools/clippy/tests/ui/needless_collect_indirect.stderr +++ b/src/tools/clippy/tests/ui/needless_collect_indirect.stderr @@ -8,6 +8,7 @@ LL | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::>( | ------------------------- the iterator could be used here instead | = note: `-D clippy::needless-collect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_collect)]` help: use the original Iterator instead of collecting it and then producing a new one | LL ~ diff --git a/src/tools/clippy/tests/ui/needless_continue.stderr b/src/tools/clippy/tests/ui/needless_continue.stderr index 9a65248c9913f..31b5dc2808da1 100644 --- a/src/tools/clippy/tests/ui/needless_continue.stderr +++ b/src/tools/clippy/tests/ui/needless_continue.stderr @@ -35,6 +35,7 @@ LL | | } println!("bleh"); } = note: `-D clippy::needless-continue` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_continue)]` error: there is no need for an explicit `else` block for this `if` expression --> $DIR/needless_continue.rs:46:9 diff --git a/src/tools/clippy/tests/ui/needless_doc_main.stderr b/src/tools/clippy/tests/ui/needless_doc_main.stderr index be6675e6482e0..8dd93bb05dd50 100644 --- a/src/tools/clippy/tests/ui/needless_doc_main.stderr +++ b/src/tools/clippy/tests/ui/needless_doc_main.stderr @@ -5,6 +5,7 @@ LL | /// fn main() { | ^^^^^^^^^^^^ | = note: `-D clippy::needless-doctest-main` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_doctest_main)]` error: needless `fn main` in doctest --> $DIR/needless_doc_main.rs:16:4 diff --git a/src/tools/clippy/tests/ui/needless_else.stderr b/src/tools/clippy/tests/ui/needless_else.stderr index 006e4d7d30fe2..e6f7138e948dd 100644 --- a/src/tools/clippy/tests/ui/needless_else.stderr +++ b/src/tools/clippy/tests/ui/needless_else.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: you can remove it | = note: `-D clippy::needless-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_else)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/needless_for_each_fixable.stderr b/src/tools/clippy/tests/ui/needless_for_each_fixable.stderr index 08e995851d7a5..3b5163b0171a9 100644 --- a/src/tools/clippy/tests/ui/needless_for_each_fixable.stderr +++ b/src/tools/clippy/tests/ui/needless_for_each_fixable.stderr @@ -7,6 +7,7 @@ LL | | }); | |_______^ | = note: `-D clippy::needless-for-each` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_for_each)]` help: try | LL ~ for elem in v.iter() { diff --git a/src/tools/clippy/tests/ui/needless_for_each_unfixable.stderr b/src/tools/clippy/tests/ui/needless_for_each_unfixable.stderr index dad0053f5591b..73f249ae6c2f3 100644 --- a/src/tools/clippy/tests/ui/needless_for_each_unfixable.stderr +++ b/src/tools/clippy/tests/ui/needless_for_each_unfixable.stderr @@ -11,6 +11,7 @@ LL | | }); | |_______^ | = note: `-D clippy::needless-for-each` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_for_each)]` help: try | LL ~ for v in v.iter() { diff --git a/src/tools/clippy/tests/ui/needless_if.stderr b/src/tools/clippy/tests/ui/needless_if.stderr index bf131f2d7e4b4..ed5b9452b86b5 100644 --- a/src/tools/clippy/tests/ui/needless_if.stderr +++ b/src/tools/clippy/tests/ui/needless_if.stderr @@ -5,6 +5,7 @@ LL | if (true) {} | ^^^^^^^^^^^^ help: you can remove it | = note: `-D clippy::needless-if` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_if)]` error: this `if` branch is empty --> $DIR/needless_if.rs:28:5 diff --git a/src/tools/clippy/tests/ui/needless_late_init.stderr b/src/tools/clippy/tests/ui/needless_late_init.stderr index eff782f8bf104..602b1a683e51d 100644 --- a/src/tools/clippy/tests/ui/needless_late_init.stderr +++ b/src/tools/clippy/tests/ui/needless_late_init.stderr @@ -7,6 +7,7 @@ LL | a = "zero"; | ^^^^^^^^^^ initialised here | = note: `-D clippy::needless-late-init` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_late_init)]` help: declare `a` here | LL | let a = "zero"; diff --git a/src/tools/clippy/tests/ui/needless_lifetimes.stderr b/src/tools/clippy/tests/ui/needless_lifetimes.stderr index 23b9cbe3f8589..7051a2604b917 100644 --- a/src/tools/clippy/tests/ui/needless_lifetimes.stderr +++ b/src/tools/clippy/tests/ui/needless_lifetimes.stderr @@ -5,6 +5,7 @@ LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} | ^^ ^^ ^^ ^^ | = note: `-D clippy::needless-lifetimes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` help: elide the lifetimes | LL - fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} diff --git a/src/tools/clippy/tests/ui/needless_match.stderr b/src/tools/clippy/tests/ui/needless_match.stderr index 6ae2f38bf5009..736926b4415bc 100644 --- a/src/tools/clippy/tests/ui/needless_match.stderr +++ b/src/tools/clippy/tests/ui/needless_match.stderr @@ -11,6 +11,7 @@ LL | | }; | |_____^ help: replace it with: `i` | = note: `-D clippy::needless-match` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_match)]` error: this match expression is unnecessary --> $DIR/needless_match.rs:22:19 diff --git a/src/tools/clippy/tests/ui/needless_option_as_deref.stderr b/src/tools/clippy/tests/ui/needless_option_as_deref.stderr index 94be76a9a45ec..024d30c1717c2 100644 --- a/src/tools/clippy/tests/ui/needless_option_as_deref.stderr +++ b/src/tools/clippy/tests/ui/needless_option_as_deref.stderr @@ -5,6 +5,7 @@ LL | let _: Option<&usize> = Some(&1).as_deref(); | ^^^^^^^^^^^^^^^^^^^ help: try: `Some(&1)` | = note: `-D clippy::needless-option-as-deref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_option_as_deref)]` error: derefed type is same as origin --> $DIR/needless_option_as_deref.rs:8:33 diff --git a/src/tools/clippy/tests/ui/needless_option_take.stderr b/src/tools/clippy/tests/ui/needless_option_take.stderr index b6b50d6f2ff6e..d3c22441d0033 100644 --- a/src/tools/clippy/tests/ui/needless_option_take.stderr +++ b/src/tools/clippy/tests/ui/needless_option_take.stderr @@ -5,6 +5,7 @@ LL | x.as_ref().take(); | ^^^^^^^^^^^^^^^^^ help: try: `x.as_ref()` | = note: `-D clippy::needless-option-take` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_option_take)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/needless_parens_on_range_literals.stderr b/src/tools/clippy/tests/ui/needless_parens_on_range_literals.stderr index 0fe331ecc7546..c73564e210c06 100644 --- a/src/tools/clippy/tests/ui/needless_parens_on_range_literals.stderr +++ b/src/tools/clippy/tests/ui/needless_parens_on_range_literals.stderr @@ -5,6 +5,7 @@ LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'a'` | = note: `-D clippy::needless-parens-on-range-literals` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_parens_on_range_literals)]` error: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:7:21 diff --git a/src/tools/clippy/tests/ui/needless_pass_by_ref_mut.stderr b/src/tools/clippy/tests/ui/needless_pass_by_ref_mut.stderr index 2e06e7252d9ba..df3df045776b8 100644 --- a/src/tools/clippy/tests/ui/needless_pass_by_ref_mut.stderr +++ b/src/tools/clippy/tests/ui/needless_pass_by_ref_mut.stderr @@ -5,6 +5,7 @@ LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: this argument is a mutable reference, but not used mutably --> $DIR/needless_pass_by_ref_mut.rs:31:12 diff --git a/src/tools/clippy/tests/ui/needless_pass_by_value.stderr b/src/tools/clippy/tests/ui/needless_pass_by_value.stderr index a6bf30b1cdfb4..1c3a63d661f68 100644 --- a/src/tools/clippy/tests/ui/needless_pass_by_value.stderr +++ b/src/tools/clippy/tests/ui/needless_pass_by_value.stderr @@ -5,6 +5,7 @@ LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec $DIR/needless_pass_by_value.rs:34:11 diff --git a/src/tools/clippy/tests/ui/needless_pub_self.stderr b/src/tools/clippy/tests/ui/needless_pub_self.stderr index 3aa2feb5ecd82..c1f6b908b53d4 100644 --- a/src/tools/clippy/tests/ui/needless_pub_self.stderr +++ b/src/tools/clippy/tests/ui/needless_pub_self.stderr @@ -5,6 +5,7 @@ LL | pub(self) fn a() {} | ^^^^^^^^^ help: remove it | = note: `-D clippy::needless-pub-self` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pub_self)]` error: unnecessary `pub(in self)` --> $DIR/needless_pub_self.rs:14:1 diff --git a/src/tools/clippy/tests/ui/needless_question_mark.stderr b/src/tools/clippy/tests/ui/needless_question_mark.stderr index 3e1d2c17c3013..cd961a49f421a 100644 --- a/src/tools/clippy/tests/ui/needless_question_mark.stderr +++ b/src/tools/clippy/tests/ui/needless_question_mark.stderr @@ -5,6 +5,7 @@ LL | return Some(to.magic?); | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` | = note: `-D clippy::needless-question-mark` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_question_mark)]` error: question mark operator is useless here --> $DIR/needless_question_mark.rs:28:12 diff --git a/src/tools/clippy/tests/ui/needless_range_loop.stderr b/src/tools/clippy/tests/ui/needless_range_loop.stderr index 0358b2fb0251a..0d8893c261961 100644 --- a/src/tools/clippy/tests/ui/needless_range_loop.stderr +++ b/src/tools/clippy/tests/ui/needless_range_loop.stderr @@ -5,6 +5,7 @@ LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | LL | for in &vec { diff --git a/src/tools/clippy/tests/ui/needless_range_loop2.stderr b/src/tools/clippy/tests/ui/needless_range_loop2.stderr index 6e6ef73c1f6e8..3d1d9e1bff432 100644 --- a/src/tools/clippy/tests/ui/needless_range_loop2.stderr +++ b/src/tools/clippy/tests/ui/needless_range_loop2.stderr @@ -5,6 +5,7 @@ LL | for i in 3..10 { | ^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | LL | for in ns.iter().take(10).skip(3) { diff --git a/src/tools/clippy/tests/ui/needless_raw_string.stderr b/src/tools/clippy/tests/ui/needless_raw_string.stderr index ddc36af2e724c..83cc6d332ee56 100644 --- a/src/tools/clippy/tests/ui/needless_raw_string.stderr +++ b/src/tools/clippy/tests/ui/needless_raw_string.stderr @@ -5,6 +5,7 @@ LL | r#"aaa"#; | ^^^^^^^^ help: try: `"aaa"` | = note: `-D clippy::needless-raw-strings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_raw_strings)]` error: unnecessary raw string literal --> $DIR/needless_raw_string.rs:9:5 diff --git a/src/tools/clippy/tests/ui/needless_raw_string_hashes.stderr b/src/tools/clippy/tests/ui/needless_raw_string_hashes.stderr index 9649d59a71fcd..94c51c423b86d 100644 --- a/src/tools/clippy/tests/ui/needless_raw_string_hashes.stderr +++ b/src/tools/clippy/tests/ui/needless_raw_string_hashes.stderr @@ -5,6 +5,7 @@ LL | r##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `r#"Hello "world"!"#` | = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_raw_string_hashes)]` error: unnecessary hashes around raw string literal --> $DIR/needless_raw_string_hashes.rs:8:5 diff --git a/src/tools/clippy/tests/ui/needless_return.stderr b/src/tools/clippy/tests/ui/needless_return.stderr index eea9a5ff9cf24..cc48831115d9f 100644 --- a/src/tools/clippy/tests/ui/needless_return.stderr +++ b/src/tools/clippy/tests/ui/needless_return.stderr @@ -5,6 +5,7 @@ LL | return true; | ^^^^^^^^^^^ | = note: `-D clippy::needless-return` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_return)]` help: remove `return` | LL - return true; diff --git a/src/tools/clippy/tests/ui/needless_return_with_question_mark.stderr b/src/tools/clippy/tests/ui/needless_return_with_question_mark.stderr index 5cc20e9682bae..0de0633803bc4 100644 --- a/src/tools/clippy/tests/ui/needless_return_with_question_mark.stderr +++ b/src/tools/clippy/tests/ui/needless_return_with_question_mark.stderr @@ -5,6 +5,7 @@ LL | return Err(())?; | ^^^^^^^ help: remove it | = note: `-D clippy::needless-return-with-question-mark` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_return_with_question_mark)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/needless_splitn.stderr b/src/tools/clippy/tests/ui/needless_splitn.stderr index 14c576e6457c8..f347ca760dbe2 100644 --- a/src/tools/clippy/tests/ui/needless_splitn.stderr +++ b/src/tools/clippy/tests/ui/needless_splitn.stderr @@ -5,6 +5,7 @@ LL | let _ = str.splitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` | = note: `-D clippy::needless-splitn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_splitn)]` error: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:14:13 diff --git a/src/tools/clippy/tests/ui/needless_update.stderr b/src/tools/clippy/tests/ui/needless_update.stderr index b154b3b306ddc..3e9e2941a7a75 100644 --- a/src/tools/clippy/tests/ui/needless_update.stderr +++ b/src/tools/clippy/tests/ui/needless_update.stderr @@ -5,6 +5,7 @@ LL | S { a: 1, b: 1, ..base }; | ^^^^ | = note: `-D clippy::needless-update` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_update)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/neg_cmp_op_on_partial_ord.stderr b/src/tools/clippy/tests/ui/neg_cmp_op_on_partial_ord.stderr index c2e1f8702ddeb..c64d96b4b2032 100644 --- a/src/tools/clippy/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/src/tools/clippy/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -5,6 +5,7 @@ LL | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::neg_cmp_op_on_partial_ord)]` 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:21:30 diff --git a/src/tools/clippy/tests/ui/neg_multiply.stderr b/src/tools/clippy/tests/ui/neg_multiply.stderr index 8b31bca0b7d4b..abfc94f97701f 100644 --- a/src/tools/clippy/tests/ui/neg_multiply.stderr +++ b/src/tools/clippy/tests/ui/neg_multiply.stderr @@ -5,6 +5,7 @@ LL | x * -1; | ^^^^^^ help: consider using: `-x` | = note: `-D clippy::neg-multiply` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::neg_multiply)]` error: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:30:5 diff --git a/src/tools/clippy/tests/ui/never_loop.stderr b/src/tools/clippy/tests/ui/never_loop.stderr index 6d6d2c8ac52e0..234780007b1af 100644 --- a/src/tools/clippy/tests/ui/never_loop.stderr +++ b/src/tools/clippy/tests/ui/never_loop.stderr @@ -137,6 +137,7 @@ LL | break 'a; | ^^^^^^^^ | = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: this loop never actually loops --> $DIR/never_loop.rs:294:13 diff --git a/src/tools/clippy/tests/ui/new_ret_no_self.stderr b/src/tools/clippy/tests/ui/new_ret_no_self.stderr index 4c76603f596d8..8436e101ff97f 100644 --- a/src/tools/clippy/tests/ui/new_ret_no_self.stderr +++ b/src/tools/clippy/tests/ui/new_ret_no_self.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::new-ret-no-self` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::new_ret_no_self)]` error: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:84:5 diff --git a/src/tools/clippy/tests/ui/new_without_default.stderr b/src/tools/clippy/tests/ui/new_without_default.stderr index 4293cd5972df7..acba5b0d7bd5d 100644 --- a/src/tools/clippy/tests/ui/new_without_default.stderr +++ b/src/tools/clippy/tests/ui/new_without_default.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::new-without-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::new_without_default)]` help: try adding this | LL + impl Default for Foo { diff --git a/src/tools/clippy/tests/ui/no_effect.stderr b/src/tools/clippy/tests/ui/no_effect.stderr index 4b8499a23a5de..feba35697f5ea 100644 --- a/src/tools/clippy/tests/ui/no_effect.stderr +++ b/src/tools/clippy/tests/ui/no_effect.stderr @@ -5,6 +5,7 @@ LL | 0; | ^^ | = note: `-D clippy::no-effect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect --> $DIR/no_effect.rs:101:5 @@ -157,6 +158,7 @@ LL | let _unused = 1; | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]` error: binding to `_` prefixed variable with no side-effect --> $DIR/no_effect.rs:154:5 diff --git a/src/tools/clippy/tests/ui/no_effect_replace.stderr b/src/tools/clippy/tests/ui/no_effect_replace.stderr index 685b20b75d41d..e1162f04f8571 100644 --- a/src/tools/clippy/tests/ui/no_effect_replace.stderr +++ b/src/tools/clippy/tests/ui/no_effect_replace.stderr @@ -5,6 +5,7 @@ LL | let _ = "12345".replace('1', "1"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::no-effect-replace` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]` error: replacing text with itself --> $DIR/no_effect_replace.rs:7:13 diff --git a/src/tools/clippy/tests/ui/no_effect_return.stderr b/src/tools/clippy/tests/ui/no_effect_return.stderr index 6b146a03abc11..b036e63420474 100644 --- a/src/tools/clippy/tests/ui/no_effect_return.stderr +++ b/src/tools/clippy/tests/ui/no_effect_return.stderr @@ -7,6 +7,7 @@ LL | 0u32; | help: did you mean to return it?: `return` | = note: `-D clippy::no-effect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect --> $DIR/no_effect_return.rs:18:9 diff --git a/src/tools/clippy/tests/ui/no_mangle_with_rust_abi.stderr b/src/tools/clippy/tests/ui/no_mangle_with_rust_abi.stderr index 721dcf603b1fd..62d53c8395fd9 100644 --- a/src/tools/clippy/tests/ui/no_mangle_with_rust_abi.stderr +++ b/src/tools/clippy/tests/ui/no_mangle_with_rust_abi.stderr @@ -5,6 +5,7 @@ LL | fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::no-mangle-with-rust-abi` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::no_mangle_with_rust_abi)]` help: set an ABI | LL | extern "C" fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} diff --git a/src/tools/clippy/tests/ui/non_expressive_names.stderr b/src/tools/clippy/tests/ui/non_expressive_names.stderr index b62748d4989df..1b78124a90318 100644 --- a/src/tools/clippy/tests/ui/non_expressive_names.stderr +++ b/src/tools/clippy/tests/ui/non_expressive_names.stderr @@ -5,6 +5,7 @@ LL | let _1 = 1; | ^^ | = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::just_underscores_and_digits)]` error: consider choosing a more descriptive name --> $DIR/non_expressive_names.rs:29:9 diff --git a/src/tools/clippy/tests/ui/non_minimal_cfg.stderr b/src/tools/clippy/tests/ui/non_minimal_cfg.stderr index d0212e2302134..c33c35ed8df94 100644 --- a/src/tools/clippy/tests/ui/non_minimal_cfg.stderr +++ b/src/tools/clippy/tests/ui/non_minimal_cfg.stderr @@ -5,6 +5,7 @@ LL | #[cfg(all(windows))] | ^^^^^^^^^^^^ help: try: `windows` | = note: `-D clippy::non-minimal-cfg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_minimal_cfg)]` error: unneeded sub `cfg` when there is only one condition --> $DIR/non_minimal_cfg.rs:6:7 diff --git a/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr b/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr index 2a9a36fbcef31..001fcddd9068e 100644 --- a/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr +++ b/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr @@ -5,6 +5,7 @@ LL | #[cfg(all())] | ^^^^^ | = note: `-D clippy::non-minimal-cfg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_minimal_cfg)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/non_octal_unix_permissions.stderr b/src/tools/clippy/tests/ui/non_octal_unix_permissions.stderr index 32845d0659415..78c8f1a2fcf78 100644 --- a/src/tools/clippy/tests/ui/non_octal_unix_permissions.stderr +++ b/src/tools/clippy/tests/ui/non_octal_unix_permissions.stderr @@ -5,6 +5,7 @@ LL | options.mode(440); | ^^^ help: consider using an octal literal instead: `0o440` | = note: `-D clippy::non-octal-unix-permissions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_octal_unix_permissions)]` error: using a non-octal value to set unix file permissions --> $DIR/non_octal_unix_permissions.rs:17:47 diff --git a/src/tools/clippy/tests/ui/non_send_fields_in_send_ty.stderr b/src/tools/clippy/tests/ui/non_send_fields_in_send_ty.stderr index 08a53b3a891cf..1ea76196af938 100644 --- a/src/tools/clippy/tests/ui/non_send_fields_in_send_ty.stderr +++ b/src/tools/clippy/tests/ui/non_send_fields_in_send_ty.stderr @@ -11,6 +11,7 @@ LL | data: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Vec>: Send` = note: `-D clippy::non-send-fields-in-send-ty` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]` error: some fields in `MvccRwLock` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:26:1 diff --git a/src/tools/clippy/tests/ui/nonminimal_bool.stderr b/src/tools/clippy/tests/ui/nonminimal_bool.stderr index 2eba55555f438..deae389dbefad 100644 --- a/src/tools/clippy/tests/ui/nonminimal_bool.stderr +++ b/src/tools/clippy/tests/ui/nonminimal_bool.stderr @@ -5,6 +5,7 @@ LL | let _ = !true; | ^^^^^ help: try: `false` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:16:13 diff --git a/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr b/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr index a2df889d62302..d47bbf7e0799a 100644 --- a/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr +++ b/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr @@ -5,6 +5,7 @@ LL | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:10:13 diff --git a/src/tools/clippy/tests/ui/numbered_fields.stderr b/src/tools/clippy/tests/ui/numbered_fields.stderr index 076c7aa0c6ac1..d52a0cf15a83c 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.stderr +++ b/src/tools/clippy/tests/ui/numbered_fields.stderr @@ -10,6 +10,7 @@ LL | | }; | |_____^ help: try: `TupleStruct(1u32, 42, 23u8)` | = note: `-D clippy::init-numbered-fields` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::init_numbered_fields)]` error: used a field initializer for a tuple struct --> $DIR/numbered_fields.rs:25:13 diff --git a/src/tools/clippy/tests/ui/obfuscated_if_else.stderr b/src/tools/clippy/tests/ui/obfuscated_if_else.stderr index 1848151b1da25..ca9f5e1e374cb 100644 --- a/src/tools/clippy/tests/ui/obfuscated_if_else.stderr +++ b/src/tools/clippy/tests/ui/obfuscated_if_else.stderr @@ -5,6 +5,7 @@ LL | true.then_some("a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` | = note: `-D clippy::obfuscated-if-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::obfuscated_if_else)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/octal_escapes.stderr b/src/tools/clippy/tests/ui/octal_escapes.stderr index 98f7d21261f5b..d2161582b827d 100644 --- a/src/tools/clippy/tests/ui/octal_escapes.stderr +++ b/src/tools/clippy/tests/ui/octal_escapes.stderr @@ -6,6 +6,7 @@ LL | let _bad1 = "\033[0m"; | = help: octal escapes are not supported, `\0` is always a null character = note: `-D clippy::octal-escapes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::octal_escapes)]` help: if an octal escape was intended, use the hexadecimal representation instead | LL | let _bad1 = "\x1b[0m"; diff --git a/src/tools/clippy/tests/ui/ok_expect.stderr b/src/tools/clippy/tests/ui/ok_expect.stderr index 4c295d7a4c257..ac2b6dcc83b52 100644 --- a/src/tools/clippy/tests/ui/ok_expect.stderr +++ b/src/tools/clippy/tests/ui/ok_expect.stderr @@ -6,6 +6,7 @@ LL | res.ok().expect("disaster!"); | = help: you can call `expect()` directly on the `Result` = note: `-D clippy::ok-expect` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ok_expect)]` error: called `ok().expect()` on a `Result` value --> $DIR/ok_expect.rs:23:5 diff --git a/src/tools/clippy/tests/ui/only_used_in_recursion.stderr b/src/tools/clippy/tests/ui/only_used_in_recursion.stderr index b731d37c62c44..85eee99c01c59 100644 --- a/src/tools/clippy/tests/ui/only_used_in_recursion.stderr +++ b/src/tools/clippy/tests/ui/only_used_in_recursion.stderr @@ -10,6 +10,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { _one_unused(flag - 1, a) } | ^ = note: `-D clippy::only-used-in-recursion` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::only_used_in_recursion)]` error: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:16:27 diff --git a/src/tools/clippy/tests/ui/only_used_in_recursion2.stderr b/src/tools/clippy/tests/ui/only_used_in_recursion2.stderr index ae349fd29e957..3ddd9758c26fd 100644 --- a/src/tools/clippy/tests/ui/only_used_in_recursion2.stderr +++ b/src/tools/clippy/tests/ui/only_used_in_recursion2.stderr @@ -10,6 +10,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { _with_inner(flag, a, b + x) } | ^ = note: `-D clippy::only-used-in-recursion` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::only_used_in_recursion)]` error: parameter is only used in recursion --> $DIR/only_used_in_recursion2.rs:5:25 diff --git a/src/tools/clippy/tests/ui/op_ref.stderr b/src/tools/clippy/tests/ui/op_ref.stderr index 5f3769ddfab4b..f03e24b840054 100644 --- a/src/tools/clippy/tests/ui/op_ref.stderr +++ b/src/tools/clippy/tests/ui/op_ref.stderr @@ -5,6 +5,7 @@ LL | let foo = &5 - &6; | ^^^^^^^ | = note: `-D clippy::op-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::op_ref)]` help: use the values directly | LL | let foo = 5 - 6; diff --git a/src/tools/clippy/tests/ui/open_options.stderr b/src/tools/clippy/tests/ui/open_options.stderr index c136cf2dbf405..7ac826f52fa9d 100644 --- a/src/tools/clippy/tests/ui/open_options.stderr +++ b/src/tools/clippy/tests/ui/open_options.stderr @@ -5,6 +5,7 @@ LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::nonsensical_open_options)]` error: file opened with `append` and `truncate` --> $DIR/open_options.rs:9:5 diff --git a/src/tools/clippy/tests/ui/option_as_ref_deref.stderr b/src/tools/clippy/tests/ui/option_as_ref_deref.stderr index b5dc6a7f33189..eb0661c523a91 100644 --- a/src/tools/clippy/tests/ui/option_as_ref_deref.stderr +++ b/src/tools/clippy/tests/ui/option_as_ref_deref.stderr @@ -5,6 +5,7 @@ LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.clone().as_deref()` | = note: `-D clippy::option-as-ref-deref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::option_as_ref_deref)]` error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead --> $DIR/option_as_ref_deref.rs:14:13 diff --git a/src/tools/clippy/tests/ui/option_env_unwrap.stderr b/src/tools/clippy/tests/ui/option_env_unwrap.stderr index cfa9dd58a3006..de31d0c7f095f 100644 --- a/src/tools/clippy/tests/ui/option_env_unwrap.stderr +++ b/src/tools/clippy/tests/ui/option_env_unwrap.stderr @@ -6,6 +6,7 @@ LL | let _ = option_env!("PATH").unwrap(); | = help: consider using the `env!` macro instead = note: `-D clippy::option-env-unwrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::option_env_unwrap)]` error: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:11:13 diff --git a/src/tools/clippy/tests/ui/option_filter_map.stderr b/src/tools/clippy/tests/ui/option_filter_map.stderr index e7da7c292871d..148f9d02f5e16 100644 --- a/src/tools/clippy/tests/ui/option_filter_map.stderr +++ b/src/tools/clippy/tests/ui/option_filter_map.stderr @@ -5,6 +5,7 @@ LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` | = note: `-D clippy::option-filter-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::option_filter_map)]` error: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:6:27 diff --git a/src/tools/clippy/tests/ui/option_if_let_else.stderr b/src/tools/clippy/tests/ui/option_if_let_else.stderr index aa2da21740032..6d7d02f8c2556 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.stderr +++ b/src/tools/clippy/tests/ui/option_if_let_else.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))` | = note: `-D clippy::option-if-let-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]` error: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:30:13 diff --git a/src/tools/clippy/tests/ui/option_map_or_none.stderr b/src/tools/clippy/tests/ui/option_map_or_none.stderr index 76c4645534365..fa150718f8910 100644 --- a/src/tools/clippy/tests/ui/option_map_or_none.stderr +++ b/src/tools/clippy/tests/ui/option_map_or_none.stderr @@ -5,6 +5,7 @@ LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)` | = note: `-D clippy::option-map-or-none` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::option_map_or_none)]` error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead --> $DIR/option_map_or_none.rs:13:26 @@ -48,6 +49,7 @@ LL | let _: Option = r.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^ help: try using `ok` instead: `r.ok()` | = note: `-D clippy::result-map-or-into-option` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_map_or_into_option)]` error: aborting due to 5 previous errors diff --git a/src/tools/clippy/tests/ui/option_map_unit_fn_fixable.stderr b/src/tools/clippy/tests/ui/option_map_unit_fn_fixable.stderr index 38bcb5967f694..34aca31e95c97 100644 --- a/src/tools/clippy/tests/ui/option_map_unit_fn_fixable.stderr +++ b/src/tools/clippy/tests/ui/option_map_unit_fn_fixable.stderr @@ -7,6 +7,7 @@ LL | x.field.map(do_nothing); | help: try: `if let Some(x_field) = x.field { do_nothing(x_field) }` | = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::option_map_unit_fn)]` error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:39:5 diff --git a/src/tools/clippy/tests/ui/or_fun_call.stderr b/src/tools/clippy/tests/ui/or_fun_call.stderr index 5a904c2f490e8..afa4b7628112d 100644 --- a/src/tools/clippy/tests/ui/or_fun_call.stderr +++ b/src/tools/clippy/tests/ui/or_fun_call.stderr @@ -5,6 +5,7 @@ LL | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(make)` | = note: `-D clippy::or-fun-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::or_fun_call)]` error: use of `unwrap_or` to construct default value --> $DIR/or_fun_call.rs:55:14 @@ -13,6 +14,7 @@ LL | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = note: `-D clippy::unwrap-or-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_or_default)]` error: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:58:21 diff --git a/src/tools/clippy/tests/ui/or_then_unwrap.stderr b/src/tools/clippy/tests/ui/or_then_unwrap.stderr index 4b47f538a6c4e..99e4488c040df 100644 --- a/src/tools/clippy/tests/ui/or_then_unwrap.stderr +++ b/src/tools/clippy/tests/ui/or_then_unwrap.stderr @@ -5,6 +5,7 @@ LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` | = note: `-D clippy::or-then-unwrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::or_then_unwrap)]` error: found `.or(Ok(…)).unwrap()` --> $DIR/or_then_unwrap.rs:25:20 diff --git a/src/tools/clippy/tests/ui/out_of_bounds_indexing/issue-3102.stderr b/src/tools/clippy/tests/ui/out_of_bounds_indexing/issue-3102.stderr index b50b76bd9b2e8..37db11caab8aa 100644 --- a/src/tools/clippy/tests/ui/out_of_bounds_indexing/issue-3102.stderr +++ b/src/tools/clippy/tests/ui/out_of_bounds_indexing/issue-3102.stderr @@ -5,6 +5,7 @@ LL | &x[num..10]; | ^^ | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds --> $DIR/issue-3102.rs:12:8 diff --git a/src/tools/clippy/tests/ui/out_of_bounds_indexing/simple.stderr b/src/tools/clippy/tests/ui/out_of_bounds_indexing/simple.stderr index ea5e83e87e089..ddef38beb315a 100644 --- a/src/tools/clippy/tests/ui/out_of_bounds_indexing/simple.stderr +++ b/src/tools/clippy/tests/ui/out_of_bounds_indexing/simple.stderr @@ -5,6 +5,7 @@ LL | &x[..=4]; | ^ | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds --> $DIR/simple.rs:10:11 diff --git a/src/tools/clippy/tests/ui/overflow_check_conditional.stderr b/src/tools/clippy/tests/ui/overflow_check_conditional.stderr index b1e9f1eee54f3..b3cab8a210983 100644 --- a/src/tools/clippy/tests/ui/overflow_check_conditional.stderr +++ b/src/tools/clippy/tests/ui/overflow_check_conditional.stderr @@ -5,6 +5,7 @@ LL | if a + b < a {} | ^^^^^^^^^ | = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::overflow_check_conditional)]` error: you are trying to use classic C overflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:8:8 diff --git a/src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr b/src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr index d296b88224d8c..dc62d0e1dbd2d 100644 --- a/src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr +++ b/src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr @@ -10,6 +10,7 @@ help: this expression can be optimized out by applying boolean operations to the LL | let _ = a && b || a; | ^ = note: `-D clippy::overly-complex-bool-expr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::overly_complex_bool_expr)]` error: this boolean expression contains a logic bug --> $DIR/overly_complex_bool_expr.rs:14:13 diff --git a/src/tools/clippy/tests/ui/panic_in_result_fn.stderr b/src/tools/clippy/tests/ui/panic_in_result_fn.stderr index 9040018f1d4c9..d55c5cf36f626 100644 --- a/src/tools/clippy/tests/ui/panic_in_result_fn.stderr +++ b/src/tools/clippy/tests/ui/panic_in_result_fn.stderr @@ -15,6 +15,7 @@ note: return Err() instead of panicking LL | panic!("error"); | ^^^^^^^^^^^^^^^ = note: `-D clippy::panic-in-result-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::panic_in_result_fn)]` error: used `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:53:1 diff --git a/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr b/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr index 368a9970af850..a80e6f27abcb4 100644 --- a/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr +++ b/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr @@ -16,6 +16,7 @@ note: return Err() instead of panicking LL | assert!(x == 5, "wrong argument"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::panic-in-result-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::panic_in_result_fn)]` error: used `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn_assertions.rs:14:5 diff --git a/src/tools/clippy/tests/ui/panicking_macros.stderr b/src/tools/clippy/tests/ui/panicking_macros.stderr index b47220d2cdc35..59ce57d0b3dae 100644 --- a/src/tools/clippy/tests/ui/panicking_macros.stderr +++ b/src/tools/clippy/tests/ui/panicking_macros.stderr @@ -5,6 +5,7 @@ LL | panic!(); | ^^^^^^^^ | = note: `-D clippy::panic` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::panic)]` error: `panic` should not be present in production code --> $DIR/panicking_macros.rs:26:5 @@ -25,6 +26,7 @@ LL | todo!(); | ^^^^^^^ | = note: `-D clippy::todo` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::todo)]` error: `todo` should not be present in production code --> $DIR/panicking_macros.rs:38:5 @@ -45,6 +47,7 @@ LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::unimplemented` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unimplemented)]` error: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:50:5 @@ -65,6 +68,7 @@ LL | unreachable!(); | ^^^^^^^^^^^^^^ | = note: `-D clippy::unreachable` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unreachable)]` error: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:62:5 diff --git a/src/tools/clippy/tests/ui/partial_pub_fields.stderr b/src/tools/clippy/tests/ui/partial_pub_fields.stderr index 95960201769e2..a152287403b75 100644 --- a/src/tools/clippy/tests/ui/partial_pub_fields.stderr +++ b/src/tools/clippy/tests/ui/partial_pub_fields.stderr @@ -6,6 +6,7 @@ LL | pub paths: HashMap, | = help: consider using private field here = note: `-D clippy::partial-pub-fields` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::partial_pub_fields)]` error: mixed usage of pub and non-pub fields --> $DIR/partial_pub_fields.rs:17:9 diff --git a/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr b/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr index 04b29dd8764aa..163d6b1dd7b62 100644 --- a/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr +++ b/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::partialeq-ne-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::partialeq_ne_impl)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/partialeq_to_none.stderr b/src/tools/clippy/tests/ui/partialeq_to_none.stderr index d06ab7aee558b..50ce15001f40f 100644 --- a/src/tools/clippy/tests/ui/partialeq_to_none.stderr +++ b/src/tools/clippy/tests/ui/partialeq_to_none.stderr @@ -5,6 +5,7 @@ LL | if f != None { "yay" } else { "nay" } | ^^^^^^^^^ help: use `Option::is_some()` instead: `f.is_some()` | = note: `-D clippy::partialeq-to-none` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::partialeq_to_none)]` error: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:44:13 diff --git a/src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr b/src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr index c94b321780497..1453d020c412a 100644 --- a/src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr +++ b/src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr @@ -5,6 +5,7 @@ LL | x.push("/bar"); | ^^^^^^ help: try: `"bar"` | = note: `-D clippy::path-buf-push-overwrite` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::path_buf_push_overwrite)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.stderr b/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.stderr index b512f5e1ee256..f21e1894af2a2 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.stderr @@ -6,6 +6,7 @@ LL | Some(_) => (), | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type --> $DIR/mutability.rs:16:9 diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr index 8e0d13bc8bdb8..b72c24840d7d4 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr @@ -6,6 +6,7 @@ LL | if let Value::B | Value::A(_) = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type --> $DIR/pattern_alternatives.rs:17:34 diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_structs.stderr b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_structs.stderr index a0c7a67b521e2..c46c7de6dd658 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_structs.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_structs.stderr @@ -6,6 +6,7 @@ LL | let Struct { .. } = ref_value; | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:15:33 diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_tuples.stderr b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_tuples.stderr index 1001f4f63c686..b365731d5619c 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_tuples.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_tuples.stderr @@ -6,6 +6,7 @@ LL | let TupleStruct(_) = ref_value; | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:13:25 diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr b/src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr index 36869598815d7..dfe4639c7746f 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr @@ -6,6 +6,7 @@ LL | Some(_) => (), | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type --> $DIR/syntax.rs:31:12 diff --git a/src/tools/clippy/tests/ui/patterns.stderr b/src/tools/clippy/tests/ui/patterns.stderr index e2431cb300975..2f608bbc18fae 100644 --- a/src/tools/clippy/tests/ui/patterns.stderr +++ b/src/tools/clippy/tests/ui/patterns.stderr @@ -5,6 +5,7 @@ LL | y @ _ => (), | ^^^^^ help: try: `y` | = note: `-D clippy::redundant-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern)]` error: the `x @ _` pattern can be written as just `x` --> $DIR/patterns.rs:29:9 diff --git a/src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr b/src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr index e7a8ee6cb19be..58a7de84d8f05 100644 --- a/src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr +++ b/src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr @@ -8,6 +8,7 @@ LL | permissions.set_readonly(false); = help: you can set the desired permissions using `PermissionsExt`. For more information, see https://doc.rust-lang.org/std/os/unix/fs/trait.PermissionsExt.html = note: `-D clippy::permissions-set-readonly-false` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::permissions_set_readonly_false)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/precedence.stderr b/src/tools/clippy/tests/ui/precedence.stderr index 30f4607ad17af..bd0cbccc787c8 100644 --- a/src/tools/clippy/tests/ui/precedence.stderr +++ b/src/tools/clippy/tests/ui/precedence.stderr @@ -5,6 +5,7 @@ LL | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` | = note: `-D clippy::precedence` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::precedence)]` error: operator precedence can trip the unwary --> $DIR/precedence.rs:17:5 diff --git a/src/tools/clippy/tests/ui/print.stderr b/src/tools/clippy/tests/ui/print.stderr index e9d88df33f597..bb8d945081e16 100644 --- a/src/tools/clippy/tests/ui/print.stderr +++ b/src/tools/clippy/tests/ui/print.stderr @@ -5,6 +5,7 @@ LL | write!(f, "{:?}", 43.1415) | ^^^^ | = note: `-D clippy::use-debug` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::use_debug)]` error: use of `println!` --> $DIR/print.rs:25:5 @@ -13,6 +14,7 @@ LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-stdout` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `print!` --> $DIR/print.rs:28:5 diff --git a/src/tools/clippy/tests/ui/print_in_format_impl.stderr b/src/tools/clippy/tests/ui/print_in_format_impl.stderr index 7a7a2dc1c2a7f..57f06dc1143f3 100644 --- a/src/tools/clippy/tests/ui/print_in_format_impl.stderr +++ b/src/tools/clippy/tests/ui/print_in_format_impl.stderr @@ -5,6 +5,7 @@ LL | print!("{}", 1); | ^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` | = note: `-D clippy::print-in-format-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_in_format_impl)]` error: use of `println!` in `Debug` impl --> $DIR/print_in_format_impl.rs:23:9 diff --git a/src/tools/clippy/tests/ui/print_literal.stderr b/src/tools/clippy/tests/ui/print_literal.stderr index d7a2fa7f4bb47..1d9751b92e9c5 100644 --- a/src/tools/clippy/tests/ui/print_literal.stderr +++ b/src/tools/clippy/tests/ui/print_literal.stderr @@ -5,6 +5,7 @@ LL | print!("Hello {}", "world"); | ^^^^^^^ | = note: `-D clippy::print-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_literal)]` help: try | LL - print!("Hello {}", "world"); diff --git a/src/tools/clippy/tests/ui/print_stderr.stderr b/src/tools/clippy/tests/ui/print_stderr.stderr index 0a56fbcec9999..7de16331067ec 100644 --- a/src/tools/clippy/tests/ui/print_stderr.stderr +++ b/src/tools/clippy/tests/ui/print_stderr.stderr @@ -5,6 +5,7 @@ LL | eprintln!("Hello"); | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-stderr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_stderr)]` error: use of `eprint!` --> $DIR/print_stderr.rs:8:5 diff --git a/src/tools/clippy/tests/ui/print_with_newline.stderr b/src/tools/clippy/tests/ui/print_with_newline.stderr index 1c5f2548c89b6..7ff6a5f060d0b 100644 --- a/src/tools/clippy/tests/ui/print_with_newline.stderr +++ b/src/tools/clippy/tests/ui/print_with_newline.stderr @@ -5,6 +5,7 @@ LL | print!("Hello\n"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-with-newline` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::print_with_newline)]` help: use `println!` instead | LL - print!("Hello\n"); diff --git a/src/tools/clippy/tests/ui/println_empty_string.stderr b/src/tools/clippy/tests/ui/println_empty_string.stderr index eb740abc6b01e..c89e64f665a75 100644 --- a/src/tools/clippy/tests/ui/println_empty_string.stderr +++ b/src/tools/clippy/tests/ui/println_empty_string.stderr @@ -7,6 +7,7 @@ LL | println!(""); | help: remove the empty string | = note: `-D clippy::println-empty-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::println_empty_string)]` error: empty string literal in `println!` --> $DIR/println_empty_string.rs:8:14 diff --git a/src/tools/clippy/tests/ui/ptr_arg.stderr b/src/tools/clippy/tests/ui/ptr_arg.stderr index e5708ce3a7e2e..cccf2d62d6319 100644 --- a/src/tools/clippy/tests/ui/ptr_arg.stderr +++ b/src/tools/clippy/tests/ui/ptr_arg.stderr @@ -5,6 +5,7 @@ LL | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` | = note: `-D clippy::ptr-arg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_arg)]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:20:18 diff --git a/src/tools/clippy/tests/ui/ptr_as_ptr.stderr b/src/tools/clippy/tests/ui/ptr_as_ptr.stderr index 9bd8f9b17d4dd..c0ce69b4357de 100644 --- a/src/tools/clippy/tests/ui/ptr_as_ptr.stderr +++ b/src/tools/clippy/tests/ui/ptr_as_ptr.stderr @@ -5,6 +5,7 @@ LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::i | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `Box::into_raw(Box::new(o)).cast::>()` | = note: `-D clippy::ptr-as-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]` error: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:27:13 diff --git a/src/tools/clippy/tests/ui/ptr_cast_constness.stderr b/src/tools/clippy/tests/ui/ptr_cast_constness.stderr index 76a5c7e016583..a4bf778ad19d1 100644 --- a/src/tools/clippy/tests/ui/ptr_cast_constness.stderr +++ b/src/tools/clippy/tests/ui/ptr_cast_constness.stderr @@ -5,6 +5,7 @@ LL | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` | = note: `-D clippy::ptr-cast-constness` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_cast_constness)]` error: `as` casting between raw pointers while changing only its constness --> $DIR/ptr_cast_constness.rs:11:19 diff --git a/src/tools/clippy/tests/ui/ptr_eq.stderr b/src/tools/clippy/tests/ui/ptr_eq.stderr index 3cdc30f970a25..2a384accac57f 100644 --- a/src/tools/clippy/tests/ui/ptr_eq.stderr +++ b/src/tools/clippy/tests/ui/ptr_eq.stderr @@ -5,6 +5,7 @@ LL | let _ = a as *const _ as usize == b as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` | = note: `-D clippy::ptr-eq` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]` error: use `std::ptr::eq` when comparing raw pointers --> $DIR/ptr_eq.rs:20:13 diff --git a/src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr b/src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr index fd45224ca067f..e99053846795d 100644 --- a/src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr +++ b/src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr @@ -5,6 +5,7 @@ LL | let _ = ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` | = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_offset_with_cast)]` error: use of `wrapping_offset` with a `usize` casted to an `isize` --> $DIR/ptr_offset_with_cast.rs:16:17 diff --git a/src/tools/clippy/tests/ui/pub_use.stderr b/src/tools/clippy/tests/ui/pub_use.stderr index ba4ee732c05c4..781572736645d 100644 --- a/src/tools/clippy/tests/ui/pub_use.stderr +++ b/src/tools/clippy/tests/ui/pub_use.stderr @@ -6,6 +6,7 @@ LL | pub use inner::Test; | = help: move the exported item to a public module instead = note: `-D clippy::pub-use` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pub_use)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/pub_with_shorthand.stderr b/src/tools/clippy/tests/ui/pub_with_shorthand.stderr index 323b5a23b247b..423b0508092f4 100644 --- a/src/tools/clippy/tests/ui/pub_with_shorthand.stderr +++ b/src/tools/clippy/tests/ui/pub_with_shorthand.stderr @@ -5,6 +5,7 @@ LL | pub(self) fn a() {} | ^^^^^^^^^ help: add it: `pub(in self)` | = note: `-D clippy::pub-with-shorthand` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pub_with_shorthand)]` error: usage of `pub` without `in` --> $DIR/pub_with_shorthand.rs:19:5 diff --git a/src/tools/clippy/tests/ui/pub_without_shorthand.stderr b/src/tools/clippy/tests/ui/pub_without_shorthand.stderr index a18c9bf893449..4fb11cb3d4ad3 100644 --- a/src/tools/clippy/tests/ui/pub_without_shorthand.stderr +++ b/src/tools/clippy/tests/ui/pub_without_shorthand.stderr @@ -5,6 +5,7 @@ LL | pub(in self) fn b() {} | ^^^^^^^^^^^^ help: remove it: `pub(self)` | = note: `-D clippy::pub-without-shorthand` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::pub_without_shorthand)]` error: usage of `pub` with `in` --> $DIR/pub_without_shorthand.rs:18:5 diff --git a/src/tools/clippy/tests/ui/question_mark.stderr b/src/tools/clippy/tests/ui/question_mark.stderr index 5dc62fadd8d65..7b7b85d08e63c 100644 --- a/src/tools/clippy/tests/ui/question_mark.stderr +++ b/src/tools/clippy/tests/ui/question_mark.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ help: replace it with: `a?;` | = note: `-D clippy::question-mark` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::question_mark)]` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:52:9 diff --git a/src/tools/clippy/tests/ui/question_mark_used.stderr b/src/tools/clippy/tests/ui/question_mark_used.stderr index 8b5fcbcdbfd6c..a3f440de80a5d 100644 --- a/src/tools/clippy/tests/ui/question_mark_used.stderr +++ b/src/tools/clippy/tests/ui/question_mark_used.stderr @@ -6,6 +6,7 @@ LL | other_function()?; | = help: consider using a custom macro or match expression = note: `-D clippy::question-mark-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::question_mark_used)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/range.stderr b/src/tools/clippy/tests/ui/range.stderr index ac83b67fde3aa..9f174307b829c 100644 --- a/src/tools/clippy/tests/ui/range.stderr +++ b/src/tools/clippy/tests/ui/range.stderr @@ -5,6 +5,7 @@ LL | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::range-zip-with-len` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::range_zip_with_len)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/range_contains.stderr b/src/tools/clippy/tests/ui/range_contains.stderr index ea34023a46645..349adea2193cc 100644 --- a/src/tools/clippy/tests/ui/range_contains.stderr +++ b/src/tools/clippy/tests/ui/range_contains.stderr @@ -5,6 +5,7 @@ LL | x >= 8 && x < 12; | ^^^^^^^^^^^^^^^^ help: use: `(8..12).contains(&x)` | = note: `-D clippy::manual-range-contains` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_range_contains)]` error: manual `Range::contains` implementation --> $DIR/range_contains.rs:14:5 diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr index f92826fb75362..c5c9b145db855 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr @@ -5,6 +5,7 @@ LL | for _ in 0..3 + 1 {} | ^^^^^^^^ help: use: `0..=3` | = note: `-D clippy::range-plus-one` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::range_plus_one)]` error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:32:14 @@ -31,6 +32,7 @@ LL | let _ = ..=11 - 1; | ^^^^^^^^^ help: use: `..11` | = note: `-D clippy::range-minus-one` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::range_minus_one)]` error: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:46:13 diff --git a/src/tools/clippy/tests/ui/rc_buffer.stderr b/src/tools/clippy/tests/ui/rc_buffer.stderr index d78e39a010d8e..04080326ae0f0 100644 --- a/src/tools/clippy/tests/ui/rc_buffer.stderr +++ b/src/tools/clippy/tests/ui/rc_buffer.stderr @@ -5,6 +5,7 @@ LL | bad1: Rc, | ^^^^^^^^^^ help: try: `Rc` | = note: `-D clippy::rc-buffer` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rc_buffer)]` error: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:12:11 diff --git a/src/tools/clippy/tests/ui/rc_buffer_arc.stderr b/src/tools/clippy/tests/ui/rc_buffer_arc.stderr index 70d4381151af5..52522dd725f4f 100644 --- a/src/tools/clippy/tests/ui/rc_buffer_arc.stderr +++ b/src/tools/clippy/tests/ui/rc_buffer_arc.stderr @@ -5,6 +5,7 @@ LL | bad1: Arc, | ^^^^^^^^^^^ help: try: `Arc` | = note: `-D clippy::rc-buffer` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rc_buffer)]` error: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:11:11 diff --git a/src/tools/clippy/tests/ui/rc_clone_in_vec_init/arc.stderr b/src/tools/clippy/tests/ui/rc_clone_in_vec_init/arc.stderr index 87f7ed56cd3c6..5dc4b5a10e526 100644 --- a/src/tools/clippy/tests/ui/rc_clone_in_vec_init/arc.stderr +++ b/src/tools/clippy/tests/ui/rc_clone_in_vec_init/arc.stderr @@ -6,6 +6,7 @@ LL | let v = vec![Arc::new("x".to_string()); 2]; | = note: each element will point to the same `Arc` instance = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rc_clone_in_vec_init)]` help: consider initializing each `Arc` element individually | LL ~ let v = { diff --git a/src/tools/clippy/tests/ui/rc_clone_in_vec_init/rc.stderr b/src/tools/clippy/tests/ui/rc_clone_in_vec_init/rc.stderr index 3fa187f0b813d..e6bc6f68b3e49 100644 --- a/src/tools/clippy/tests/ui/rc_clone_in_vec_init/rc.stderr +++ b/src/tools/clippy/tests/ui/rc_clone_in_vec_init/rc.stderr @@ -6,6 +6,7 @@ LL | let v = vec![Rc::new("x".to_string()); 2]; | = note: each element will point to the same `Rc` instance = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rc_clone_in_vec_init)]` help: consider initializing each `Rc` element individually | LL ~ let v = { diff --git a/src/tools/clippy/tests/ui/rc_clone_in_vec_init/weak.stderr b/src/tools/clippy/tests/ui/rc_clone_in_vec_init/weak.stderr index 9b60c22c28106..25d7dae72da30 100644 --- a/src/tools/clippy/tests/ui/rc_clone_in_vec_init/weak.stderr +++ b/src/tools/clippy/tests/ui/rc_clone_in_vec_init/weak.stderr @@ -6,6 +6,7 @@ LL | let v = vec![SyncWeak::::new(); 2]; | = note: each element will point to the same `Weak` instance = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rc_clone_in_vec_init)]` help: consider initializing each `Weak` element individually | LL ~ let v = { diff --git a/src/tools/clippy/tests/ui/rc_mutex.stderr b/src/tools/clippy/tests/ui/rc_mutex.stderr index e21337b0f2ed4..50922fb67e492 100644 --- a/src/tools/clippy/tests/ui/rc_mutex.stderr +++ b/src/tools/clippy/tests/ui/rc_mutex.stderr @@ -6,6 +6,7 @@ LL | foo: Rc>, | = help: consider using `Rc>` or `Arc>` instead = note: `-D clippy::rc-mutex` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rc_mutex)]` error: usage of `Rc>` --> $DIR/rc_mutex.rs:27:18 diff --git a/src/tools/clippy/tests/ui/read_line_without_trim.stderr b/src/tools/clippy/tests/ui/read_line_without_trim.stderr index a7751eb68d837..8d46e0f790781 100644 --- a/src/tools/clippy/tests/ui/read_line_without_trim.stderr +++ b/src/tools/clippy/tests/ui/read_line_without_trim.stderr @@ -12,6 +12,7 @@ note: call to `.read_line()` here, which leaves a trailing newline character in LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::read-line-without-trim` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::read_line_without_trim)]` error: calling `.parse()` without trimming the trailing newline character --> $DIR/read_line_without_trim.rs:16:20 diff --git a/src/tools/clippy/tests/ui/read_zero_byte_vec.stderr b/src/tools/clippy/tests/ui/read_zero_byte_vec.stderr index b80a614eceba3..523ecb2948df3 100644 --- a/src/tools/clippy/tests/ui/read_zero_byte_vec.stderr +++ b/src/tools/clippy/tests/ui/read_zero_byte_vec.stderr @@ -5,6 +5,7 @@ LL | f.read_exact(&mut data).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data.resize(20, 0); f.read_exact(&mut data).unwrap();` | = note: `-D clippy::read-zero-byte-vec` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::read_zero_byte_vec)]` error: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:27:5 diff --git a/src/tools/clippy/tests/ui/readonly_write_lock.stderr b/src/tools/clippy/tests/ui/readonly_write_lock.stderr index ca754e5c8f29d..b4a093ce9c93f 100644 --- a/src/tools/clippy/tests/ui/readonly_write_lock.stderr +++ b/src/tools/clippy/tests/ui/readonly_write_lock.stderr @@ -5,6 +5,7 @@ LL | let writer = lock.write().unwrap(); | ^^^^^^^^^^^^ help: consider using a read lock instead: `lock.read()` | = note: `-D clippy::readonly-write-lock` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::readonly_write_lock)]` error: this write lock is used only for reading --> $DIR/readonly_write_lock.rs:23:22 diff --git a/src/tools/clippy/tests/ui/recursive_format_impl.stderr b/src/tools/clippy/tests/ui/recursive_format_impl.stderr index c80e90ba61bc2..adb16f44a999e 100644 --- a/src/tools/clippy/tests/ui/recursive_format_impl.stderr +++ b/src/tools/clippy/tests/ui/recursive_format_impl.stderr @@ -5,6 +5,7 @@ LL | write!(f, "{}", self.to_string()) | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::recursive-format-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::recursive_format_impl)]` error: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:77:9 diff --git a/src/tools/clippy/tests/ui/redundant_allocation.stderr b/src/tools/clippy/tests/ui/redundant_allocation.stderr index 233e3eb42896e..d72f6b202ec23 100644 --- a/src/tools/clippy/tests/ui/redundant_allocation.stderr +++ b/src/tools/clippy/tests/ui/redundant_allocation.stderr @@ -7,6 +7,7 @@ LL | pub fn box_test6(foo: Box>) {} = note: `Rc` is already on the heap, `Box>` makes an extra allocation = help: consider using just `Box` or `Rc` = note: `-D clippy::redundant-allocation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box>` --> $DIR/redundant_allocation.rs:20:30 diff --git a/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr b/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr index 2e6e078b24b02..603600f30227d 100644 --- a/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr +++ b/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr @@ -6,6 +6,7 @@ LL | pub fn box_test1(foo: Box<&T>) {} | = note: `&T` is already a pointer, `Box<&T>` allocates a pointer on the heap = note: `-D clippy::redundant-allocation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box<&MyStruct>` --> $DIR/redundant_allocation_fixable.rs:25:27 diff --git a/src/tools/clippy/tests/ui/redundant_async_block.stderr b/src/tools/clippy/tests/ui/redundant_async_block.stderr index 0ebd4d2cece7f..adb44d7a62ef4 100644 --- a/src/tools/clippy/tests/ui/redundant_async_block.stderr +++ b/src/tools/clippy/tests/ui/redundant_async_block.stderr @@ -5,6 +5,7 @@ LL | let x = async { f.await }; | ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f` | = note: `-D clippy::redundant-async-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_async_block)]` error: this async expression only awaits a single future --> $DIR/redundant_async_block.rs:20:16 diff --git a/src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr b/src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr index 008db304daf95..3a44636fc78ef 100644 --- a/src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr +++ b/src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr @@ -5,6 +5,7 @@ LL | if let [a @ ..] = [()] {} | ^^^^^^^^ help: this is better represented with just the binding: `a` | = note: `-D clippy::redundant-at-rest-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_at_rest_pattern)]` error: using a rest pattern to bind an entire slice to a local --> $DIR/redundant_at_rest_pattern.rs:10:12 diff --git a/src/tools/clippy/tests/ui/redundant_clone.stderr b/src/tools/clippy/tests/ui/redundant_clone.stderr index a1c09d2b3c79f..4115fcf21228b 100644 --- a/src/tools/clippy/tests/ui/redundant_clone.stderr +++ b/src/tools/clippy/tests/ui/redundant_clone.stderr @@ -10,6 +10,7 @@ note: this value is dropped without further use LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::redundant-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone --> $DIR/redundant_clone.rs:18:15 diff --git a/src/tools/clippy/tests/ui/redundant_closure_call_early.stderr b/src/tools/clippy/tests/ui/redundant_closure_call_early.stderr index 4a2ce175b5ce1..be7a981dc27b8 100644 --- a/src/tools/clippy/tests/ui/redundant_closure_call_early.stderr +++ b/src/tools/clippy/tests/ui/redundant_closure_call_early.stderr @@ -5,6 +5,7 @@ LL | let mut k = (|m| m + 1)(i); | ^^^^^^^^^^^^^^ | = note: `-D clippy::redundant-closure-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_early.rs:14:9 diff --git a/src/tools/clippy/tests/ui/redundant_closure_call_fixable.stderr b/src/tools/clippy/tests/ui/redundant_closure_call_fixable.stderr index a285420ea8f7d..a7cdb43693fc9 100644 --- a/src/tools/clippy/tests/ui/redundant_closure_call_fixable.stderr +++ b/src/tools/clippy/tests/ui/redundant_closure_call_fixable.stderr @@ -5,6 +5,7 @@ LL | let a = (|| 42)(); | ^^^^^^^^^ help: try doing something like: `42` | = note: `-D clippy::redundant-closure-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:17:13 diff --git a/src/tools/clippy/tests/ui/redundant_closure_call_late.stderr b/src/tools/clippy/tests/ui/redundant_closure_call_late.stderr index 4a0fe95d57345..a89bfc7703de4 100644 --- a/src/tools/clippy/tests/ui/redundant_closure_call_late.stderr +++ b/src/tools/clippy/tests/ui/redundant_closure_call_late.stderr @@ -5,6 +5,7 @@ LL | i = redun_closure(); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::redundant-closure-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: closure called just once immediately after it was declared --> $DIR/redundant_closure_call_late.rs:22:5 diff --git a/src/tools/clippy/tests/ui/redundant_else.stderr b/src/tools/clippy/tests/ui/redundant_else.stderr index d6759422e953b..af33e05a608f3 100644 --- a/src/tools/clippy/tests/ui/redundant_else.stderr +++ b/src/tools/clippy/tests/ui/redundant_else.stderr @@ -10,6 +10,7 @@ LL | | } | = help: remove the `else` block and move the contents out = note: `-D clippy::redundant-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_else)]` error: redundant else block --> $DIR/redundant_else.rs:18:16 diff --git a/src/tools/clippy/tests/ui/redundant_field_names.stderr b/src/tools/clippy/tests/ui/redundant_field_names.stderr index 8bcf33007db6b..5fee60b8ea411 100644 --- a/src/tools/clippy/tests/ui/redundant_field_names.stderr +++ b/src/tools/clippy/tests/ui/redundant_field_names.stderr @@ -5,6 +5,7 @@ LL | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` | = note: `-D clippy::redundant-field-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_field_names)]` error: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:34:9 diff --git a/src/tools/clippy/tests/ui/redundant_guards.stderr b/src/tools/clippy/tests/ui/redundant_guards.stderr index 5007723438263..0a45a6d7619fe 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.stderr +++ b/src/tools/clippy/tests/ui/redundant_guards.stderr @@ -5,6 +5,7 @@ LL | C(x, y) if let 1 = y => .., | ^^^^^^^^^ | = note: `-D clippy::redundant-guards` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_guards)]` help: try | LL - C(x, y) if let 1 = y => .., diff --git a/src/tools/clippy/tests/ui/redundant_locals.stderr b/src/tools/clippy/tests/ui/redundant_locals.stderr index 587de05752476..13b872e9576d8 100644 --- a/src/tools/clippy/tests/ui/redundant_locals.stderr +++ b/src/tools/clippy/tests/ui/redundant_locals.stderr @@ -8,6 +8,7 @@ LL | let x = x; | = help: remove the redefinition of `x` = note: `-D clippy::redundant-locals` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_locals)]` error: redundant redefinition of a binding --> $DIR/redundant_locals.rs:16:9 diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_drop_order.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_drop_order.stderr index 636d1a292aca2..28f0244b9e87b 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_drop_order.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_drop_order.stderr @@ -7,6 +7,7 @@ LL | if let Ok(_) = m.lock() {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_drop_order.rs:16:12 diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_ipaddr.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_ipaddr.stderr index f5f5d268a621f..d36129a2bee95 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_ipaddr.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_ipaddr.stderr @@ -5,6 +5,7 @@ LL | if let V4(_) = &ipaddr {} | -------^^^^^---------- help: try: `if ipaddr.is_ipv4()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:17:12 diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr index 73b0353ce34fd..fdf395d82862a 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr @@ -5,6 +5,7 @@ LL | matches!(maybe_some, None if !boolean) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (!boolean)` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:18:13 diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.stderr index 6c4603bcf3d83..c010c3c44375a 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.stderr @@ -5,6 +5,7 @@ LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try: `if Pending::<()>.is_pending()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:17:12 diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_result.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_result.stderr index 4467e8e81073d..19e7f82298ea6 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_result.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_result.stderr @@ -5,6 +5,7 @@ LL | if let Ok(_) = &result {} | -------^^^^^---------- help: try: `if result.is_ok()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:17:12 diff --git a/src/tools/clippy/tests/ui/redundant_pub_crate.stderr b/src/tools/clippy/tests/ui/redundant_pub_crate.stderr index f8c7d7a9e69e3..5d7744aa86492 100644 --- a/src/tools/clippy/tests/ui/redundant_pub_crate.stderr +++ b/src/tools/clippy/tests/ui/redundant_pub_crate.stderr @@ -7,6 +7,7 @@ LL | pub(crate) fn g() {} // private due to m1 | help: consider using: `pub` | = note: `-D clippy::redundant-pub-crate` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_pub_crate)]` error: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:11:9 diff --git a/src/tools/clippy/tests/ui/redundant_slicing.stderr b/src/tools/clippy/tests/ui/redundant_slicing.stderr index e0db72765a8da..05287c882f7e1 100644 --- a/src/tools/clippy/tests/ui/redundant_slicing.stderr +++ b/src/tools/clippy/tests/ui/redundant_slicing.stderr @@ -5,6 +5,7 @@ LL | let _ = &slice[..]; // Redundant slice | ^^^^^^^^^^ help: use the original value instead: `slice` | = note: `-D clippy::redundant-slicing` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_slicing)]` error: redundant slicing of the whole range --> $DIR/redundant_slicing.rs:12:13 diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr b/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr index 3e344fc67f92c..26f50345351fe 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr @@ -5,6 +5,7 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removi | -^^^^^^^---- help: consider removing `'static`: `&str` | = note: `-D clippy::redundant-static-lifetimes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]` error: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:10:21 diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes_multiple.stderr b/src/tools/clippy/tests/ui/redundant_static_lifetimes_multiple.stderr index 297f505d96841..bf4d211200f3c 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes_multiple.stderr +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes_multiple.stderr @@ -5,6 +5,7 @@ LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` | = note: `-D clippy::redundant-static-lifetimes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]` error: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:4:30 diff --git a/src/tools/clippy/tests/ui/redundant_type_annotations.stderr b/src/tools/clippy/tests/ui/redundant_type_annotations.stderr index 927761c74372c..d1f26f1832e39 100644 --- a/src/tools/clippy/tests/ui/redundant_type_annotations.stderr +++ b/src/tools/clippy/tests/ui/redundant_type_annotations.stderr @@ -5,6 +5,7 @@ LL | let v: u32 = self.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::redundant-type-annotations` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_type_annotations)]` error: redundant type annotation --> $DIR/redundant_type_annotations.rs:84:9 diff --git a/src/tools/clippy/tests/ui/ref_binding_to_reference.stderr b/src/tools/clippy/tests/ui/ref_binding_to_reference.stderr index 2505d7d500bf8..6e8b43a3e52a5 100644 --- a/src/tools/clippy/tests/ui/ref_binding_to_reference.stderr +++ b/src/tools/clippy/tests/ui/ref_binding_to_reference.stderr @@ -5,6 +5,7 @@ LL | Some(ref x) => x, | ^^^^^ | = note: `-D clippy::ref-binding-to-reference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ref_binding_to_reference)]` help: try | LL | Some(x) => &x, diff --git a/src/tools/clippy/tests/ui/ref_option_ref.stderr b/src/tools/clippy/tests/ui/ref_option_ref.stderr index 430dd9c0e8dc8..6a28a68dc2bbb 100644 --- a/src/tools/clippy/tests/ui/ref_option_ref.stderr +++ b/src/tools/clippy/tests/ui/ref_option_ref.stderr @@ -5,6 +5,7 @@ LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` | = note: `-D clippy::ref-option-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ref_option_ref)]` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:14:18 diff --git a/src/tools/clippy/tests/ui/ref_patterns.stderr b/src/tools/clippy/tests/ui/ref_patterns.stderr index 5883a7883e64d..74892bac6e4f4 100644 --- a/src/tools/clippy/tests/ui/ref_patterns.stderr +++ b/src/tools/clippy/tests/ui/ref_patterns.stderr @@ -6,6 +6,7 @@ LL | Some(ref opt) => {}, | = help: consider using `&` for clarity instead = note: `-D clippy::ref-patterns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ref_patterns)]` error: usage of ref pattern --> $DIR/ref_patterns.rs:15:9 diff --git a/src/tools/clippy/tests/ui/regex.stderr b/src/tools/clippy/tests/ui/regex.stderr index ed5aa29e079e1..91f90157e6847 100644 --- a/src/tools/clippy/tests/ui/regex.stderr +++ b/src/tools/clippy/tests/ui/regex.stderr @@ -6,6 +6,7 @@ LL | let pipe_in_wrong_position = Regex::new("|"); | = help: the regex is unlikely to be useful as it is = note: `-D clippy::trivial-regex` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::trivial_regex)]` error: trivial regex --> $DIR/regex.rs:20:60 @@ -22,6 +23,7 @@ LL | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ | = note: `-D clippy::invalid-regex` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::invalid_regex)]` error: regex syntax error: invalid character class range, the start must be <= the end --> $DIR/regex.rs:25:37 diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index 2b26af16bad50..d98fc7b30db57 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -5,6 +5,7 @@ LL | #![warn(clippy::almost_complete_letter_range)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range` | = note: `-D renamed-and-removed-lints` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` --> $DIR/rename.rs:53:9 diff --git a/src/tools/clippy/tests/ui/repeat_once.stderr b/src/tools/clippy/tests/ui/repeat_once.stderr index ae5258d4c2fbd..895729390785a 100644 --- a/src/tools/clippy/tests/ui/repeat_once.stderr +++ b/src/tools/clippy/tests/ui/repeat_once.stderr @@ -5,6 +5,7 @@ LL | let a = [1; 5].repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `[1; 5].to_vec()` | = note: `-D clippy::repeat-once` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::repeat_once)]` error: calling `repeat(1)` on slice --> $DIR/repeat_once.rs:10:13 diff --git a/src/tools/clippy/tests/ui/repl_uninit.stderr b/src/tools/clippy/tests/ui/repl_uninit.stderr index 6bbefcadb8639..c82f29adb5ac4 100644 --- a/src/tools/clippy/tests/ui/repl_uninit.stderr +++ b/src/tools/clippy/tests/ui/repl_uninit.stderr @@ -5,6 +5,7 @@ LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` | = note: `-D clippy::mem-replace-with-uninit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_uninit)]` error: replacing with `mem::MaybeUninit::uninit().assume_init()` --> $DIR/repl_uninit.rs:23:23 diff --git a/src/tools/clippy/tests/ui/reserve_after_initialization.stderr b/src/tools/clippy/tests/ui/reserve_after_initialization.stderr index 4a6164d8ebc94..a910338907668 100644 --- a/src/tools/clippy/tests/ui/reserve_after_initialization.stderr +++ b/src/tools/clippy/tests/ui/reserve_after_initialization.stderr @@ -6,6 +6,7 @@ LL | | v1.reserve(10); | |___________________^ help: consider using `Vec::with_capacity(/* Space hint */)`: `let mut v1: Vec = Vec::with_capacity(10);` | = note: `-D clippy::reserve-after-initialization` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::reserve_after_initialization)]` error: call to `reserve` immediately after creation --> $DIR/reserve_after_initialization.rs:17:5 diff --git a/src/tools/clippy/tests/ui/rest_pat_in_fully_bound_structs.stderr b/src/tools/clippy/tests/ui/rest_pat_in_fully_bound_structs.stderr index f8e4087823d61..2c221b4dbb2cc 100644 --- a/src/tools/clippy/tests/ui/rest_pat_in_fully_bound_structs.stderr +++ b/src/tools/clippy/tests/ui/rest_pat_in_fully_bound_structs.stderr @@ -6,6 +6,7 @@ LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint | = help: consider removing `..` from this binding = note: `-D clippy::rest-pat-in-fully-bound-structs` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::rest_pat_in_fully_bound_structs)]` error: unnecessary use of `..` pattern in struct binding. All fields were already bound --> $DIR/rest_pat_in_fully_bound_structs.rs:24:9 diff --git a/src/tools/clippy/tests/ui/result_large_err.stderr b/src/tools/clippy/tests/ui/result_large_err.stderr index c51531f55db67..d42dd6600a324 100644 --- a/src/tools/clippy/tests/ui/result_large_err.stderr +++ b/src/tools/clippy/tests/ui/result_large_err.stderr @@ -6,6 +6,7 @@ LL | pub fn large_err() -> Result<(), [u8; 512]> { | = help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>` = note: `-D clippy::result-large-err` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_large_err)]` error: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:20:21 diff --git a/src/tools/clippy/tests/ui/result_map_or_into_option.stderr b/src/tools/clippy/tests/ui/result_map_or_into_option.stderr index 2b057042aee24..9396ea4c064ef 100644 --- a/src/tools/clippy/tests/ui/result_map_or_into_option.stderr +++ b/src/tools/clippy/tests/ui/result_map_or_into_option.stderr @@ -5,6 +5,7 @@ LL | let _ = opt.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^^^ help: try using `ok` instead: `opt.ok()` | = note: `-D clippy::result-map-or-into-option` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_map_or_into_option)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/result_map_unit_fn_fixable.stderr b/src/tools/clippy/tests/ui/result_map_unit_fn_fixable.stderr index 5def0fe41733a..42ee273c2bd23 100644 --- a/src/tools/clippy/tests/ui/result_map_unit_fn_fixable.stderr +++ b/src/tools/clippy/tests/ui/result_map_unit_fn_fixable.stderr @@ -7,6 +7,7 @@ LL | x.field.map(do_nothing); | help: try: `if let Ok(x_field) = x.field { do_nothing(x_field) }` | = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_map_unit_fn)]` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:36:5 diff --git a/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr b/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr index ba17e22d0b359..ccf9bfb947c70 100644 --- a/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr +++ b/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr @@ -7,6 +7,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | help: try: `if let Ok(value) = x.field { ... }` | = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_map_unit_fn)]` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:27:5 diff --git a/src/tools/clippy/tests/ui/result_unit_error.stderr b/src/tools/clippy/tests/ui/result_unit_error.stderr index 252c72481f513..72208f5391647 100644 --- a/src/tools/clippy/tests/ui/result_unit_error.stderr +++ b/src/tools/clippy/tests/ui/result_unit_error.stderr @@ -6,6 +6,7 @@ LL | pub fn returns_unit_error() -> Result { | = help: use a custom `Error` type instead = note: `-D clippy::result-unit-err` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` --> $DIR/result_unit_error.rs:13:5 diff --git a/src/tools/clippy/tests/ui/return_self_not_must_use.stderr b/src/tools/clippy/tests/ui/return_self_not_must_use.stderr index adfd6564d99cb..b3e41470d7b12 100644 --- a/src/tools/clippy/tests/ui/return_self_not_must_use.stderr +++ b/src/tools/clippy/tests/ui/return_self_not_must_use.stderr @@ -6,6 +6,7 @@ LL | fn what(&self) -> Self; | = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type = note: `-D clippy::return-self-not-must-use` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::return_self_not_must_use)]` error: missing `#[must_use]` attribute on a method returning `Self` --> $DIR/return_self_not_must_use.rs:19:5 diff --git a/src/tools/clippy/tests/ui/reversed_empty_ranges_fixable.stderr b/src/tools/clippy/tests/ui/reversed_empty_ranges_fixable.stderr index 2d1bfe62c9236..92fbac8e30c9e 100644 --- a/src/tools/clippy/tests/ui/reversed_empty_ranges_fixable.stderr +++ b/src/tools/clippy/tests/ui/reversed_empty_ranges_fixable.stderr @@ -5,6 +5,7 @@ LL | (42..=21).for_each(|x| println!("{}", x)); | ^^^^^^^^^ | = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` help: consider using the following if you are attempting to iterate over this range in reverse | LL | (21..=42).rev().for_each(|x| println!("{}", x)); diff --git a/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_fixable.stderr b/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_fixable.stderr index a135da488ffd3..843d6a36d9be5 100644 --- a/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_fixable.stderr +++ b/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_fixable.stderr @@ -5,6 +5,7 @@ LL | for i in 10..0 { | ^^^^^ | = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` help: consider using the following if you are attempting to iterate over this range in reverse | LL | for i in (0..10).rev() { diff --git a/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_unfixable.stderr b/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_unfixable.stderr index f644631749524..73165e091cb16 100644 --- a/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_unfixable.stderr +++ b/src/tools/clippy/tests/ui/reversed_empty_ranges_loops_unfixable.stderr @@ -5,6 +5,7 @@ LL | for i in 5..5 { | ^^^^ | = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` error: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_unfixable.rs:11:14 diff --git a/src/tools/clippy/tests/ui/reversed_empty_ranges_unfixable.stderr b/src/tools/clippy/tests/ui/reversed_empty_ranges_unfixable.stderr index d32301742d346..e3dc96dfb9c4e 100644 --- a/src/tools/clippy/tests/ui/reversed_empty_ranges_unfixable.stderr +++ b/src/tools/clippy/tests/ui/reversed_empty_ranges_unfixable.stderr @@ -5,6 +5,7 @@ LL | let _ = &arr[3usize..=1usize]; | ^^^^^^^^^^^^^^^ | = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` error: this range is reversed and using it to index a slice will panic at run-time --> $DIR/reversed_empty_ranges_unfixable.rs:11:18 diff --git a/src/tools/clippy/tests/ui/same_item_push.stderr b/src/tools/clippy/tests/ui/same_item_push.stderr index 8e876e914cea9..f519be463695b 100644 --- a/src/tools/clippy/tests/ui/same_item_push.stderr +++ b/src/tools/clippy/tests/ui/same_item_push.stderr @@ -6,6 +6,7 @@ LL | vec.push(item); | = help: try using vec![item;SIZE] or vec.resize(NEW_SIZE, item) = note: `-D clippy::same-item-push` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::same_item_push)]` error: it looks like the same item is being pushed into this Vec --> $DIR/same_item_push.rs:30:9 diff --git a/src/tools/clippy/tests/ui/same_name_method.stderr b/src/tools/clippy/tests/ui/same_name_method.stderr index b31d2537eadfc..3c5c4a53ad1f6 100644 --- a/src/tools/clippy/tests/ui/same_name_method.stderr +++ b/src/tools/clippy/tests/ui/same_name_method.stderr @@ -10,6 +10,7 @@ note: existing `foo` defined here LL | fn foo() {} | ^^^^^^^^^^^ = note: `-D clippy::same-name-method` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::same_name_method)]` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:36:13 diff --git a/src/tools/clippy/tests/ui/search_is_some.stderr b/src/tools/clippy/tests/ui/search_is_some.stderr index 7eff614d17c69..a7a47447f61de 100644 --- a/src/tools/clippy/tests/ui/search_is_some.stderr +++ b/src/tools/clippy/tests/ui/search_is_some.stderr @@ -10,6 +10,7 @@ LL | | ).is_some(); | = help: this is more succinctly expressed by calling `any()` = note: `-D clippy::search-is-some` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: called `is_some()` after searching an `Iterator` with `position` --> $DIR/search_is_some.rs:21:13 diff --git a/src/tools/clippy/tests/ui/search_is_some_fixable_none.stderr b/src/tools/clippy/tests/ui/search_is_some_fixable_none.stderr index 82b81f2906046..f33b0430912a1 100644 --- a/src/tools/clippy/tests/ui/search_is_some_fixable_none.stderr +++ b/src/tools/clippy/tests/ui/search_is_some_fixable_none.stderr @@ -5,6 +5,7 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| *x < 0)` | = note: `-D clippy::search-is-some` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:10:13 diff --git a/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr b/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr index 5466d0cb9f003..e878e62de07f3 100644 --- a/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr +++ b/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr @@ -5,6 +5,7 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| *x < 0)` | = note: `-D clippy::search-is-some` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::search_is_some)]` error: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:10:20 diff --git a/src/tools/clippy/tests/ui/seek_from_current.stderr b/src/tools/clippy/tests/ui/seek_from_current.stderr index 2549a26b23c3d..42eb342c10aa6 100644 --- a/src/tools/clippy/tests/ui/seek_from_current.stderr +++ b/src/tools/clippy/tests/ui/seek_from_current.stderr @@ -5,6 +5,7 @@ LL | f.seek(SeekFrom::Current(0))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `f.stream_position()` | = note: `-D clippy::seek-from-current` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::seek_from_current)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/seek_to_start_instead_of_rewind.stderr b/src/tools/clippy/tests/ui/seek_to_start_instead_of_rewind.stderr index 47cddfe7ea694..05c11cf7f8c61 100644 --- a/src/tools/clippy/tests/ui/seek_to_start_instead_of_rewind.stderr +++ b/src/tools/clippy/tests/ui/seek_to_start_instead_of_rewind.stderr @@ -5,6 +5,7 @@ LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` | = note: `-D clippy::seek-to-start-instead-of-rewind` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::seek_to_start_instead_of_rewind)]` error: used `seek` to go to the start of the stream --> $DIR/seek_to_start_instead_of_rewind.rs:57:7 diff --git a/src/tools/clippy/tests/ui/self_assignment.stderr b/src/tools/clippy/tests/ui/self_assignment.stderr index ecb62f96a93a6..4612f8f824481 100644 --- a/src/tools/clippy/tests/ui/self_assignment.stderr +++ b/src/tools/clippy/tests/ui/self_assignment.stderr @@ -5,6 +5,7 @@ LL | a = a; | ^^^^^ | = note: `-D clippy::self-assignment` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::self_assignment)]` error: self-assignment of `*b` to `*b` --> $DIR/self_assignment.rs:16:5 diff --git a/src/tools/clippy/tests/ui/self_named_constructors.stderr b/src/tools/clippy/tests/ui/self_named_constructors.stderr index 2024d86f91fcc..f299b860d4783 100644 --- a/src/tools/clippy/tests/ui/self_named_constructors.stderr +++ b/src/tools/clippy/tests/ui/self_named_constructors.stderr @@ -9,6 +9,7 @@ LL | | } | |_____^ | = note: `-D clippy::self-named-constructors` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::self_named_constructors)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.stderr b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.stderr index 8d9a67585cf12..66373a13c5690 100644 --- a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.stderr +++ b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.stderr @@ -5,6 +5,7 @@ LL | println!("Hello") | ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");` | = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_if_nothing_returned)]` error: consider adding a `;` to the last statement for consistent formatting --> $DIR/semicolon_if_nothing_returned.rs:12:5 diff --git a/src/tools/clippy/tests/ui/semicolon_inside_block.stderr b/src/tools/clippy/tests/ui/semicolon_inside_block.stderr index 825c7142fdfa4..1bfc1f24c436a 100644 --- a/src/tools/clippy/tests/ui/semicolon_inside_block.stderr +++ b/src/tools/clippy/tests/ui/semicolon_inside_block.stderr @@ -5,6 +5,7 @@ LL | { unit_fn_block() }; | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::semicolon-inside-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_inside_block)]` help: put the `;` here | LL - { unit_fn_block() }; diff --git a/src/tools/clippy/tests/ui/semicolon_outside_block.stderr b/src/tools/clippy/tests/ui/semicolon_outside_block.stderr index 53c6bbd825c18..427271fca64da 100644 --- a/src/tools/clippy/tests/ui/semicolon_outside_block.stderr +++ b/src/tools/clippy/tests/ui/semicolon_outside_block.stderr @@ -5,6 +5,7 @@ LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::semicolon-outside-block` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::semicolon_outside_block)]` help: put the `;` here | LL - { unit_fn_block(); } diff --git a/src/tools/clippy/tests/ui/serde.stderr b/src/tools/clippy/tests/ui/serde.stderr index a0d8217010e93..e5d64e271644d 100644 --- a/src/tools/clippy/tests/ui/serde.stderr +++ b/src/tools/clippy/tests/ui/serde.stderr @@ -11,6 +11,7 @@ LL | | } | |_____^ | = note: `-D clippy::serde-api-misuse` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::serde_api_misuse)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/shadow.stderr b/src/tools/clippy/tests/ui/shadow.stderr index 88b02f53be12e..26ace287b1f4a 100644 --- a/src/tools/clippy/tests/ui/shadow.stderr +++ b/src/tools/clippy/tests/ui/shadow.stderr @@ -10,6 +10,7 @@ note: previous binding is here LL | let x = 1; | ^ = note: `-D clippy::shadow-same` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::shadow_same)]` error: `mut x` is shadowed by itself in `&x` --> $DIR/shadow.rs:25:13 @@ -59,6 +60,7 @@ note: previous binding is here LL | let x = ([[0]], ()); | ^ = note: `-D clippy::shadow-reuse` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::shadow_reuse)]` error: `x` is shadowed --> $DIR/shadow.rs:33:9 @@ -156,6 +158,7 @@ note: previous binding is here LL | let x = 1; | ^ = note: `-D clippy::shadow-unrelated` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::shadow_unrelated)]` error: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:60:13 diff --git a/src/tools/clippy/tests/ui/short_circuit_statement.stderr b/src/tools/clippy/tests/ui/short_circuit_statement.stderr index 1f7adea4a8b11..dbdf44dfcbd98 100644 --- a/src/tools/clippy/tests/ui/short_circuit_statement.stderr +++ b/src/tools/clippy/tests/ui/short_circuit_statement.stderr @@ -5,6 +5,7 @@ LL | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` | = note: `-D clippy::short-circuit-statement` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::short_circuit_statement)]` error: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:6:5 diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr index 7ad00d14d0cda..c9894eec53a20 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr @@ -9,6 +9,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Add` or choosing a less ambiguous method name = note: `-D clippy::should-implement-trait` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]` error: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` --> $DIR/method_list_1.rs:30:5 diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr index 0073c899813f7..79afddea24798 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr @@ -9,6 +9,7 @@ LL | | } | = help: consider implementing the trait `std::cmp::PartialEq` or choosing a less ambiguous method name = note: `-D clippy::should-implement-trait` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]` error: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` --> $DIR/method_list_2.rs:31:5 @@ -174,6 +175,7 @@ LL | pub fn hash(&self, state: &mut T) { | = warning: changing this function will impact semver compatibility = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: aborting due to 16 previous errors diff --git a/src/tools/clippy/tests/ui/significant_drop_in_scrutinee.stderr b/src/tools/clippy/tests/ui/significant_drop_in_scrutinee.stderr index 6ead59b072580..05bfda5475d8b 100644 --- a/src/tools/clippy/tests/ui/significant_drop_in_scrutinee.stderr +++ b/src/tools/clippy/tests/ui/significant_drop_in_scrutinee.stderr @@ -12,6 +12,7 @@ LL | }; | = note: this might lead to deadlocks or other unexpected behavior = note: `-D clippy::significant-drop-in-scrutinee` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::significant_drop_in_scrutinee)]` help: try moving the temporary above the match | LL ~ let value = mutex.lock().unwrap().foo(); diff --git a/src/tools/clippy/tests/ui/significant_drop_tightening.stderr b/src/tools/clippy/tests/ui/significant_drop_tightening.stderr index ff6f5907ebd5f..6572d99693170 100644 --- a/src/tools/clippy/tests/ui/significant_drop_tightening.stderr +++ b/src/tools/clippy/tests/ui/significant_drop_tightening.stderr @@ -16,6 +16,7 @@ LL | | } | = note: this might lead to unnecessary resource contention = note: `-D clippy::significant-drop-tightening` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::significant_drop_tightening)]` help: drop the temporary after the end of its last usage | LL ~ let _ = *lock; diff --git a/src/tools/clippy/tests/ui/similar_names.stderr b/src/tools/clippy/tests/ui/similar_names.stderr index 059e26d589113..011dbe679c082 100644 --- a/src/tools/clippy/tests/ui/similar_names.stderr +++ b/src/tools/clippy/tests/ui/similar_names.stderr @@ -10,6 +10,7 @@ note: existing binding defined here LL | let apple: i32; | ^^^^^ = note: `-D clippy::similar-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::similar_names)]` error: binding's name is too similar to existing binding --> $DIR/similar_names.rs:24:9 diff --git a/src/tools/clippy/tests/ui/single_call_fn.stderr b/src/tools/clippy/tests/ui/single_call_fn.stderr index 9ef8c487844fb..4acb383c40846 100644 --- a/src/tools/clippy/tests/ui/single_call_fn.stderr +++ b/src/tools/clippy/tests/ui/single_call_fn.stderr @@ -14,6 +14,7 @@ help: used here LL | c(); | ^ = note: `-D clippy::single-call-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_call_fn)]` error: this function is only used once --> $DIR/single_call_fn.rs:12:1 diff --git a/src/tools/clippy/tests/ui/single_char_add_str.stderr b/src/tools/clippy/tests/ui/single_char_add_str.stderr index cea9ba7235dea..a6f2b3e037b4a 100644 --- a/src/tools/clippy/tests/ui/single_char_add_str.stderr +++ b/src/tools/clippy/tests/ui/single_char_add_str.stderr @@ -5,6 +5,7 @@ LL | string.push_str("R"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('R')` | = note: `-D clippy::single-char-add-str` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_char_add_str)]` error: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:15:5 diff --git a/src/tools/clippy/tests/ui/single_char_lifetime_names.stderr b/src/tools/clippy/tests/ui/single_char_lifetime_names.stderr index 19bea0ae0c23b..2cdfd61358e75 100644 --- a/src/tools/clippy/tests/ui/single_char_lifetime_names.stderr +++ b/src/tools/clippy/tests/ui/single_char_lifetime_names.stderr @@ -6,6 +6,7 @@ LL | struct DiagnosticCtx<'a, 'b> | = help: use a more informative name = note: `-D clippy::single-char-lifetime-names` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_char_lifetime_names)]` error: single-character lifetime names are likely uninformative --> $DIR/single_char_lifetime_names.rs:5:26 diff --git a/src/tools/clippy/tests/ui/single_char_pattern.stderr b/src/tools/clippy/tests/ui/single_char_pattern.stderr index f11ab12edee93..6e57ab3489f12 100644 --- a/src/tools/clippy/tests/ui/single_char_pattern.stderr +++ b/src/tools/clippy/tests/ui/single_char_pattern.stderr @@ -5,6 +5,7 @@ LL | x.split("x"); | ^^^ help: try using a `char` instead: `'x'` | = note: `-D clippy::single-char-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_char_pattern)]` error: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:13:13 diff --git a/src/tools/clippy/tests/ui/single_component_path_imports.stderr b/src/tools/clippy/tests/ui/single_component_path_imports.stderr index 0bff108f86ac4..440d34002d7ff 100644 --- a/src/tools/clippy/tests/ui/single_component_path_imports.stderr +++ b/src/tools/clippy/tests/ui/single_component_path_imports.stderr @@ -5,6 +5,7 @@ LL | use regex; | ^^^^^^^^^^ help: remove it entirely | = note: `-D clippy::single-component-path-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_component_path_imports)]` error: this import is redundant --> $DIR/single_component_path_imports.rs:32:5 diff --git a/src/tools/clippy/tests/ui/single_component_path_imports_nested_first.stderr b/src/tools/clippy/tests/ui/single_component_path_imports_nested_first.stderr index b2a0521f7d143..d65ab5620db77 100644 --- a/src/tools/clippy/tests/ui/single_component_path_imports_nested_first.stderr +++ b/src/tools/clippy/tests/ui/single_component_path_imports_nested_first.stderr @@ -5,6 +5,7 @@ LL | use regex; | ^^^^^^^^^^ help: remove it entirely | = note: `-D clippy::single-component-path-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_component_path_imports)]` error: this import is redundant --> $DIR/single_component_path_imports_nested_first.rs:17:10 diff --git a/src/tools/clippy/tests/ui/single_element_loop.stderr b/src/tools/clippy/tests/ui/single_element_loop.stderr index 1d89bf5538794..603dd7406e4e6 100644 --- a/src/tools/clippy/tests/ui/single_element_loop.stderr +++ b/src/tools/clippy/tests/ui/single_element_loop.stderr @@ -7,6 +7,7 @@ LL | | } | |_____^ | = note: `-D clippy::single-element-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_element_loop)]` help: try | LL ~ { diff --git a/src/tools/clippy/tests/ui/single_match.stderr b/src/tools/clippy/tests/ui/single_match.stderr index 76f7e78958985..d4b8659952139 100644 --- a/src/tools/clippy/tests/ui/single_match.stderr +++ b/src/tools/clippy/tests/ui/single_match.stderr @@ -10,6 +10,7 @@ LL | | }; | |_____^ | = note: `-D clippy::single-match` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_match)]` help: try | LL ~ if let Some(y) = x { diff --git a/src/tools/clippy/tests/ui/single_match_else.stderr b/src/tools/clippy/tests/ui/single_match_else.stderr index e85d51de6a103..3b4b1332c403a 100644 --- a/src/tools/clippy/tests/ui/single_match_else.stderr +++ b/src/tools/clippy/tests/ui/single_match_else.stderr @@ -12,6 +12,7 @@ LL | | }; | |_____^ | = note: `-D clippy::single-match-else` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_match_else)]` help: try | LL ~ let _ = if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { diff --git a/src/tools/clippy/tests/ui/single_range_in_vec_init.stderr b/src/tools/clippy/tests/ui/single_range_in_vec_init.stderr index 1b347f4ae97f9..e83e49af676cc 100644 --- a/src/tools/clippy/tests/ui/single_range_in_vec_init.stderr +++ b/src/tools/clippy/tests/ui/single_range_in_vec_init.stderr @@ -5,6 +5,7 @@ LL | [0..200]; | ^^^^^^^^ | = note: `-D clippy::single-range-in-vec-init` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::single_range_in_vec_init)]` help: if you wanted a `Vec` that contains the entire range, try | LL | (0..200).collect::>(); diff --git a/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr b/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr index 0c31c3a1f4b32..47f9632b8d123 100644 --- a/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr +++ b/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr @@ -6,6 +6,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::( | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type = note: `-D clippy::size-of-in-element-count` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` --> $DIR/expressions.rs:19:62 diff --git a/src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr b/src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr index 4901d11736d5e..aba4c800e44df 100644 --- a/src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr +++ b/src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr @@ -6,6 +6,7 @@ LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of: | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type = note: `-D clippy::size-of-in-element-count` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:20:62 diff --git a/src/tools/clippy/tests/ui/size_of_ref.stderr b/src/tools/clippy/tests/ui/size_of_ref.stderr index c7a1758825cba..e239c5810c92e 100644 --- a/src/tools/clippy/tests/ui/size_of_ref.stderr +++ b/src/tools/clippy/tests/ui/size_of_ref.stderr @@ -6,6 +6,7 @@ LL | size_of_val(&&x); | = help: dereference the argument to `std::mem::size_of_val()` to get the size of the value instead of the size of the reference-type = note: `-D clippy::size-of-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::size_of_ref)]` error: argument to `std::mem::size_of_val()` is a reference to a reference --> $DIR/size_of_ref.rs:15:5 diff --git a/src/tools/clippy/tests/ui/skip_while_next.stderr b/src/tools/clippy/tests/ui/skip_while_next.stderr index 7308ab4e55c9c..3c33af3a16080 100644 --- a/src/tools/clippy/tests/ui/skip_while_next.stderr +++ b/src/tools/clippy/tests/ui/skip_while_next.stderr @@ -6,6 +6,7 @@ LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); | = help: this is more succinctly expressed by calling `.find(!

)` instead = note: `-D clippy::skip-while-next` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::skip_while_next)]` error: called `skip_while(

).next()` on an `Iterator` --> $DIR/skip_while_next.rs:17:13 diff --git a/src/tools/clippy/tests/ui/slow_vector_initialization.stderr b/src/tools/clippy/tests/ui/slow_vector_initialization.stderr index 4800e6e441862..f4501551656a2 100644 --- a/src/tools/clippy/tests/ui/slow_vector_initialization.stderr +++ b/src/tools/clippy/tests/ui/slow_vector_initialization.stderr @@ -7,6 +7,7 @@ LL | vec1.extend(repeat(0).take(len)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::slow-vector-initialization` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::slow_vector_initialization)]` error: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:20:5 @@ -103,6 +104,7 @@ LL | fn do_stuff(vec: &mut [u8]) {} | ^^^^^^^^^ help: consider changing to: `&[u8]` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` error: aborting due to 13 previous errors diff --git a/src/tools/clippy/tests/ui/stable_sort_primitive.stderr b/src/tools/clippy/tests/ui/stable_sort_primitive.stderr index 1432fdcff77ad..b665033283348 100644 --- a/src/tools/clippy/tests/ui/stable_sort_primitive.stderr +++ b/src/tools/clippy/tests/ui/stable_sort_primitive.stderr @@ -6,6 +6,7 @@ LL | vec.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type = note: `-D clippy::stable-sort-primitive` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::stable_sort_primitive)]` error: used `sort` on primitive type `bool` --> $DIR/stable_sort_primitive.rs:9:5 diff --git a/src/tools/clippy/tests/ui/starts_ends_with.stderr b/src/tools/clippy/tests/ui/starts_ends_with.stderr index 48d561bc4b8ec..c4c547949a364 100644 --- a/src/tools/clippy/tests/ui/starts_ends_with.stderr +++ b/src/tools/clippy/tests/ui/starts_ends_with.stderr @@ -5,6 +5,7 @@ LL | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` | = note: `-D clippy::chars-next-cmp` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::chars_next_cmp)]` error: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:8:5 @@ -37,6 +38,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::chars_last_cmp)]` error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:25:8 diff --git a/src/tools/clippy/tests/ui/std_instead_of_core.stderr b/src/tools/clippy/tests/ui/std_instead_of_core.stderr index f2db81e51633a..7435d716157ae 100644 --- a/src/tools/clippy/tests/ui/std_instead_of_core.stderr +++ b/src/tools/clippy/tests/ui/std_instead_of_core.stderr @@ -6,6 +6,7 @@ LL | use std::hash::Hasher; | = help: consider importing the item from `core` = note: `-D clippy::std-instead-of-core` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_core)]` error: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:12:9 @@ -79,6 +80,7 @@ LL | use std::vec; | = help: consider importing the item from `alloc` = note: `-D clippy::std-instead-of-alloc` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]` error: used import from `std` instead of `alloc` --> $DIR/std_instead_of_core.rs:49:9 @@ -96,6 +98,7 @@ LL | use alloc::slice::from_ref; | = help: consider importing the item from `core` = note: `-D clippy::alloc-instead-of-core` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]` error: aborting due to 12 previous errors diff --git a/src/tools/clippy/tests/ui/str_to_string.stderr b/src/tools/clippy/tests/ui/str_to_string.stderr index 25af1d376638f..203805eca5a64 100644 --- a/src/tools/clippy/tests/ui/str_to_string.stderr +++ b/src/tools/clippy/tests/ui/str_to_string.stderr @@ -6,6 +6,7 @@ LL | let hello = "hello world".to_string(); | = help: consider using `.to_owned()` = note: `-D clippy::str-to-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::str_to_string)]` error: `to_string()` called on a `&str` --> $DIR/str_to_string.rs:7:5 diff --git a/src/tools/clippy/tests/ui/string_add.stderr b/src/tools/clippy/tests/ui/string_add.stderr index 3987641c75a30..892753b9034e9 100644 --- a/src/tools/clippy/tests/ui/string_add.stderr +++ b/src/tools/clippy/tests/ui/string_add.stderr @@ -5,6 +5,7 @@ LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/string_add.rs:13:13 @@ -13,6 +14,7 @@ LL | x = x + "."; | ^^^^^^^ | = note: `-D clippy::string-add` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_add)]` error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/string_add.rs:17:13 diff --git a/src/tools/clippy/tests/ui/string_add_assign.stderr b/src/tools/clippy/tests/ui/string_add_assign.stderr index d4b995519e379..7d37c98a8f930 100644 --- a/src/tools/clippy/tests/ui/string_add_assign.stderr +++ b/src/tools/clippy/tests/ui/string_add_assign.stderr @@ -5,6 +5,7 @@ LL | x = x + "."; | ^^^^^^^^^^^ | = note: `-D clippy::string-add-assign` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_add_assign)]` error: manual implementation of an assign operation --> $DIR/string_add_assign.rs:8:9 @@ -13,6 +14,7 @@ LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: manual implementation of an assign operation --> $DIR/string_add_assign.rs:17:5 diff --git a/src/tools/clippy/tests/ui/string_extend.stderr b/src/tools/clippy/tests/ui/string_extend.stderr index 49ff4516db1b6..e063d87e37d3e 100644 --- a/src/tools/clippy/tests/ui/string_extend.stderr +++ b/src/tools/clippy/tests/ui/string_extend.stderr @@ -5,6 +5,7 @@ LL | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(abc)` | = note: `-D clippy::string-extend-chars` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_extend_chars)]` error: calling `.extend(_.chars())` --> $DIR/string_extend.rs:19:5 diff --git a/src/tools/clippy/tests/ui/string_from_utf8_as_bytes.stderr b/src/tools/clippy/tests/ui/string_from_utf8_as_bytes.stderr index 0fa4d59068f8e..cf5688a978241 100644 --- a/src/tools/clippy/tests/ui/string_from_utf8_as_bytes.stderr +++ b/src/tools/clippy/tests/ui/string_from_utf8_as_bytes.stderr @@ -5,6 +5,7 @@ LL | let _ = std::str::from_utf8(&"Hello World!".as_bytes()[6..11]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(&"Hello World!"[6..11])` | = note: `-D clippy::string-from-utf8-as-bytes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_from_utf8_as_bytes)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr b/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr index 73576f9f30000..1c12cb8e56d28 100644 --- a/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr +++ b/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::string_lit_as_bytes)]` error: calling `as_bytes()` on a string literal --> $DIR/string_lit_as_bytes.rs:18:14 diff --git a/src/tools/clippy/tests/ui/string_lit_chars_any.stderr b/src/tools/clippy/tests/ui/string_lit_chars_any.stderr index dac9a90b34181..09c4f02eb062c 100644 --- a/src/tools/clippy/tests/ui/string_lit_chars_any.stderr +++ b/src/tools/clippy/tests/ui/string_lit_chars_any.stderr @@ -5,6 +5,7 @@ LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::string-lit-chars-any` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_lit_chars_any)]` help: use `matches!(...)` instead | LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' | '&' | '-' | '~'); diff --git a/src/tools/clippy/tests/ui/string_slice.stderr b/src/tools/clippy/tests/ui/string_slice.stderr index 94dad58cd972e..e9e773aaf3ae3 100644 --- a/src/tools/clippy/tests/ui/string_slice.stderr +++ b/src/tools/clippy/tests/ui/string_slice.stderr @@ -5,6 +5,7 @@ LL | &"Ölkanne"[1..]; | ^^^^^^^^^^^^^^ | = note: `-D clippy::string-slice` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_slice)]` error: indexing into a string may panic if the index is within a UTF-8 character --> $DIR/string_slice.rs:9:6 diff --git a/src/tools/clippy/tests/ui/string_to_string.stderr b/src/tools/clippy/tests/ui/string_to_string.stderr index e304c3e346db1..27a84431507b2 100644 --- a/src/tools/clippy/tests/ui/string_to_string.stderr +++ b/src/tools/clippy/tests/ui/string_to_string.stderr @@ -6,6 +6,7 @@ LL | let mut v = message.to_string(); | = help: consider using `.clone()` = note: `-D clippy::string-to-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::string_to_string)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/strlen_on_c_strings.stderr b/src/tools/clippy/tests/ui/strlen_on_c_strings.stderr index 81881fbe3bd39..6d8ad3981c04b 100644 --- a/src/tools/clippy/tests/ui/strlen_on_c_strings.stderr +++ b/src/tools/clippy/tests/ui/strlen_on_c_strings.stderr @@ -5,6 +5,7 @@ LL | let _ = unsafe { libc::strlen(cstring.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstring.as_bytes().len()` | = note: `-D clippy::strlen-on-c-strings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::strlen_on_c_strings)]` error: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:17:13 diff --git a/src/tools/clippy/tests/ui/struct_excessive_bools.stderr b/src/tools/clippy/tests/ui/struct_excessive_bools.stderr index 05b2363eb5680..5284949c2d2aa 100644 --- a/src/tools/clippy/tests/ui/struct_excessive_bools.stderr +++ b/src/tools/clippy/tests/ui/struct_excessive_bools.stderr @@ -12,6 +12,7 @@ LL | | } | = help: consider using a state machine or refactoring bools into two-variant enums = note: `-D clippy::struct-excessive-bools` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::struct_excessive_bools)]` error: more than 3 bools in a struct --> $DIR/struct_excessive_bools.rs:39:5 diff --git a/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr b/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr index 4a4be0712b289..3995c6eb5c4ee 100644 --- a/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr +++ b/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr @@ -5,6 +5,7 @@ LL | Foo(self.0 - other.0) | ^ | = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_arithmetic_impl)]` error: suspicious use of `-` in `AddAssign` impl --> $DIR/suspicious_arithmetic_impl.rs:21:23 @@ -13,6 +14,7 @@ LL | *self = *self - other; | ^ | = note: `-D clippy::suspicious-op-assign-impl` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_op_assign_impl)]` error: suspicious use of `/` in `MulAssign` impl --> $DIR/suspicious_arithmetic_impl.rs:36:16 diff --git a/src/tools/clippy/tests/ui/suspicious_command_arg_space.stderr b/src/tools/clippy/tests/ui/suspicious_command_arg_space.stderr index 0ed4eb20ecb5b..9bf3128cb8e26 100644 --- a/src/tools/clippy/tests/ui/suspicious_command_arg_space.stderr +++ b/src/tools/clippy/tests/ui/suspicious_command_arg_space.stderr @@ -5,6 +5,7 @@ LL | std::process::Command::new("echo").arg("-n hello").spawn().unwrap(); | ^^^^^^^^^^ | = note: `-D clippy::suspicious-command-arg-space` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_command_arg_space)]` help: consider splitting the argument | LL | std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap(); diff --git a/src/tools/clippy/tests/ui/suspicious_doc_comments.stderr b/src/tools/clippy/tests/ui/suspicious_doc_comments.stderr index 8d2a2bdf6e99d..1b238f501e13a 100644 --- a/src/tools/clippy/tests/ui/suspicious_doc_comments.stderr +++ b/src/tools/clippy/tests/ui/suspicious_doc_comments.stderr @@ -5,6 +5,7 @@ LL | ///! Fake module documentation. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::suspicious-doc-comments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_doc_comments)]` help: use an inner doc comment to document the parent module or crate | LL | //! Fake module documentation. diff --git a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr index 3a93c289fc702..ae92c334f6092 100644 --- a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr +++ b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr @@ -10,6 +10,7 @@ LL | | ///! d | |______^ | = note: `-D clippy::suspicious-doc-comments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_doc_comments)]` help: use an inner doc comment to document the parent module or crate | LL + //! a diff --git a/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr b/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr index 723fdd7e93e3b..95047cb95ee13 100644 --- a/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr +++ b/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr @@ -6,6 +6,7 @@ LL | } { | = note: to remove this lint, add the missing `else` or add a new line before the next block = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_else_formatting)]` error: this looks like an `else if` but the `else` is missing --> $DIR/suspicious_else_formatting.rs:26:6 diff --git a/src/tools/clippy/tests/ui/suspicious_map.stderr b/src/tools/clippy/tests/ui/suspicious_map.stderr index 154083f99fa29..9c065e05ca6f6 100644 --- a/src/tools/clippy/tests/ui/suspicious_map.stderr +++ b/src/tools/clippy/tests/ui/suspicious_map.stderr @@ -6,6 +6,7 @@ LL | let _ = (0..3).map(|x| x + 2).count(); | = help: make sure you did not confuse `map` with `filter`, `for_each` or `inspect` = note: `-D clippy::suspicious-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_map)]` error: this call to `map()` won't have an effect on the call to `count()` --> $DIR/suspicious_map.rs:8:13 diff --git a/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr b/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr index baf9bc74b000e..0784da06e5f58 100644 --- a/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr +++ b/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr @@ -5,6 +5,7 @@ LL | self.x == other.y && self.y == other.y && self.z == other.z | ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x` | = note: `-D clippy::suspicious-operation-groupings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_operation_groupings)]` error: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:28:20 diff --git a/src/tools/clippy/tests/ui/suspicious_splitn.stderr b/src/tools/clippy/tests/ui/suspicious_splitn.stderr index 2bdf1043abb73..4513beac8b2de 100644 --- a/src/tools/clippy/tests/ui/suspicious_splitn.stderr +++ b/src/tools/clippy/tests/ui/suspicious_splitn.stderr @@ -6,6 +6,7 @@ LL | let _ = "a,b".splitn(0, ','); | = note: the resulting iterator will always return `None` = note: `-D clippy::suspicious-splitn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_splitn)]` error: `rsplitn` called with `0` splits --> $DIR/suspicious_splitn.rs:13:13 diff --git a/src/tools/clippy/tests/ui/suspicious_to_owned.stderr b/src/tools/clippy/tests/ui/suspicious_to_owned.stderr index cbda1649c629f..eb967a714d949 100644 --- a/src/tools/clippy/tests/ui/suspicious_to_owned.stderr +++ b/src/tools/clippy/tests/ui/suspicious_to_owned.stderr @@ -5,6 +5,7 @@ LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ | = note: `-D clippy::suspicious-to-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_to_owned)]` help: depending on intent, either make the Cow an Owned variant | LL | let _ = cow.into_owned(); @@ -66,6 +67,7 @@ LL | let _ = String::from(moo).to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::from(moo).clone()` | = note: `-D clippy::implicit-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implicit_clone)]` error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type --> $DIR/suspicious_to_owned.rs:69:13 diff --git a/src/tools/clippy/tests/ui/suspicious_unary_op_formatting.stderr b/src/tools/clippy/tests/ui/suspicious_unary_op_formatting.stderr index c44a43ea1ec28..3cddde4eca7b9 100644 --- a/src/tools/clippy/tests/ui/suspicious_unary_op_formatting.stderr +++ b/src/tools/clippy/tests/ui/suspicious_unary_op_formatting.stderr @@ -6,6 +6,7 @@ LL | if a >- 30 {} | = help: put a space between `>` and `-` and remove the space after `-` = note: `-D clippy::suspicious-unary-op-formatting` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_unary_op_formatting)]` error: by not having a space between `>=` and `-` it looks like `>=-` is a single operator --> $DIR/suspicious_unary_op_formatting.rs:11:9 diff --git a/src/tools/clippy/tests/ui/suspicious_xor_used_as_pow.stderr b/src/tools/clippy/tests/ui/suspicious_xor_used_as_pow.stderr index 1a260e64e77a3..29e9fa771019e 100644 --- a/src/tools/clippy/tests/ui/suspicious_xor_used_as_pow.stderr +++ b/src/tools/clippy/tests/ui/suspicious_xor_used_as_pow.stderr @@ -5,6 +5,7 @@ LL | let _ = 2 ^ 5; | ^^^^^ help: did you mean to write: `2.pow(5)` | = note: `-D clippy::suspicious-xor-used-as-pow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::suspicious_xor_used_as_pow)]` error: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:22:13 diff --git a/src/tools/clippy/tests/ui/swap.stderr b/src/tools/clippy/tests/ui/swap.stderr index a3b9c2b744c98..e69ad02b08fe1 100644 --- a/src/tools/clippy/tests/ui/swap.stderr +++ b/src/tools/clippy/tests/ui/swap.stderr @@ -8,6 +8,7 @@ LL | | bar.b = temp; | = note: or maybe you should use `std::mem::replace`? = note: `-D clippy::manual-swap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_swap)]` error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:40:5 @@ -108,6 +109,7 @@ LL | | b = a; | = note: or maybe you should use `std::mem::replace`? = note: `-D clippy::almost-swapped` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::almost_swapped)]` error: this looks like you are trying to swap `c.0` and `a` --> $DIR/swap.rs:144:5 diff --git a/src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr b/src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr index a0f5160ee207b..42455f4926e89 100644 --- a/src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr +++ b/src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr @@ -5,6 +5,7 @@ LL | core::mem::swap(&mut *y, &mut *z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, z)` | = note: `-D clippy::swap-ptr-to-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::swap_ptr_to_ref)]` error: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref.rs:12:9 diff --git a/src/tools/clippy/tests/ui/swap_ptr_to_ref_unfixable.stderr b/src/tools/clippy/tests/ui/swap_ptr_to_ref_unfixable.stderr index f0c1e7e7428bf..ce1d7814250a7 100644 --- a/src/tools/clippy/tests/ui/swap_ptr_to_ref_unfixable.stderr +++ b/src/tools/clippy/tests/ui/swap_ptr_to_ref_unfixable.stderr @@ -5,6 +5,7 @@ LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::swap-ptr-to-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::swap_ptr_to_ref)]` error: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref_unfixable.rs:17:9 diff --git a/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr b/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr index 9da05fbec682a..69ce214ae565b 100644 --- a/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr +++ b/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr @@ -5,6 +5,7 @@ LL | /// - First String: | ^^^^ help: consider using four spaces per tab | = note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]` error: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:11:9 diff --git a/src/tools/clippy/tests/ui/temporary_assignment.stderr b/src/tools/clippy/tests/ui/temporary_assignment.stderr index 241abc2c5c7cb..cbb8924187c44 100644 --- a/src/tools/clippy/tests/ui/temporary_assignment.stderr +++ b/src/tools/clippy/tests/ui/temporary_assignment.stderr @@ -5,6 +5,7 @@ LL | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::temporary-assignment` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::temporary_assignment)]` error: assignment to temporary --> $DIR/temporary_assignment.rs:51:5 diff --git a/src/tools/clippy/tests/ui/tests_outside_test_module.stderr b/src/tools/clippy/tests/ui/tests_outside_test_module.stderr index 71c649c5d2706..112d6ce1f2c46 100644 --- a/src/tools/clippy/tests/ui/tests_outside_test_module.stderr +++ b/src/tools/clippy/tests/ui/tests_outside_test_module.stderr @@ -6,6 +6,7 @@ LL | fn my_test() {} | = note: move it to a testing module marked with #[cfg(test)] = note: `-D clippy::tests-outside-test-module` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::tests_outside_test_module)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/to_digit_is_some.stderr b/src/tools/clippy/tests/ui/to_digit_is_some.stderr index 9ece2fce664e4..5067ad7fb6dff 100644 --- a/src/tools/clippy/tests/ui/to_digit_is_some.stderr +++ b/src/tools/clippy/tests/ui/to_digit_is_some.stderr @@ -5,6 +5,7 @@ LL | let _ = d.to_digit(8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d.is_digit(8)` | = note: `-D clippy::to-digit-is-some` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::to_digit_is_some)]` error: use of `.to_digit(..).is_some()` --> $DIR/to_digit_is_some.rs:8:13 diff --git a/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr b/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr index 84017669f4750..2c27a3c8e9189 100644 --- a/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr +++ b/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr @@ -5,6 +5,7 @@ LL | let ref _x = 1; | ----^^^^^^----- help: try: `let _x = &1;` | = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::toplevel_ref_arg)]` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:16:9 diff --git a/src/tools/clippy/tests/ui/toplevel_ref_arg_non_rustfix.stderr b/src/tools/clippy/tests/ui/toplevel_ref_arg_non_rustfix.stderr index 7307bd599d9ba..45123dd5ec0bd 100644 --- a/src/tools/clippy/tests/ui/toplevel_ref_arg_non_rustfix.stderr +++ b/src/tools/clippy/tests/ui/toplevel_ref_arg_non_rustfix.stderr @@ -5,6 +5,7 @@ LL | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::toplevel_ref_arg)]` error: `ref` directly on a function argument is ignored. Consider using a reference type instead --> $DIR/toplevel_ref_arg_non_rustfix.rs:20:24 diff --git a/src/tools/clippy/tests/ui/trailing_empty_array.stderr b/src/tools/clippy/tests/ui/trailing_empty_array.stderr index d89e77f61ce4a..ef7fc24c374fa 100644 --- a/src/tools/clippy/tests/ui/trailing_empty_array.stderr +++ b/src/tools/clippy/tests/ui/trailing_empty_array.stderr @@ -10,6 +10,7 @@ LL | | } | = help: consider annotating `RarelyUseful` with `#[repr(C)]` or another `repr` attribute = note: `-D clippy::trailing-empty-array` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::trailing_empty_array)]` error: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:11:1 diff --git a/src/tools/clippy/tests/ui/trailing_zeros.stderr b/src/tools/clippy/tests/ui/trailing_zeros.stderr index fb4025a75481d..10924ad124712 100644 --- a/src/tools/clippy/tests/ui/trailing_zeros.stderr +++ b/src/tools/clippy/tests/ui/trailing_zeros.stderr @@ -5,6 +5,7 @@ LL | let _ = (x & 0b1111 == 0); | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::verbose_bit_mask)]` error: bit mask could be simplified with a call to `trailing_zeros` --> $DIR/trailing_zeros.rs:9:13 diff --git a/src/tools/clippy/tests/ui/transmute.stderr b/src/tools/clippy/tests/ui/transmute.stderr index 2765f763d6df7..cdc733b54a9b2 100644 --- a/src/tools/clippy/tests/ui/transmute.stderr +++ b/src/tools/clippy/tests/ui/transmute.stderr @@ -5,6 +5,7 @@ LL | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` | = note: `-D clippy::useless-transmute` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]` error: transmute from a reference to a pointer --> $DIR/transmute.rs:28:21 @@ -67,6 +68,7 @@ LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::crosspointer_transmute)]` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) --> $DIR/transmute.rs:94:24 @@ -93,6 +95,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` --> $DIR/transmute.rs:110:28 @@ -107,6 +110,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]` error: transmute from a `u32` to a `f32` --> $DIR/transmute.rs:128:31 @@ -115,6 +119,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]` error: transmute from a `i32` to a `f32` --> $DIR/transmute.rs:131:31 @@ -141,6 +146,7 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` | = note: `-D clippy::transmute-num-to-bytes` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]` error: transmute from a `u32` to a `[u8; 4]` --> $DIR/transmute.rs:159:30 @@ -227,6 +233,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]` error: transmute from a `&mut [u8]` to a `&mut str` --> $DIR/transmute.rs:201:32 diff --git a/src/tools/clippy/tests/ui/transmute_64bit.stderr b/src/tools/clippy/tests/ui/transmute_64bit.stderr index 32d7e6bdf421a..a30480eb7df0a 100644 --- a/src/tools/clippy/tests/ui/transmute_64bit.stderr +++ b/src/tools/clippy/tests/ui/transmute_64bit.stderr @@ -5,6 +5,7 @@ LL | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::wrong-transmute` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wrong_transmute)]` error: transmute from a `f64` to a pointer --> $DIR/transmute_64bit.rs:10:29 diff --git a/src/tools/clippy/tests/ui/transmute_collection.stderr b/src/tools/clippy/tests/ui/transmute_collection.stderr index e4b9963be89b3..2163142eef2e8 100644 --- a/src/tools/clippy/tests/ui/transmute_collection.stderr +++ b/src/tools/clippy/tests/ui/transmute_collection.stderr @@ -5,6 +5,7 @@ LL | let _ = transmute::<_, Vec>(vec![0u8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unsound-collection-transmute` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unsound_collection_transmute)]` error: transmute from `std::vec::Vec` to `std::vec::Vec<[u8; 4]>` with mismatched layout is unsound --> $DIR/transmute_collection.rs:13:17 diff --git a/src/tools/clippy/tests/ui/transmute_float_to_int.stderr b/src/tools/clippy/tests/ui/transmute_float_to_int.stderr index dd21c0cde2c42..1895120c0c99c 100644 --- a/src/tools/clippy/tests/ui/transmute_float_to_int.stderr +++ b/src/tools/clippy/tests/ui/transmute_float_to_int.stderr @@ -5,6 +5,7 @@ LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits()` | = note: `-D clippy::transmute-float-to-int` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_float_to_int)]` error: transmute from a `f32` to a `i32` --> $DIR/transmute_float_to_int.rs:7:27 diff --git a/src/tools/clippy/tests/ui/transmute_int_to_non_zero.stderr b/src/tools/clippy/tests/ui/transmute_int_to_non_zero.stderr index 9efba88f38f6b..b79a80c326d8d 100644 --- a/src/tools/clippy/tests/ui/transmute_int_to_non_zero.stderr +++ b/src/tools/clippy/tests/ui/transmute_int_to_non_zero.stderr @@ -5,6 +5,7 @@ LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU8::new_unchecked(int_u8)` | = note: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_non_zero)]` error: transmute from a `u16` to a `NonZeroU16` --> $DIR/transmute_int_to_non_zero.rs:21:34 diff --git a/src/tools/clippy/tests/ui/transmute_null_to_fn.stderr b/src/tools/clippy/tests/ui/transmute_null_to_fn.stderr index 6278f51dde25d..ab0ac0dd480bc 100644 --- a/src/tools/clippy/tests/ui/transmute_null_to_fn.stderr +++ b/src/tools/clippy/tests/ui/transmute_null_to_fn.stderr @@ -6,6 +6,7 @@ LL | let _: fn() = std::mem::transmute(0 as *const ()); | = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value = note: `-D clippy::transmute-null-to-fn` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_null_to_fn)]` error: transmuting a known null pointer into a function pointer --> $DIR/transmute_null_to_fn.rs:10:23 diff --git a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr index ee414e46bb748..564339c067ee1 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ptr)]` error: transmute from a pointer to a pointer --> $DIR/transmute_ptr_to_ptr.rs:33:27 diff --git a/src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr b/src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr index c63b5524edb49..9d1b22a795b3d 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr @@ -5,6 +5,7 @@ LL | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` | = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ref)]` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute_ptr_to_ref.rs:8:21 diff --git a/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr b/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr index 3618213ecd505..f87b1ece96472 100644 --- a/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr +++ b/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr @@ -5,6 +5,7 @@ LL | let _: Ty2C = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::transmute-undefined-repr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_undefined_repr)]` error: transmute into `Ty2` which has an undefined layout --> $DIR/transmute_undefined_repr.rs:33:32 diff --git a/src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.stderr b/src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.stderr index 846b982cdeaca..a7988dc4b39b2 100644 --- a/src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.stderr +++ b/src/tools/clippy/tests/ui/transmutes_expressible_as_ptr_casts.stderr @@ -5,6 +5,7 @@ LL | let _ptr_i32_transmute = unsafe { transmute::(usize: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32` | = note: `-D clippy::useless-transmute` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]` error: transmute from a pointer to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:21:38 @@ -13,6 +14,7 @@ LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as *const i8` | = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ptr)]` error: transmute from a pointer to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:27:46 @@ -27,6 +29,7 @@ LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, us | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as usize` | = note: `-D clippy::transmutes-expressible-as-ptr-casts` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmutes_expressible_as_ptr_casts)]` error: transmute from a reference to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:39:41 diff --git a/src/tools/clippy/tests/ui/transmuting_null.stderr b/src/tools/clippy/tests/ui/transmuting_null.stderr index a8de01ec15dc4..402de38fe9e2f 100644 --- a/src/tools/clippy/tests/ui/transmuting_null.stderr +++ b/src/tools/clippy/tests/ui/transmuting_null.stderr @@ -5,6 +5,7 @@ LL | let _: &u64 = std::mem::transmute(0 as *const u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::transmuting-null` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::transmuting_null)]` error: transmuting a known null pointer into a reference --> $DIR/transmuting_null.rs:13:23 diff --git a/src/tools/clippy/tests/ui/trim_split_whitespace.stderr b/src/tools/clippy/tests/ui/trim_split_whitespace.stderr index 0379d79ae986e..a1c66eea0d14c 100644 --- a/src/tools/clippy/tests/ui/trim_split_whitespace.stderr +++ b/src/tools/clippy/tests/ui/trim_split_whitespace.stderr @@ -5,6 +5,7 @@ LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` | = note: `-D clippy::trim-split-whitespace` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::trim_split_whitespace)]` error: found call to `str::trim_start` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:62:23 diff --git a/src/tools/clippy/tests/ui/tuple_array_conversions.stderr b/src/tools/clippy/tests/ui/tuple_array_conversions.stderr index 70c13d10fd875..f8f5b3e75871d 100644 --- a/src/tools/clippy/tests/ui/tuple_array_conversions.stderr +++ b/src/tools/clippy/tests/ui/tuple_array_conversions.stderr @@ -6,6 +6,7 @@ LL | let x = (x[0], x[1]); | = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed = note: `-D clippy::tuple-array-conversions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::tuple_array_conversions)]` error: it looks like you're trying to convert a tuple to an array --> $DIR/tuple_array_conversions.rs:11:13 diff --git a/src/tools/clippy/tests/ui/type_complexity.stderr b/src/tools/clippy/tests/ui/type_complexity.stderr index 496dacfbfde61..a3cf6ffe97516 100644 --- a/src/tools/clippy/tests/ui/type_complexity.stderr +++ b/src/tools/clippy/tests/ui/type_complexity.stderr @@ -5,6 +5,7 @@ LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::type-complexity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::type_complexity)]` error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:10:12 diff --git a/src/tools/clippy/tests/ui/type_id_on_box.stderr b/src/tools/clippy/tests/ui/type_id_on_box.stderr index 442f2c6b84770..844dae158b8d8 100644 --- a/src/tools/clippy/tests/ui/type_id_on_box.stderr +++ b/src/tools/clippy/tests/ui/type_id_on_box.stderr @@ -9,6 +9,7 @@ LL | let _ = any_box.type_id(); = note: this returns the type id of the literal type `Box` instead of the type id of the boxed value, which is most likely not what you want = note: if this is intentional, use `TypeId::of::>()` instead, which makes it more clear = note: `-D clippy::type-id-on-box` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::type_id_on_box)]` error: calling `.type_id()` on a `Box` --> $DIR/type_id_on_box.rs:28:13 diff --git a/src/tools/clippy/tests/ui/types.stderr b/src/tools/clippy/tests/ui/types.stderr index 0d489f625204f..b253cf33867f7 100644 --- a/src/tools/clippy/tests/ui/types.stderr +++ b/src/tools/clippy/tests/ui/types.stderr @@ -5,6 +5,7 @@ LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr b/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr index fa47f6ee80622..2b62bc9640392 100644 --- a/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr +++ b/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr @@ -5,6 +5,7 @@ LL | let _ = _first - second; | ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap()` | = note: `-D clippy::unchecked-duration-subtraction` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unchecked_duration_subtraction)]` error: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:11:13 diff --git a/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.stderr b/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.stderr index ee1d3aa285a28..77f6aea2e0d07 100644 --- a/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.stderr +++ b/src/tools/clippy/tests/ui/undocumented_unsafe_blocks.stderr @@ -6,6 +6,7 @@ LL | /* Safety: */ unsafe {} | = help: consider adding a safety comment on the preceding line = note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]` error: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:266:5 @@ -251,6 +252,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ = note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:472:5 diff --git a/src/tools/clippy/tests/ui/unicode.stderr b/src/tools/clippy/tests/ui/unicode.stderr index 4f3bad6c03296..0b6e20664e34c 100644 --- a/src/tools/clippy/tests/ui/unicode.stderr +++ b/src/tools/clippy/tests/ui/unicode.stderr @@ -5,6 +5,7 @@ LL | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{200B}< is a ZWS, and \u{200B}another"` | = note: `-D clippy::invisible-characters` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::invisible_characters)]` error: invisible character detected --> $DIR/unicode.rs:7:12 @@ -25,6 +26,7 @@ LL | print!("̀àh?"); | ^^^^^ help: consider replacing the string with: `"̀àh?"` | = note: `-D clippy::unicode-not-nfc` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unicode_not_nfc)]` error: literal non-ASCII character detected --> $DIR/unicode.rs:23:16 diff --git a/src/tools/clippy/tests/ui/uninit_vec.stderr b/src/tools/clippy/tests/ui/uninit_vec.stderr index 1ffea9f8730de..d39f05839ed90 100644 --- a/src/tools/clippy/tests/ui/uninit_vec.stderr +++ b/src/tools/clippy/tests/ui/uninit_vec.stderr @@ -9,6 +9,7 @@ LL | vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` = note: `-D clippy::uninit-vec` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::uninit_vec)]` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:24:5 diff --git a/src/tools/clippy/tests/ui/uninlined_format_args.stderr b/src/tools/clippy/tests/ui/uninlined_format_args.stderr index c73c648738656..829d646b86692 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args.stderr +++ b/src/tools/clippy/tests/ui/uninlined_format_args.stderr @@ -5,6 +5,7 @@ LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::uninlined-format-args` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]` help: change this to | LL - println!("val='{}'", local_i32); diff --git a/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.stderr b/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.stderr index 55a3bd08b3192..221efeb50cd9b 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.stderr +++ b/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2018.stderr @@ -5,6 +5,7 @@ LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::uninlined-format-args` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]` help: change this to | LL - println!("val='{}'", var); diff --git a/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2021.stderr b/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2021.stderr index 00e7e8f0ff79a..ec1e3a1cf1178 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2021.stderr +++ b/src/tools/clippy/tests/ui/uninlined_format_args_panic.edition2021.stderr @@ -5,6 +5,7 @@ LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::uninlined-format-args` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]` help: change this to | LL - println!("val='{}'", var); diff --git a/src/tools/clippy/tests/ui/unit_arg.stderr b/src/tools/clippy/tests/ui/unit_arg.stderr index 1de9d44bb0d6e..8656c8fddabc3 100644 --- a/src/tools/clippy/tests/ui/unit_arg.stderr +++ b/src/tools/clippy/tests/ui/unit_arg.stderr @@ -7,6 +7,7 @@ LL | | }); | |______^ | = note: `-D clippy::unit-arg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unit_arg)]` help: remove the semicolon from the last statement in the block | LL | 1 diff --git a/src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr b/src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr index d35e931697d21..b207acb5927d5 100644 --- a/src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr +++ b/src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr @@ -7,6 +7,7 @@ LL | foo({}); | help: use a unit literal instead: `()` | = note: `-D clippy::unit-arg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unit_arg)]` error: passing a unit value to a function --> $DIR/unit_arg_empty_blocks.rs:17:5 diff --git a/src/tools/clippy/tests/ui/unit_cmp.stderr b/src/tools/clippy/tests/ui/unit_cmp.stderr index 38618c59180c1..17355e2379785 100644 --- a/src/tools/clippy/tests/ui/unit_cmp.stderr +++ b/src/tools/clippy/tests/ui/unit_cmp.stderr @@ -12,6 +12,7 @@ LL | | } {} | |_____^ | = note: `-D clippy::unit-cmp` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unit_cmp)]` error: >-comparison of unit values detected. This will always be false --> $DIR/unit_cmp.rs:25:8 diff --git a/src/tools/clippy/tests/ui/unit_hash.stderr b/src/tools/clippy/tests/ui/unit_hash.stderr index eeb48cf7f37fb..a26fd734413c1 100644 --- a/src/tools/clippy/tests/ui/unit_hash.stderr +++ b/src/tools/clippy/tests/ui/unit_hash.stderr @@ -6,6 +6,7 @@ LL | Foo::Empty => ().hash(&mut state), | = note: the implementation of `Hash` for `()` is a no-op = note: `-D clippy::unit-hash` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unit_hash)]` error: this call to `hash` on the unit type will do nothing --> $DIR/unit_hash.rs:26:5 diff --git a/src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr b/src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr index 74e6d6b126297..9220fb89e901e 100644 --- a/src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr +++ b/src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr @@ -10,6 +10,7 @@ help: probably caused by this trailing semicolon LL | double(s.field); | ^ = note: `-D clippy::unit-return-expecting-ord` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unit_return_expecting_ord)]` error: this closure returns the unit type which also implements PartialOrd --> $DIR/unit_return_expecting_ord.rs:24:30 diff --git a/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr b/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr index d478df8056b5e..ee82db31c2c2a 100644 --- a/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr +++ b/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr @@ -5,6 +5,7 @@ LL | #![allow(clippy::All)] | ^^^^^^^^^^^ help: did you mean: `clippy::all` | = note: `-D unknown-lints` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unknown_lints)]` error: unknown lint: `clippy::CMP_OWNED` --> $DIR/unknown_clippy_lints.rs:4:9 diff --git a/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr b/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr index 8909dbcdd9855..944e911fa944e 100644 --- a/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr @@ -6,6 +6,7 @@ LL | fn baz(&self) -> Box; | = help: changing this also requires a change to the return expressions in this function = note: `-D clippy::unnecessary-box-returns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_box_returns)]` error: boxed return of the sized type `usize` --> $DIR/unnecessary_box_returns.rs:19:22 diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.stderr b/src/tools/clippy/tests/ui/unnecessary_cast.stderr index 69bbcdf740717..d4786f66e4476 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_cast.stderr @@ -5,6 +5,7 @@ LL | ptr as *const T | ^^^^^^^^^^^^^^^ help: try: `ptr` | = note: `-D clippy::unnecessary-cast` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:53:5 diff --git a/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr b/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr index ef3632db9f1d4..2d38a2a7709ca 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr @@ -5,6 +5,7 @@ LL | let _ = std::ptr::null() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null()` | = note: `-D clippy::unnecessary-cast` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting raw pointers to the same type and constness is unnecessary (`*mut issue11113::Vtbl` -> `*mut issue11113::Vtbl`) --> $DIR/unnecessary_cast_unfixable.rs:21:16 diff --git a/src/tools/clippy/tests/ui/unnecessary_clone.stderr b/src/tools/clippy/tests/ui/unnecessary_clone.stderr index da387e8bb7c3c..eab5f04231656 100644 --- a/src/tools/clippy/tests/ui/unnecessary_clone.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_clone.stderr @@ -5,6 +5,7 @@ LL | rc.clone(); | ^^^^^^^^^^ help: try: `Rc::::clone(&rc)` | = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::clone_on_ref_ptr)]` error: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:28:5 @@ -37,6 +38,7 @@ LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::clone_on_copy)]` error: using `clone` on type `Option` which implements the `Copy` trait --> $DIR/unnecessary_clone.rs:50:5 diff --git a/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr b/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr index f34acdc8d7e62..0dd65f6527248 100644 --- a/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr @@ -5,6 +5,7 @@ LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_filter_map)]` error: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:7:13 diff --git a/src/tools/clippy/tests/ui/unnecessary_find_map.stderr b/src/tools/clippy/tests/ui/unnecessary_find_map.stderr index 9acbd6650024a..662623fb61790 100644 --- a/src/tools/clippy/tests/ui/unnecessary_find_map.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_find_map.stderr @@ -5,6 +5,7 @@ LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-find-map` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_find_map)]` error: this `.find_map` can be written more simply using `.find` --> $DIR/unnecessary_find_map.rs:7:13 diff --git a/src/tools/clippy/tests/ui/unnecessary_fold.stderr b/src/tools/clippy/tests/ui/unnecessary_fold.stderr index 10920470c1ade..f0d0396384214 100644 --- a/src/tools/clippy/tests/ui/unnecessary_fold.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_fold.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fold)]` error: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:8:20 diff --git a/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr b/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr index e9df5afa6b9f5..ba40c6c14db21 100644 --- a/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr @@ -5,6 +5,7 @@ LL | for (t, path) in files.iter().copied() { | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-to-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` help: use | LL | for (t, path) in files { diff --git a/src/tools/clippy/tests/ui/unnecessary_join.stderr b/src/tools/clippy/tests/ui/unnecessary_join.stderr index 80e5bc63a65e8..8bf2ac5fdb1d9 100644 --- a/src/tools/clippy/tests/ui/unnecessary_join.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_join.stderr @@ -7,6 +7,7 @@ LL | | .join(""); | |_________________^ help: try using: `collect::()` | = note: `-D clippy::unnecessary-join` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_join)]` error: called `.collect::>().join("")` on an iterator --> $DIR/unnecessary_join.rs:19:10 diff --git a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr index 2850a632fc774..4f1ca3748728f 100644 --- a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr @@ -7,6 +7,7 @@ LL | let _ = opt.unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` | = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_lazy_evaluations)]` error: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:69:13 diff --git a/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr b/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr index 8bff2a6377935..27fa560d4d77c 100644 --- a/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr @@ -7,6 +7,7 @@ LL | let _ = Ok(1).unwrap_or_else(|()| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` | = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_lazy_evaluations)]` error: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval_unfixable.rs:19:13 diff --git a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr index eae74f5695086..013907f59c46f 100644 --- a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr @@ -5,6 +5,7 @@ LL | let _val = Some(1).unwrap(); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-literal-unwrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_literal_unwrap)]` help: remove the `Some` and `unwrap()` | LL - let _val = Some(1).unwrap(); diff --git a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap_unfixable.stderr b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap_unfixable.stderr index 2a60896c0a3c7..c6ecd6de61ea1 100644 --- a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap_unfixable.stderr @@ -10,6 +10,7 @@ help: remove the `Some` and `unwrap()` LL | let val = Some(1); | ^^^^^^^ = note: `-D clippy::unnecessary-literal-unwrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_literal_unwrap)]` error: used `expect()` on `Some` value --> $DIR/unnecessary_literal_unwrap_unfixable.rs:9:17 diff --git a/src/tools/clippy/tests/ui/unnecessary_operation.stderr b/src/tools/clippy/tests/ui/unnecessary_operation.stderr index d71aa60d4cc1e..fbe495f518fab 100644 --- a/src/tools/clippy/tests/ui/unnecessary_operation.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_operation.stderr @@ -5,6 +5,7 @@ LL | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_operation)]` error: unnecessary operation --> $DIR/unnecessary_operation.rs:55:5 diff --git a/src/tools/clippy/tests/ui/unnecessary_owned_empty_strings.stderr b/src/tools/clippy/tests/ui/unnecessary_owned_empty_strings.stderr index 2cfed265adf88..58d925b1096d9 100644 --- a/src/tools/clippy/tests/ui/unnecessary_owned_empty_strings.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_owned_empty_strings.stderr @@ -5,6 +5,7 @@ LL | ref_str_argument(&String::new()); | ^^^^^^^^^^^^^^ help: try: `""` | = note: `-D clippy::unnecessary-owned-empty-strings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_owned_empty_strings)]` error: usage of `&String::from("")` for a function expecting a `&str` argument --> $DIR/unnecessary_owned_empty_strings.rs:14:22 diff --git a/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr b/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr index d97048e270367..6d4ef6c308db8 100644 --- a/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr @@ -10,6 +10,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ = note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]` error: static item has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:9:5 diff --git a/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr b/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr index 412674a85ec7a..4e50aaececf95 100644 --- a/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr @@ -8,6 +8,7 @@ LL | use std::fs::{self as alias}; | = note: this will slightly change semantics; any non-module items at the same path will also be imported = note: `-D clippy::unnecessary-self-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_self_imports)]` error: import ending with `::{self}` --> $DIR/unnecessary_self_imports.rs:7:1 diff --git a/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr b/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr index 55d681487b66f..9d54c8d50e31f 100644 --- a/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr @@ -5,6 +5,7 @@ LL | vec.sort_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()` | = note: `-D clippy::unnecessary-sort-by` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_sort_by)]` error: use Vec::sort here instead --> $DIR/unnecessary_sort_by.rs:13:5 diff --git a/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr b/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr index 5311415d166d2..d8e0ce6ccaf27 100644 --- a/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr @@ -5,6 +5,7 @@ LL | Self { ..*self } | ^^^^^^^^^^^^^^^^ help: replace with: `*self` | = note: `-D clippy::unnecessary-struct-initialization` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_struct_initialization)]` error: unnecessary struct building --> $DIR/unnecessary_struct_initialization.rs:39:17 diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr b/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr index b5d009ae1dd5d..d8971b51dcadd 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr @@ -10,6 +10,7 @@ note: this value is dropped without further use LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::redundant-clone` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone --> $DIR/unnecessary_to_owned.rs:149:40 @@ -66,6 +67,7 @@ LL | require_c_str(&Cow::from(c_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this | = note: `-D clippy::unnecessary-to-owned` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:58:19 diff --git a/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr b/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr index b0f20fdac5fa4..817eb3e26eed5 100644 --- a/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr @@ -5,6 +5,7 @@ LL | pub fn apocalypse(universe: &mut ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-safety-doc` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_doc)]` error: safe function's docs have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:45:5 diff --git a/src/tools/clippy/tests/ui/unnecessary_wraps.stderr b/src/tools/clippy/tests/ui/unnecessary_wraps.stderr index 01340a0abddf4..20d3e070e71c9 100644 --- a/src/tools/clippy/tests/ui/unnecessary_wraps.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_wraps.stderr @@ -11,6 +11,7 @@ LL | | } | |_^ | = note: `-D clippy::unnecessary-wraps` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_wraps)]` help: remove `Option` from the return type... | LL | fn func1(a: bool, b: bool) -> i32 { diff --git a/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr b/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr index 3f15684986fe0..68b433df8aaac 100644 --- a/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr +++ b/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr @@ -6,6 +6,7 @@ LL | Foo { a: _, b: 0, .. } => {}, | = help: try with `Foo { b: 0, .. }` = note: `-D clippy::unneeded-field-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unneeded_field_pattern)]` error: all the struct fields are matched to a wildcard pattern, consider using `..` --> $DIR/unneeded_field_pattern.rs:20:9 diff --git a/src/tools/clippy/tests/ui/unnested_or_patterns.stderr b/src/tools/clippy/tests/ui/unnested_or_patterns.stderr index 9e4f0d45d80a5..98ca7e3735678 100644 --- a/src/tools/clippy/tests/ui/unnested_or_patterns.stderr +++ b/src/tools/clippy/tests/ui/unnested_or_patterns.stderr @@ -5,6 +5,7 @@ LL | if let box 0 | box 2 = Box::new(0) {} | ^^^^^^^^^^^^^ | = note: `-D clippy::unnested-or-patterns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnested_or_patterns)]` help: nest the patterns | LL | if let box (0 | 2) = Box::new(0) {} diff --git a/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr b/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr index afb3100a552b2..182ae00de2208 100644 --- a/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr +++ b/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr @@ -5,6 +5,7 @@ LL | if let Some(Some(0)) | Some(Some(1)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnested-or-patterns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnested_or_patterns)]` help: nest the patterns | LL | if let Some(Some(0 | 1)) = None {} diff --git a/src/tools/clippy/tests/ui/unreadable_literal.stderr b/src/tools/clippy/tests/ui/unreadable_literal.stderr index b75aa75a336d2..d7a3377ec37df 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.stderr +++ b/src/tools/clippy/tests/ui/unreadable_literal.stderr @@ -5,6 +5,7 @@ LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]` error: long literal lacking separators --> $DIR/unreadable_literal.rs:32:31 diff --git a/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr b/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr index 7b96500fd115a..d6fb82398d87a 100644 --- a/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr +++ b/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr @@ -6,6 +6,7 @@ LL | #[derive(Deserialize)] | = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html = note: `-D clippy::unsafe-derive-deserialize` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unsafe_derive_deserialize)]` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` diff --git a/src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr b/src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr index 5daa69e1fb4d1..261c7837a4c1f 100644 --- a/src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr +++ b/src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr @@ -5,6 +5,7 @@ LL | use std::cell::UnsafeCell as TotallySafeCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unsafe_removed_from_name)]` error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCellAgain` --> $DIR/unsafe_removed_from_name.rs:9:1 diff --git a/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr b/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr index a0c0be7a9d154..d74e728750577 100644 --- a/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr +++ b/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr @@ -5,6 +5,7 @@ LL | let _fail1 = 1234i32; | ^^^^^^^ help: add an underscore: `1234_i32` | = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unseparated_literal_suffix)]` error: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:24:18 diff --git a/src/tools/clippy/tests/ui/unused_async.stderr b/src/tools/clippy/tests/ui/unused_async.stderr index 06944f8f8d8d6..077e8cacce146 100644 --- a/src/tools/clippy/tests/ui/unused_async.stderr +++ b/src/tools/clippy/tests/ui/unused_async.stderr @@ -16,6 +16,7 @@ note: `await` used in an async block, which does not require the enclosing funct LL | ready(()).await; | ^^^^^ = note: `-D clippy::unused-async` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unused_async)]` error: unused `async` for function with no await statements --> $DIR/unused_async.rs:46:5 diff --git a/src/tools/clippy/tests/ui/unused_format_specs_unfixable.stderr b/src/tools/clippy/tests/ui/unused_format_specs_unfixable.stderr index e9145ff382a73..183e80c853c66 100644 --- a/src/tools/clippy/tests/ui/unused_format_specs_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unused_format_specs_unfixable.stderr @@ -5,6 +5,7 @@ LL | println!("{:5}.", format_args!("")); | ^^^^ | = note: `-D clippy::unused-format-specs` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unused_format_specs)]` help: for the width to apply consider using `format!()` | LL | println!("{:5}.", format!("")); diff --git a/src/tools/clippy/tests/ui/unused_io_amount.stderr b/src/tools/clippy/tests/ui/unused_io_amount.stderr index c729a0b90166d..f9aef596a1c98 100644 --- a/src/tools/clippy/tests/ui/unused_io_amount.stderr +++ b/src/tools/clippy/tests/ui/unused_io_amount.stderr @@ -6,6 +6,7 @@ LL | s.write(b"test")?; | = help: use `Write::write_all` instead, or handle partial writes = note: `-D clippy::unused-io-amount` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unused_io_amount)]` error: read amount is not handled --> $DIR/unused_io_amount.rs:12:5 diff --git a/src/tools/clippy/tests/ui/unused_peekable.stderr b/src/tools/clippy/tests/ui/unused_peekable.stderr index 896ca49d710c9..157d6fc15f2f7 100644 --- a/src/tools/clippy/tests/ui/unused_peekable.stderr +++ b/src/tools/clippy/tests/ui/unused_peekable.stderr @@ -6,6 +6,7 @@ LL | let peekable = std::iter::empty::().peekable(); | = help: consider removing the call to `peekable` = note: `-D clippy::unused-peekable` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unused_peekable)]` error: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:18:9 diff --git a/src/tools/clippy/tests/ui/unused_rounding.stderr b/src/tools/clippy/tests/ui/unused_rounding.stderr index 163f78982eef0..d6ce27351353c 100644 --- a/src/tools/clippy/tests/ui/unused_rounding.stderr +++ b/src/tools/clippy/tests/ui/unused_rounding.stderr @@ -5,6 +5,7 @@ LL | let _ = 1f32.ceil(); | ^^^^^^^^^^^ help: remove the `ceil` method call: `1f32` | = note: `-D clippy::unused-rounding` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unused_rounding)]` error: used the `floor` method with a whole number float --> $DIR/unused_rounding.rs:5:13 diff --git a/src/tools/clippy/tests/ui/unused_self.stderr b/src/tools/clippy/tests/ui/unused_self.stderr index 5cf15c00b1b6f..3865095bbfeb6 100644 --- a/src/tools/clippy/tests/ui/unused_self.stderr +++ b/src/tools/clippy/tests/ui/unused_self.stderr @@ -6,6 +6,7 @@ LL | fn unused_self_move(self) {} | = help: consider refactoring to an associated function = note: `-D clippy::unused-self` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unused_self)]` error: unused `self` argument --> $DIR/unused_self.rs:13:28 diff --git a/src/tools/clippy/tests/ui/unwrap.stderr b/src/tools/clippy/tests/ui/unwrap.stderr index 38904858a3239..25911ded2fb3c 100644 --- a/src/tools/clippy/tests/ui/unwrap.stderr +++ b/src/tools/clippy/tests/ui/unwrap.stderr @@ -7,6 +7,7 @@ LL | let _ = opt.unwrap(); = note: if this value is `None`, it will panic = help: consider using `expect()` to provide a better panic message = note: `-D clippy::unwrap-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `unwrap()` on a `Result` value --> $DIR/unwrap.rs:12:13 diff --git a/src/tools/clippy/tests/ui/unwrap_expect_used.stderr b/src/tools/clippy/tests/ui/unwrap_expect_used.stderr index 0b43f5727455f..cbe6ea22e8997 100644 --- a/src/tools/clippy/tests/ui/unwrap_expect_used.stderr +++ b/src/tools/clippy/tests/ui/unwrap_expect_used.stderr @@ -6,6 +6,7 @@ LL | Some(3).unwrap(); | = note: if this value is `None`, it will panic = note: `-D clippy::unwrap-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `expect()` on an `Option` value --> $DIR/unwrap_expect_used.rs:29:5 @@ -15,6 +16,7 @@ LL | Some(3).expect("Hello world!"); | = note: if this value is `None`, it will panic = note: `-D clippy::expect-used` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `unwrap()` on a `Result` value --> $DIR/unwrap_expect_used.rs:45:5 diff --git a/src/tools/clippy/tests/ui/unwrap_in_result.stderr b/src/tools/clippy/tests/ui/unwrap_in_result.stderr index a394da272a869..9a0a32d471e33 100644 --- a/src/tools/clippy/tests/ui/unwrap_in_result.stderr +++ b/src/tools/clippy/tests/ui/unwrap_in_result.stderr @@ -17,6 +17,7 @@ note: potential non-recoverable error(s) LL | let i = i_str.parse::().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::unwrap-in-result` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_in_result)]` error: used unwrap or expect in a function that returns result or option --> $DIR/unwrap_in_result.rs:33:5 diff --git a/src/tools/clippy/tests/ui/unwrap_or.stderr b/src/tools/clippy/tests/ui/unwrap_or.stderr index 8992092bc58fb..3a32092f7be17 100644 --- a/src/tools/clippy/tests/ui/unwrap_or.stderr +++ b/src/tools/clippy/tests/ui/unwrap_or.stderr @@ -5,6 +5,7 @@ LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| "Fail".to_string())` | = note: `-D clippy::or-fun-call` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::or_fun_call)]` error: use of `unwrap_or` followed by a function call --> $DIR/unwrap_or.rs:11:47 diff --git a/src/tools/clippy/tests/ui/unwrap_or_else_default.stderr b/src/tools/clippy/tests/ui/unwrap_or_else_default.stderr index 40023cf3b668d..3119aba19e8fd 100644 --- a/src/tools/clippy/tests/ui/unwrap_or_else_default.stderr +++ b/src/tools/clippy/tests/ui/unwrap_or_else_default.stderr @@ -5,6 +5,7 @@ LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = note: `-D clippy::unwrap-or-default` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unwrap_or_default)]` error: use of `unwrap_or_else` to construct default value --> $DIR/unwrap_or_else_default.rs:60:23 diff --git a/src/tools/clippy/tests/ui/upper_case_acronyms.stderr b/src/tools/clippy/tests/ui/upper_case_acronyms.stderr index 9be1bb304eced..c57b325e91a6d 100644 --- a/src/tools/clippy/tests/ui/upper_case_acronyms.stderr +++ b/src/tools/clippy/tests/ui/upper_case_acronyms.stderr @@ -5,6 +5,7 @@ LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` | = note: `-D clippy::upper-case-acronyms` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::upper_case_acronyms)]` error: name `ECE` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:12:5 diff --git a/src/tools/clippy/tests/ui/use_self.stderr b/src/tools/clippy/tests/ui/use_self.stderr index 0e6ae5d451ba2..a1d4eac5dc09a 100644 --- a/src/tools/clippy/tests/ui/use_self.stderr +++ b/src/tools/clippy/tests/ui/use_self.stderr @@ -5,6 +5,7 @@ LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` | = note: `-D clippy::use-self` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition --> $DIR/use_self.rs:22:13 diff --git a/src/tools/clippy/tests/ui/use_self_trait.stderr b/src/tools/clippy/tests/ui/use_self_trait.stderr index 301d78e6c1ece..71a227174eafc 100644 --- a/src/tools/clippy/tests/ui/use_self_trait.stderr +++ b/src/tools/clippy/tests/ui/use_self_trait.stderr @@ -5,6 +5,7 @@ LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` | = note: `-D clippy::use-self` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition --> $DIR/use_self_trait.rs:19:27 diff --git a/src/tools/clippy/tests/ui/used_underscore_binding.stderr b/src/tools/clippy/tests/ui/used_underscore_binding.stderr index 875fafe438a13..289519b172eeb 100644 --- a/src/tools/clippy/tests/ui/used_underscore_binding.stderr +++ b/src/tools/clippy/tests/ui/used_underscore_binding.stderr @@ -5,6 +5,7 @@ LL | _foo + 1 | ^^^^ | = note: `-D clippy::used-underscore-binding` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::used_underscore_binding)]` 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:20 diff --git a/src/tools/clippy/tests/ui/useless_attribute.stderr b/src/tools/clippy/tests/ui/useless_attribute.stderr index 8bb7b2d3d9ed1..e65c59abaf88f 100644 --- a/src/tools/clippy/tests/ui/useless_attribute.stderr +++ b/src/tools/clippy/tests/ui/useless_attribute.stderr @@ -5,6 +5,7 @@ LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` | = note: `-D clippy::useless-attribute` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::useless_attribute)]` error: useless lint attribute --> $DIR/useless_attribute.rs:9:1 diff --git a/src/tools/clippy/tests/ui/vec.stderr b/src/tools/clippy/tests/ui/vec.stderr index 5cd6d9fa8c7e7..a28024d236a1e 100644 --- a/src/tools/clippy/tests/ui/vec.stderr +++ b/src/tools/clippy/tests/ui/vec.stderr @@ -5,6 +5,7 @@ LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` | = note: `-D clippy::useless-vec` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::useless_vec)]` error: useless use of `vec!` --> $DIR/vec.rs:32:18 diff --git a/src/tools/clippy/tests/ui/vec_box_sized.stderr b/src/tools/clippy/tests/ui/vec_box_sized.stderr index 78e00f5661b41..9118f284bb977 100644 --- a/src/tools/clippy/tests/ui/vec_box_sized.stderr +++ b/src/tools/clippy/tests/ui/vec_box_sized.stderr @@ -5,6 +5,7 @@ LL | const C: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` | = note: `-D clippy::vec-box` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::vec_box)]` error: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:11:15 diff --git a/src/tools/clippy/tests/ui/vec_init_then_push.stderr b/src/tools/clippy/tests/ui/vec_init_then_push.stderr index 9ad793d979b77..978201bd17aa2 100644 --- a/src/tools/clippy/tests/ui/vec_init_then_push.stderr +++ b/src/tools/clippy/tests/ui/vec_init_then_push.stderr @@ -8,6 +8,7 @@ LL | | def_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `let def_err: Vec = vec![..];` | = note: `-D clippy::vec-init-then-push` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::vec_init_then_push)]` error: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:10:5 diff --git a/src/tools/clippy/tests/ui/vec_resize_to_zero.stderr b/src/tools/clippy/tests/ui/vec_resize_to_zero.stderr index 8851e9f38be49..715c9923b2e54 100644 --- a/src/tools/clippy/tests/ui/vec_resize_to_zero.stderr +++ b/src/tools/clippy/tests/ui/vec_resize_to_zero.stderr @@ -8,6 +8,7 @@ LL | v.resize(0, 5); | = help: the arguments may be inverted... = note: `-D clippy::vec-resize-to-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::vec_resize_to_zero)]` error: aborting due to previous error diff --git a/src/tools/clippy/tests/ui/verbose_file_reads.stderr b/src/tools/clippy/tests/ui/verbose_file_reads.stderr index 592a7984305d4..04e1aedf7c5a5 100644 --- a/src/tools/clippy/tests/ui/verbose_file_reads.stderr +++ b/src/tools/clippy/tests/ui/verbose_file_reads.stderr @@ -6,6 +6,7 @@ LL | f.read_to_end(&mut buffer)?; | = help: consider using `fs::read` instead = note: `-D clippy::verbose-file-reads` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::verbose_file_reads)]` error: use of `File::read_to_string` --> $DIR/verbose_file_reads.rs:27:5 diff --git a/src/tools/clippy/tests/ui/vtable_address_comparisons.stderr b/src/tools/clippy/tests/ui/vtable_address_comparisons.stderr index 91490afce3626..83c82f3796eb4 100644 --- a/src/tools/clippy/tests/ui/vtable_address_comparisons.stderr +++ b/src/tools/clippy/tests/ui/vtable_address_comparisons.stderr @@ -6,6 +6,7 @@ LL | let _ = a == b; | = help: consider extracting and comparing data pointers only = note: `-D clippy::vtable-address-comparisons` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::vtable_address_comparisons)]` error: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:16:13 diff --git a/src/tools/clippy/tests/ui/while_let_loop.stderr b/src/tools/clippy/tests/ui/while_let_loop.stderr index 00411172141c3..db887dc65c6a2 100644 --- a/src/tools/clippy/tests/ui/while_let_loop.stderr +++ b/src/tools/clippy/tests/ui/while_let_loop.stderr @@ -11,6 +11,7 @@ LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` | = note: `-D clippy::while-let-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: this loop could be written as a `while let` loop --> $DIR/while_let_loop.rs:25:5 diff --git a/src/tools/clippy/tests/ui/while_let_on_iterator.stderr b/src/tools/clippy/tests/ui/while_let_on_iterator.stderr index f8a66f2ad3e95..cdc83b8166707 100644 --- a/src/tools/clippy/tests/ui/while_let_on_iterator.stderr +++ b/src/tools/clippy/tests/ui/while_let_on_iterator.stderr @@ -5,6 +5,7 @@ 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` + = help: to override `-D warnings` add `#[allow(clippy::while_let_on_iterator)]` error: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:20:5 diff --git a/src/tools/clippy/tests/ui/wild_in_or_pats.stderr b/src/tools/clippy/tests/ui/wild_in_or_pats.stderr index 5d9ab78bbb4d8..4cfa0d99350d0 100644 --- a/src/tools/clippy/tests/ui/wild_in_or_pats.stderr +++ b/src/tools/clippy/tests/ui/wild_in_or_pats.stderr @@ -6,6 +6,7 @@ LL | "bar" | _ => { | = help: consider handling `_` separately = note: `-D clippy::wildcard-in-or-patterns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wildcard_in_or_patterns)]` error: wildcard pattern covers any other pattern as it will match anyway --> $DIR/wild_in_or_pats.rs:17:9 diff --git a/src/tools/clippy/tests/ui/wildcard_imports.stderr b/src/tools/clippy/tests/ui/wildcard_imports.stderr index f7baf234c2f8b..3c750815bafc9 100644 --- a/src/tools/clippy/tests/ui/wildcard_imports.stderr +++ b/src/tools/clippy/tests/ui/wildcard_imports.stderr @@ -5,6 +5,7 @@ LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` | = note: `-D clippy::wildcard-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import --> $DIR/wildcard_imports.rs:16:5 diff --git a/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr b/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr index af9ae6e786c96..709a665d65c2a 100644 --- a/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr +++ b/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr @@ -5,6 +5,7 @@ LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` | = note: `-D clippy::wildcard-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:14:5 diff --git a/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr b/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr index af9ae6e786c96..709a665d65c2a 100644 --- a/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr +++ b/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr @@ -5,6 +5,7 @@ LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` | = note: `-D clippy::wildcard-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:14:5 diff --git a/src/tools/clippy/tests/ui/write_literal.stderr b/src/tools/clippy/tests/ui/write_literal.stderr index f0a09074bc654..372a54cf769fb 100644 --- a/src/tools/clippy/tests/ui/write_literal.stderr +++ b/src/tools/clippy/tests/ui/write_literal.stderr @@ -5,6 +5,7 @@ LL | write!(v, "Hello {}", "world"); | ^^^^^^^ | = note: `-D clippy::write-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::write_literal)]` help: try | LL - write!(v, "Hello {}", "world"); diff --git a/src/tools/clippy/tests/ui/write_literal_2.stderr b/src/tools/clippy/tests/ui/write_literal_2.stderr index 84b302d8d3b4e..fc24dba45437c 100644 --- a/src/tools/clippy/tests/ui/write_literal_2.stderr +++ b/src/tools/clippy/tests/ui/write_literal_2.stderr @@ -5,6 +5,7 @@ LL | writeln!(v, r"{}", r"{hello}"); | ^^^^^^^^^^ help: try: `"{hello}"` | = note: `-D clippy::needless-raw-strings` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_raw_strings)]` error: literal with an empty format string --> $DIR/write_literal_2.rs:10:23 @@ -13,6 +14,7 @@ LL | writeln!(v, "{}", "{hello}"); | ^^^^^^^^^ | = note: `-D clippy::write-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::write_literal)]` help: try | LL - writeln!(v, "{}", "{hello}"); diff --git a/src/tools/clippy/tests/ui/write_with_newline.stderr b/src/tools/clippy/tests/ui/write_with_newline.stderr index d84d57d84f5b5..78874ffadc0be 100644 --- a/src/tools/clippy/tests/ui/write_with_newline.stderr +++ b/src/tools/clippy/tests/ui/write_with_newline.stderr @@ -5,6 +5,7 @@ LL | write!(v, "Hello\n"); | ^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::write-with-newline` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::write_with_newline)]` help: use `writeln!` instead | LL - write!(v, "Hello\n"); diff --git a/src/tools/clippy/tests/ui/writeln_empty_string.stderr b/src/tools/clippy/tests/ui/writeln_empty_string.stderr index 93e1af5a4ec4f..0374755436176 100644 --- a/src/tools/clippy/tests/ui/writeln_empty_string.stderr +++ b/src/tools/clippy/tests/ui/writeln_empty_string.stderr @@ -7,6 +7,7 @@ LL | writeln!(v, ""); | help: remove the empty string | = note: `-D clippy::writeln-empty-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::writeln_empty_string)]` error: empty string literal in `writeln!` --> $DIR/writeln_empty_string.rs:12:5 diff --git a/src/tools/clippy/tests/ui/wrong_self_convention.stderr b/src/tools/clippy/tests/ui/wrong_self_convention.stderr index 2d52b64c81274..9f457b50ce775 100644 --- a/src/tools/clippy/tests/ui/wrong_self_convention.stderr +++ b/src/tools/clippy/tests/ui/wrong_self_convention.stderr @@ -6,6 +6,7 @@ LL | fn from_i32(self) {} | = help: consider choosing a less ambiguous name = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:23:21 diff --git a/src/tools/clippy/tests/ui/wrong_self_convention2.stderr b/src/tools/clippy/tests/ui/wrong_self_convention2.stderr index 0069059203bf9..dc12a844332eb 100644 --- a/src/tools/clippy/tests/ui/wrong_self_convention2.stderr +++ b/src/tools/clippy/tests/ui/wrong_self_convention2.stderr @@ -6,6 +6,7 @@ LL | pub fn from_be_self(self) -> Self { | = help: consider choosing a less ambiguous name = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention2.rs:64:25 diff --git a/src/tools/clippy/tests/ui/wrong_self_conventions_mut.stderr b/src/tools/clippy/tests/ui/wrong_self_conventions_mut.stderr index cd7a9aae144e2..21255287d722e 100644 --- a/src/tools/clippy/tests/ui/wrong_self_conventions_mut.stderr +++ b/src/tools/clippy/tests/ui/wrong_self_conventions_mut.stderr @@ -6,6 +6,7 @@ LL | pub fn to_many(&mut self) -> Option<&mut [T]> { | = help: consider choosing a less ambiguous name = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods with the following characteristics: (`to_*` and `*_mut`) usually take `self` by mutable reference --> $DIR/wrong_self_conventions_mut.rs:23:28 diff --git a/src/tools/clippy/tests/ui/zero_div_zero.stderr b/src/tools/clippy/tests/ui/zero_div_zero.stderr index cde6bc907c683..797ae2537bb37 100644 --- a/src/tools/clippy/tests/ui/zero_div_zero.stderr +++ b/src/tools/clippy/tests/ui/zero_div_zero.stderr @@ -6,6 +6,7 @@ LL | let nan = 0.0 / 0.0; | = help: consider using `f64::NAN` if you would like a constant representing NaN = note: `-D clippy::zero-divided-by-zero` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::zero_divided_by_zero)]` error: constant division of `0.0` with `0.0` will always result in NaN --> $DIR/zero_div_zero.rs:6:19 diff --git a/src/tools/clippy/tests/ui/zero_ptr.stderr b/src/tools/clippy/tests/ui/zero_ptr.stderr index 21c2b8c1e3527..57679a8ac564f 100644 --- a/src/tools/clippy/tests/ui/zero_ptr.stderr +++ b/src/tools/clippy/tests/ui/zero_ptr.stderr @@ -5,6 +5,7 @@ LL | let _ = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null::()` | = note: `-D clippy::zero-ptr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::zero_ptr)]` error: `0 as *mut _` detected --> $DIR/zero_ptr.rs:5:13 diff --git a/src/tools/clippy/tests/ui/zero_sized_btreemap_values.stderr b/src/tools/clippy/tests/ui/zero_sized_btreemap_values.stderr index de122473fd26d..c48e19a760af2 100644 --- a/src/tools/clippy/tests/ui/zero_sized_btreemap_values.stderr +++ b/src/tools/clippy/tests/ui/zero_sized_btreemap_values.stderr @@ -6,6 +6,7 @@ LL | const CONST_NOT_OK: Option> = None; | = help: consider using a set instead = note: `-D clippy::zero-sized-map-values` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::zero_sized_map_values)]` error: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:9:30 diff --git a/src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr b/src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr index 0d489f45aca16..08b1b58f3df3a 100644 --- a/src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr +++ b/src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr @@ -6,6 +6,7 @@ LL | const CONST_NOT_OK: Option> = None; | = help: consider using a set instead = note: `-D clippy::zero-sized-map-values` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::zero_sized_map_values)]` error: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:9:30 From fa5f13775af25b71edb07bfce42041f40862353a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 4 Sep 2023 17:53:38 +0200 Subject: [PATCH 48/73] interpret: make MemPlace, Place, Operand types private to the interpreter --- .../src/const_eval/eval_queries.rs | 6 +- .../rustc_const_eval/src/const_eval/mod.rs | 2 +- .../src/const_eval/valtrees.rs | 6 +- .../src/interpret/eval_context.rs | 61 +++-- .../rustc_const_eval/src/interpret/intern.rs | 12 +- .../src/interpret/intrinsics.rs | 2 +- .../rustc_const_eval/src/interpret/machine.rs | 18 +- .../rustc_const_eval/src/interpret/mod.rs | 11 +- .../rustc_const_eval/src/interpret/operand.rs | 122 +++++---- .../rustc_const_eval/src/interpret/place.rs | 259 ++++++++++-------- .../src/interpret/projection.rs | 8 +- .../rustc_const_eval/src/interpret/step.rs | 4 +- .../src/interpret/terminator.rs | 6 +- .../src/interpret/validity.rs | 12 +- .../src/util/check_validity_requirement.rs | 2 +- .../rustc_middle/src/mir/interpret/pointer.rs | 2 +- .../rustc_mir_transform/src/const_prop.rs | 24 +- .../src/const_prop_lint.rs | 20 +- .../src/borrow_tracker/stacked_borrows/mod.rs | 10 +- .../src/borrow_tracker/tree_borrows/mod.rs | 10 +- src/tools/miri/src/concurrency/data_race.rs | 10 +- src/tools/miri/src/concurrency/thread.rs | 12 +- src/tools/miri/src/concurrency/weak_memory.rs | 10 +- src/tools/miri/src/diagnostics.rs | 4 +- src/tools/miri/src/eval.rs | 15 +- src/tools/miri/src/helpers.rs | 12 +- src/tools/miri/src/machine.rs | 16 +- src/tools/miri/src/shims/backtrace.rs | 2 +- src/tools/miri/src/shims/env.rs | 2 +- src/tools/miri/src/shims/foreign_items.rs | 2 +- src/tools/miri/src/shims/intrinsics/mod.rs | 2 +- src/tools/miri/src/shims/os_str.rs | 8 +- .../miri/src/shims/unix/android/dlsym.rs | 2 +- .../miri/src/shims/unix/foreign_items.rs | 2 +- src/tools/miri/src/shims/unix/fs.rs | 2 +- src/tools/miri/src/shims/unix/linux/sync.rs | 4 +- src/tools/miri/src/shims/unix/macos/dlsym.rs | 2 +- .../src/shims/unix/macos/foreign_items.rs | 6 +- src/tools/miri/src/shims/windows/dlsym.rs | 2 +- .../miri/src/shims/windows/foreign_items.rs | 4 +- src/tools/miri/src/tag_gc.rs | 39 +-- 41 files changed, 417 insertions(+), 338 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index fc0dba6b67bc3..9df3e4030fff6 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -79,7 +79,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( intern_const_alloc_recursive(ecx, intern_kind, &ret)?; // we leave alignment checks off, since this `ecx` will not be used for further evaluation anyway - debug!("eval_body_using_ecx done: {:?}", *ret); + debug!("eval_body_using_ecx done: {:?}", ret); Ok(ret) } @@ -147,7 +147,7 @@ pub(super) fn op_to_const<'tcx>( // We know `offset` is relative to the allocation, so we can use `into_parts`. let to_const_value = |mplace: &MPlaceTy<'_>| { debug!("to_const_value(mplace: {:?})", mplace); - match mplace.ptr.into_parts() { + match mplace.ptr().into_parts() { (Some(alloc_id), offset) => { let alloc = ecx.tcx.global_alloc(alloc_id).unwrap_memory(); ConstValue::ByRef { alloc, offset } @@ -370,7 +370,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>( inner = true; } }; - let alloc_id = mplace.ptr.provenance.unwrap(); + let alloc_id = mplace.ptr().provenance.unwrap(); // Validation failed, report an error. This is always a hard error. if let Err(error) = validation { diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index ef31155215a1b..5327fa5ce39bd 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -30,7 +30,7 @@ pub(crate) fn const_caller_location( if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() { bug!("intern_const_alloc_recursive should not error in this case") } - ConstValue::Scalar(Scalar::from_maybe_pointer(loc_place.ptr, &tcx)) + ConstValue::Scalar(Scalar::from_maybe_pointer(loc_place.ptr(), &tcx)) } // We forbid type-level constants that contain more than `VALTREE_MAX_NODES` nodes. diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index b15a65d67a3d3..572d7f9ac2fec 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -5,7 +5,7 @@ use crate::const_eval::CanAccessStatics; use crate::interpret::MPlaceTy; use crate::interpret::{ intern_const_alloc_recursive, ConstValue, ImmTy, Immediate, InternKind, MemPlaceMeta, - MemoryKind, Place, Projectable, Scalar, + MemoryKind, PlaceTy, Projectable, Scalar, }; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt}; @@ -318,7 +318,7 @@ fn valtree_into_mplace<'tcx>( let len_scalar = Scalar::from_target_usize(len as u64, &tcx); Immediate::ScalarPair( - Scalar::from_maybe_pointer((*pointee_place).ptr, &tcx), + Scalar::from_maybe_pointer(pointee_place.ptr(), &tcx), len_scalar, ) } @@ -383,5 +383,5 @@ fn valtree_into_mplace<'tcx>( } fn dump_place<'tcx>(ecx: &CompileTimeEvalContext<'tcx, 'tcx>, place: &MPlaceTy<'tcx>) { - trace!("{:?}", ecx.dump_place(Place::Ptr(**place))); + trace!("{:?}", ecx.dump_place(&PlaceTy::from(place.clone()))); } diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 1c90ce29b02e3..db1eaf5862179 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -21,8 +21,8 @@ use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayou use super::{ AllocId, GlobalId, Immediate, InterpErrorInfo, InterpResult, MPlaceTy, Machine, MemPlace, - MemPlaceMeta, Memory, MemoryKind, Operand, Place, PlaceTy, PointerArithmetic, Provenance, - Scalar, StackPopJump, + MemPlaceMeta, Memory, MemoryKind, Operand, Place, PlaceTy, Pointer, PointerArithmetic, + Projectable, Provenance, Scalar, StackPopJump, }; use crate::errors::{self, ErroneousConstUsed}; use crate::util; @@ -155,17 +155,26 @@ pub enum StackPopCleanup { } /// State of a local variable including a memoized layout -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct LocalState<'tcx, Prov: Provenance = AllocId> { - pub value: LocalValue, + value: LocalValue, /// Don't modify if `Some`, this is only used to prevent computing the layout twice. /// Avoids computing the layout of locals that are never actually initialized. - pub layout: Cell>>, + layout: Cell>>, +} + +impl std::fmt::Debug for LocalState<'_, Prov> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("LocalState") + .field("value", &self.value) + .field("ty", &self.layout.get().map(|l| l.ty)) + .finish() + } } /// Current value of a local variable #[derive(Copy, Clone, Debug)] // Miri debug-prints these -pub enum LocalValue { +pub(super) enum LocalValue { /// This local is not currently alive, and cannot be used at all. Dead, /// A normal, live local. @@ -176,10 +185,27 @@ pub enum LocalValue { Live(Operand), } -impl<'tcx, Prov: Provenance + 'static> LocalState<'tcx, Prov> { +impl<'tcx, Prov: Provenance> LocalState<'tcx, Prov> { + pub fn make_live_uninit(&mut self) { + self.value = LocalValue::Live(Operand::Immediate(Immediate::Uninit)); + } + + /// This is a hack because Miri needs a way to visit all the provenance in a `LocalState` + /// without having a layout or `TyCtxt` available, and we want to keep the `Operand` type + /// private. + pub fn as_mplace_or_imm( + &self, + ) -> Option>, MemPlaceMeta), Immediate>> { + match self.value { + LocalValue::Dead => None, + LocalValue::Live(Operand::Indirect(mplace)) => Some(Left((mplace.ptr, mplace.meta))), + LocalValue::Live(Operand::Immediate(imm)) => Some(Right(imm)), + } + } + /// Read the local's value or error if the local is not yet live or not live anymore. #[inline(always)] - pub fn access(&self) -> InterpResult<'tcx, &Operand> { + pub(super) fn access(&self) -> InterpResult<'tcx, &Operand> { match &self.value { LocalValue::Dead => throw_ub!(DeadLocal), // could even be "invalid program"? LocalValue::Live(val) => Ok(val), @@ -189,10 +215,10 @@ impl<'tcx, Prov: Provenance + 'static> LocalState<'tcx, Prov> { /// Overwrite the local. If the local can be overwritten in place, return a reference /// to do so; otherwise return the `MemPlace` to consult instead. /// - /// Note: This may only be invoked from the `Machine::access_local_mut` hook and not from - /// anywhere else. You may be invalidating machine invariants if you do! + /// Note: Before calling this, call the `before_access_local_mut` machine hook! You may be + /// invalidating machine invariants otherwise! #[inline(always)] - pub fn access_mut(&mut self) -> InterpResult<'tcx, &mut Operand> { + pub(super) fn access_mut(&mut self) -> InterpResult<'tcx, &mut Operand> { match &mut self.value { LocalValue::Dead => throw_ub!(DeadLocal), // could even be "invalid program"? LocalValue::Live(val) => Ok(val), @@ -694,7 +720,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { &self, mplace: &MPlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx, Option<(Size, Align)>> { - self.size_and_align_of(&mplace.meta, &mplace.layout) + self.size_and_align_of(&mplace.meta(), &mplace.layout) } #[instrument(skip(self, body, return_place, return_to_block), level = "debug")] @@ -826,7 +852,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { .expect("return place should always be live"); let dest = self.frame().return_place.clone(); let err = self.copy_op(&op, &dest, /*allow_transmute*/ true); - trace!("return value: {:?}", self.dump_place(*dest)); + trace!("return value: {:?}", self.dump_place(&dest)); // We delay actually short-circuiting on this error until *after* the stack frame is // popped, since we want this error to be attributed to the caller, whose type defines // this transmute. @@ -974,7 +1000,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } // Need to allocate some memory, since `Immediate::Uninit` cannot be unsized. let dest_place = self.allocate_dyn(layout, MemoryKind::Stack, meta)?; - Operand::Indirect(*dest_place) + Operand::Indirect(*dest_place.mplace()) } else { assert!(!meta.has_meta()); // we're dropping the metadata // Just make this an efficient immediate. @@ -1068,8 +1094,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } #[must_use] - pub fn dump_place(&self, place: Place) -> PlacePrinter<'_, 'mir, 'tcx, M> { - PlacePrinter { ecx: self, place } + pub fn dump_place( + &self, + place: &PlaceTy<'tcx, M::Provenance>, + ) -> PlacePrinter<'_, 'mir, 'tcx, M> { + PlacePrinter { ecx: self, place: *place.place() } } #[must_use] diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index 42950d1ffb0c8..562f7c610fd65 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -25,7 +25,7 @@ use rustc_ast::Mutability; use super::{ AllocId, Allocation, ConstAllocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy, - ValueVisitor, + Projectable, ValueVisitor, }; use crate::const_eval; use crate::errors::{DanglingPtrInFinal, UnsupportedUntypedPointer}; @@ -177,7 +177,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory if let ty::Dynamic(_, _, ty::Dyn) = tcx.struct_tail_erasing_lifetimes(referenced_ty, self.ecx.param_env).kind() { - let ptr = mplace.meta.unwrap_meta().to_pointer(&tcx)?; + let ptr = mplace.meta().unwrap_meta().to_pointer(&tcx)?; if let Some(alloc_id) = ptr.provenance { // Explicitly choose const mode here, since vtables are immutable, even // if the reference of the fat pointer is mutable. @@ -191,7 +191,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory } // Check if we have encountered this pointer+layout combination before. // Only recurse for allocation-backed pointers. - if let Some(alloc_id) = mplace.ptr.provenance { + if let Some(alloc_id) = mplace.ptr().provenance { // Compute the mode with which we intern this. Our goal here is to make as many // statics as we can immutable so they can be placed in read-only memory by LLVM. let ref_mode = match self.mode { @@ -267,7 +267,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory // If there is no provenance in this allocation, it does not contain references // that point to another allocation, and we can avoid the interning walk. - if let Some(alloc) = self.ecx.get_ptr_alloc(mplace.ptr, size, align)? { + if let Some(alloc) = self.ecx.get_ptr_alloc(mplace.ptr(), size, align)? { if !alloc.has_provenance() { return Ok(false); } @@ -353,7 +353,7 @@ pub fn intern_const_alloc_recursive< leftover_allocations, // The outermost allocation must exist, because we allocated it with // `Memory::allocate`. - ret.ptr.provenance.unwrap(), + ret.ptr().provenance.unwrap(), base_intern_mode, Some(ret.layout.ty), ); @@ -466,7 +466,7 @@ impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx, !>> ) -> InterpResult<'tcx, ConstAllocation<'tcx>> { let dest = self.allocate(layout, MemoryKind::Stack)?; f(self, &dest.clone().into())?; - let mut alloc = self.memory.alloc_map.remove(&dest.ptr.provenance.unwrap()).unwrap().1; + let mut alloc = self.memory.alloc_map.remove(&dest.ptr().provenance.unwrap()).unwrap().1; alloc.mutability = Mutability::Not; Ok(self.tcx.mk_const_alloc(alloc)) } diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index d6ca6fe73a6e6..7feed74ceae17 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -466,7 +466,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { _ => return Ok(false), } - trace!("{:?}", self.dump_place(**dest)); + trace!("{:?}", self.dump_place(dest)); self.go_to_block(ret); Ok(true) } diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 91c07d73fceb5..9fda6b037c8ec 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -18,7 +18,7 @@ use crate::const_eval::CheckAlignment; use super::{ AllocBytes, AllocId, AllocRange, Allocation, ConstAllocation, FnArg, Frame, ImmTy, InterpCx, - InterpResult, MPlaceTy, MemoryKind, OpTy, Operand, PlaceTy, Pointer, Provenance, Scalar, + InterpResult, MPlaceTy, MemoryKind, OpTy, PlaceTy, Pointer, Provenance, Scalar, }; /// Data returned by Machine::stack_pop, @@ -237,22 +237,22 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized { right: &ImmTy<'tcx, Self::Provenance>, ) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)>; - /// Called to write the specified `local` from the `frame`. + /// Called before writing the specified `local` of the `frame`. /// Since writing a ZST is not actually accessing memory or locals, this is never invoked /// for ZST reads. /// /// Due to borrow checker trouble, we indicate the `frame` as an index rather than an `&mut /// Frame`. - #[inline] - fn access_local_mut<'a>( - ecx: &'a mut InterpCx<'mir, 'tcx, Self>, - frame: usize, - local: mir::Local, - ) -> InterpResult<'tcx, &'a mut Operand> + #[inline(always)] + fn before_access_local_mut<'a>( + _ecx: &'a mut InterpCx<'mir, 'tcx, Self>, + _frame: usize, + _local: mir::Local, + ) -> InterpResult<'tcx> where 'tcx: 'mir, { - ecx.stack_mut()[frame].locals[local].access_mut() + Ok(()) } /// Called before a basic block terminator is executed. diff --git a/compiler/rustc_const_eval/src/interpret/mod.rs b/compiler/rustc_const_eval/src/interpret/mod.rs index b0b553c45d432..69eb22028fa3d 100644 --- a/compiler/rustc_const_eval/src/interpret/mod.rs +++ b/compiler/rustc_const_eval/src/interpret/mod.rs @@ -20,16 +20,21 @@ mod visitor; pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in one place: here -pub use self::eval_context::{Frame, FrameInfo, InterpCx, LocalState, LocalValue, StackPopCleanup}; +pub use self::eval_context::{Frame, FrameInfo, InterpCx, StackPopCleanup}; pub use self::intern::{intern_const_alloc_recursive, InternKind}; pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump}; pub use self::memory::{AllocKind, AllocRef, AllocRefMut, FnVal, Memory, MemoryKind}; -pub use self::operand::{ImmTy, Immediate, OpTy, Operand, Readable}; -pub use self::place::{MPlaceTy, MemPlace, MemPlaceMeta, Place, PlaceTy, Writeable}; +pub use self::operand::{ImmTy, Immediate, OpTy, Readable}; +pub use self::place::{MPlaceTy, MemPlaceMeta, PlaceTy, Writeable}; pub use self::projection::Projectable; pub use self::terminator::FnArg; pub use self::validity::{CtfeValidationMode, RefTracking}; pub use self::visitor::ValueVisitor; +use self::{ + operand::Operand, + place::{MemPlace, Place}, +}; + pub(crate) use self::intrinsics::eval_nullary_intrinsic; use eval_context::{from_known_layout, mir_assign_valid_types}; diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 8d948eb10a7ad..26dd9098bb5d6 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -88,7 +88,7 @@ impl Immediate { // ScalarPair needs a type to interpret, so we often have an immediate and a type together // as input for binary and cast operations. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct ImmTy<'tcx, Prov: Provenance = AllocId> { imm: Immediate, pub layout: TyAndLayout<'tcx>, @@ -134,6 +134,12 @@ impl std::fmt::Display for ImmTy<'_, Prov> { } } +impl std::fmt::Debug for ImmTy<'_, Prov> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ImmTy").field("imm", &self.imm).field("ty", &self.layout.ty).finish() + } +} + impl<'tcx, Prov: Provenance> std::ops::Deref for ImmTy<'tcx, Prov> { type Target = Immediate; #[inline(always)] @@ -142,51 +148,6 @@ impl<'tcx, Prov: Provenance> std::ops::Deref for ImmTy<'tcx, Prov> { } } -/// An `Operand` is the result of computing a `mir::Operand`. It can be immediate, -/// or still in memory. The latter is an optimization, to delay reading that chunk of -/// memory and to avoid having to store arbitrary-sized data here. -#[derive(Copy, Clone, Debug)] -pub enum Operand { - Immediate(Immediate), - Indirect(MemPlace), -} - -#[derive(Clone, Debug)] -pub struct OpTy<'tcx, Prov: Provenance = AllocId> { - op: Operand, // Keep this private; it helps enforce invariants. - pub layout: TyAndLayout<'tcx>, - /// rustc does not have a proper way to represent the type of a field of a `repr(packed)` struct: - /// it needs to have a different alignment than the field type would usually have. - /// So we represent this here with a separate field that "overwrites" `layout.align`. - /// This means `layout.align` should never be used for an `OpTy`! - /// `None` means "alignment does not matter since this is a by-value operand" - /// (`Operand::Immediate`); this field is only relevant for `Operand::Indirect`. - /// Also CTFE ignores alignment anyway, so this is for Miri only. - pub align: Option, -} - -impl<'tcx, Prov: Provenance> std::ops::Deref for OpTy<'tcx, Prov> { - type Target = Operand; - #[inline(always)] - fn deref(&self) -> &Operand { - &self.op - } -} - -impl<'tcx, Prov: Provenance> From> for OpTy<'tcx, Prov> { - #[inline(always)] - fn from(mplace: MPlaceTy<'tcx, Prov>) -> Self { - OpTy { op: Operand::Indirect(*mplace), layout: mplace.layout, align: Some(mplace.align) } - } -} - -impl<'tcx, Prov: Provenance> From> for OpTy<'tcx, Prov> { - #[inline(always)] - fn from(val: ImmTy<'tcx, Prov>) -> Self { - OpTy { op: Operand::Immediate(val.imm), layout: val.layout, align: None } - } -} - impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> { #[inline] pub fn from_scalar(val: Scalar, layout: TyAndLayout<'tcx>) -> Self { @@ -319,7 +280,61 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for ImmTy<'tcx, Prov> { } } -impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for OpTy<'tcx, Prov> { +/// An `Operand` is the result of computing a `mir::Operand`. It can be immediate, +/// or still in memory. The latter is an optimization, to delay reading that chunk of +/// memory and to avoid having to store arbitrary-sized data here. +#[derive(Copy, Clone, Debug)] +pub(super) enum Operand { + Immediate(Immediate), + Indirect(MemPlace), +} + +#[derive(Clone)] +pub struct OpTy<'tcx, Prov: Provenance = AllocId> { + op: Operand, // Keep this private; it helps enforce invariants. + pub layout: TyAndLayout<'tcx>, + /// rustc does not have a proper way to represent the type of a field of a `repr(packed)` struct: + /// it needs to have a different alignment than the field type would usually have. + /// So we represent this here with a separate field that "overwrites" `layout.align`. + /// This means `layout.align` should never be used for an `OpTy`! + /// `None` means "alignment does not matter since this is a by-value operand" + /// (`Operand::Immediate`); this field is only relevant for `Operand::Indirect`. + /// Also CTFE ignores alignment anyway, so this is for Miri only. + pub align: Option, +} + +impl std::fmt::Debug for OpTy<'_, Prov> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("OpTy").field("op", &self.op).field("ty", &self.layout.ty).finish() + } +} + +impl<'tcx, Prov: Provenance> From> for OpTy<'tcx, Prov> { + #[inline(always)] + fn from(val: ImmTy<'tcx, Prov>) -> Self { + OpTy { op: Operand::Immediate(val.imm), layout: val.layout, align: None } + } +} + +impl<'tcx, Prov: Provenance> From> for OpTy<'tcx, Prov> { + #[inline(always)] + fn from(mplace: MPlaceTy<'tcx, Prov>) -> Self { + OpTy { + op: Operand::Indirect(*mplace.mplace()), + layout: mplace.layout, + align: Some(mplace.align), + } + } +} + +impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> { + #[inline(always)] + pub(super) fn op(&self) -> &Operand { + &self.op + } +} + +impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for OpTy<'tcx, Prov> { #[inline(always)] fn layout(&self) -> TyAndLayout<'tcx> { self.layout @@ -328,7 +343,7 @@ impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for OpTy<'tcx, Pr #[inline] fn meta(&self) -> MemPlaceMeta { match self.as_mplace_or_imm() { - Left(mplace) => mplace.meta, + Left(mplace) => mplace.meta(), Right(_) => { debug_assert!(self.layout.is_sized(), "unsized immediates are not a thing"); MemPlaceMeta::None @@ -362,18 +377,19 @@ impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for OpTy<'tcx, Pr } } +/// The `Readable` trait describes interpreter values that one can read from. pub trait Readable<'tcx, Prov: Provenance>: Projectable<'tcx, Prov> { fn as_mplace_or_imm(&self) -> Either, ImmTy<'tcx, Prov>>; } -impl<'tcx, Prov: Provenance + 'static> Readable<'tcx, Prov> for OpTy<'tcx, Prov> { +impl<'tcx, Prov: Provenance> Readable<'tcx, Prov> for OpTy<'tcx, Prov> { #[inline(always)] fn as_mplace_or_imm(&self) -> Either, ImmTy<'tcx, Prov>> { self.as_mplace_or_imm() } } -impl<'tcx, Prov: Provenance + 'static> Readable<'tcx, Prov> for MPlaceTy<'tcx, Prov> { +impl<'tcx, Prov: Provenance> Readable<'tcx, Prov> for MPlaceTy<'tcx, Prov> { #[inline(always)] fn as_mplace_or_imm(&self) -> Either, ImmTy<'tcx, Prov>> { Left(self.clone()) @@ -535,7 +551,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Turn the wide MPlace into a string (must already be dereferenced!) pub fn read_str(&self, mplace: &MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, &str> { let len = mplace.len(self)?; - let bytes = self.read_bytes_ptr_strip_provenance(mplace.ptr, Size::from_bytes(len))?; + let bytes = self.read_bytes_ptr_strip_provenance(mplace.ptr(), Size::from_bytes(len))?; let str = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?; Ok(str) } @@ -630,7 +646,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { op = self.project(&op, elem)? } - trace!("eval_place_to_op: got {:?}", *op); + trace!("eval_place_to_op: got {:?}", op); // Sanity-check the type we ended up with. debug_assert!( mir_assign_valid_types( @@ -673,7 +689,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.eval_mir_constant(&c, Some(constant.span), layout)? } }; - trace!("{:?}: {:?}", mir_op, *op); + trace!("{:?}: {:?}", mir_op, op); Ok(op) } diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 65c5cd656cb83..d8ad82d3da0a1 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -51,7 +51,7 @@ impl MemPlaceMeta { } #[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)] -pub struct MemPlace { +pub(super) struct MemPlace { /// The pointer can be a pure integer, with the `None` provenance. pub ptr: Pointer>, /// Metadata for unsized places. Interpretation is up to the type. @@ -60,68 +60,6 @@ pub struct MemPlace { pub meta: MemPlaceMeta, } -/// A MemPlace with its layout. Constructing it is only possible in this module. -#[derive(Clone, Hash, Eq, PartialEq, Debug)] -pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> { - mplace: MemPlace, - pub layout: TyAndLayout<'tcx>, - /// rustc does not have a proper way to represent the type of a field of a `repr(packed)` struct: - /// it needs to have a different alignment than the field type would usually have. - /// So we represent this here with a separate field that "overwrites" `layout.align`. - /// This means `layout.align` should never be used for a `MPlaceTy`! - pub align: Align, -} - -impl<'tcx, Prov: Provenance> std::ops::Deref for MPlaceTy<'tcx, Prov> { - type Target = MemPlace; - #[inline(always)] - fn deref(&self) -> &MemPlace { - &self.mplace - } -} - -#[derive(Copy, Clone, Debug)] -pub enum Place { - /// A place referring to a value allocated in the `Memory` system. - Ptr(MemPlace), - - /// To support alloc-free locals, we are able to write directly to a local. The offset indicates - /// where in the local this place is located; if it is `None`, no projection has been applied. - /// Such projections are meaningful even if the offset is 0, since they can change layouts. - /// (Without that optimization, we'd just always be a `MemPlace`.) - /// Note that this only stores the frame index, not the thread this frame belongs to -- that is - /// implicit. This means a `Place` must never be moved across interpreter thread boundaries! - /// - /// This variant shall not be used for unsized types -- those must always live in memory. - Local { frame: usize, local: mir::Local, offset: Option }, -} - -#[derive(Clone, Debug)] -pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> { - place: Place, // Keep this private; it helps enforce invariants. - pub layout: TyAndLayout<'tcx>, - /// rustc does not have a proper way to represent the type of a field of a `repr(packed)` struct: - /// it needs to have a different alignment than the field type would usually have. - /// So we represent this here with a separate field that "overwrites" `layout.align`. - /// This means `layout.align` should never be used for a `PlaceTy`! - pub align: Align, -} - -impl<'tcx, Prov: Provenance> std::ops::Deref for PlaceTy<'tcx, Prov> { - type Target = Place; - #[inline(always)] - fn deref(&self) -> &Place { - &self.place - } -} - -impl<'tcx, Prov: Provenance> From> for PlaceTy<'tcx, Prov> { - #[inline(always)] - fn from(mplace: MPlaceTy<'tcx, Prov>) -> Self { - PlaceTy { place: Place::Ptr(*mplace), layout: mplace.layout, align: mplace.align } - } -} - impl MemPlace { #[inline(always)] pub fn from_ptr(ptr: Pointer>) -> Self { @@ -165,6 +103,27 @@ impl MemPlace { } } +/// A MemPlace with its layout. Constructing it is only possible in this module. +#[derive(Clone, Hash, Eq, PartialEq)] +pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> { + mplace: MemPlace, + pub layout: TyAndLayout<'tcx>, + /// rustc does not have a proper way to represent the type of a field of a `repr(packed)` struct: + /// it needs to have a different alignment than the field type would usually have. + /// So we represent this here with a separate field that "overwrites" `layout.align`. + /// This means `layout.align` should never be used for a `MPlaceTy`! + pub align: Align, +} + +impl std::fmt::Debug for MPlaceTy<'_, Prov> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("MPlaceTy") + .field("mplace", &self.mplace) + .field("ty", &self.layout.ty) + .finish() + } +} + impl<'tcx, Prov: Provenance> MPlaceTy<'tcx, Prov> { /// Produces a MemPlace that works for ZST but nothing else. /// Conceptually this is a new allocation, but it doesn't actually create an allocation so you @@ -194,9 +153,29 @@ impl<'tcx, Prov: Provenance> MPlaceTy<'tcx, Prov> { align: layout.align.abi, } } + + /// Adjust the provenance of the main pointer (metadata is unaffected). + pub fn map_provenance(self, f: impl FnOnce(Option) -> Option) -> Self { + MPlaceTy { mplace: self.mplace.map_provenance(f), ..self } + } + + #[inline(always)] + pub(super) fn mplace(&self) -> &MemPlace { + &self.mplace + } + + #[inline(always)] + pub fn ptr(&self) -> Pointer> { + self.mplace.ptr + } + + #[inline(always)] + pub fn to_ref(&self, cx: &impl HasDataLayout) -> Immediate { + self.mplace.to_ref(cx) + } } -impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for MPlaceTy<'tcx, Prov> { +impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for MPlaceTy<'tcx, Prov> { #[inline(always)] fn layout(&self) -> TyAndLayout<'tcx> { self.layout @@ -204,7 +183,7 @@ impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for MPlaceTy<'tcx #[inline(always)] fn meta(&self) -> MemPlaceMeta { - self.meta + self.mplace.meta } fn offset_with_meta<'mir, M: Machine<'mir, 'tcx, Provenance = Prov>>( @@ -229,7 +208,76 @@ impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for MPlaceTy<'tcx } } -impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for PlaceTy<'tcx, Prov> { +#[derive(Copy, Clone, Debug)] +pub(super) enum Place { + /// A place referring to a value allocated in the `Memory` system. + Ptr(MemPlace), + + /// To support alloc-free locals, we are able to write directly to a local. The offset indicates + /// where in the local this place is located; if it is `None`, no projection has been applied. + /// Such projections are meaningful even if the offset is 0, since they can change layouts. + /// (Without that optimization, we'd just always be a `MemPlace`.) + /// Note that this only stores the frame index, not the thread this frame belongs to -- that is + /// implicit. This means a `Place` must never be moved across interpreter thread boundaries! + /// + /// This variant shall not be used for unsized types -- those must always live in memory. + Local { frame: usize, local: mir::Local, offset: Option }, +} + +#[derive(Clone)] +pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> { + place: Place, // Keep this private; it helps enforce invariants. + pub layout: TyAndLayout<'tcx>, + /// rustc does not have a proper way to represent the type of a field of a `repr(packed)` struct: + /// it needs to have a different alignment than the field type would usually have. + /// So we represent this here with a separate field that "overwrites" `layout.align`. + /// This means `layout.align` should never be used for a `PlaceTy`! + pub align: Align, +} + +impl std::fmt::Debug for PlaceTy<'_, Prov> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("PlaceTy").field("place", &self.place).field("ty", &self.layout.ty).finish() + } +} + +impl<'tcx, Prov: Provenance> From> for PlaceTy<'tcx, Prov> { + #[inline(always)] + fn from(mplace: MPlaceTy<'tcx, Prov>) -> Self { + PlaceTy { place: Place::Ptr(mplace.mplace), layout: mplace.layout, align: mplace.align } + } +} + +impl<'tcx, Prov: Provenance> PlaceTy<'tcx, Prov> { + #[inline(always)] + pub(super) fn place(&self) -> &Place { + &self.place + } + + /// A place is either an mplace or some local. + #[inline(always)] + pub fn as_mplace_or_local( + &self, + ) -> Either, (usize, mir::Local, Option)> { + match self.place { + Place::Ptr(mplace) => Left(MPlaceTy { mplace, layout: self.layout, align: self.align }), + Place::Local { frame, local, offset } => Right((frame, local, offset)), + } + } + + #[inline(always)] + #[cfg_attr(debug_assertions, track_caller)] // only in debug builds due to perf (see #98980) + pub fn assert_mem_place(&self) -> MPlaceTy<'tcx, Prov> { + self.as_mplace_or_local().left().unwrap_or_else(|| { + bug!( + "PlaceTy of type {} was a local when it was expected to be an MPlace", + self.layout.ty + ) + }) + } +} + +impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for PlaceTy<'tcx, Prov> { #[inline(always)] fn layout(&self) -> TyAndLayout<'tcx> { self.layout @@ -238,7 +286,7 @@ impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for PlaceTy<'tcx, #[inline] fn meta(&self) -> MemPlaceMeta { match self.as_mplace_or_local() { - Left(mplace) => mplace.meta, + Left(mplace) => mplace.meta(), Right(_) => { debug_assert!(self.layout.is_sized(), "unsized locals should live in memory"); MemPlaceMeta::None @@ -286,11 +334,11 @@ impl<'tcx, Prov: Provenance + 'static> Projectable<'tcx, Prov> for PlaceTy<'tcx, impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> { #[inline(always)] pub fn as_mplace_or_imm(&self) -> Either, ImmTy<'tcx, Prov>> { - match **self { + match self.op() { Operand::Indirect(mplace) => { - Left(MPlaceTy { mplace, layout: self.layout, align: self.align.unwrap() }) + Left(MPlaceTy { mplace: *mplace, layout: self.layout, align: self.align.unwrap() }) } - Operand::Immediate(imm) => Right(ImmTy::from_immediate(imm, self.layout)), + Operand::Immediate(imm) => Right(ImmTy::from_immediate(*imm, self.layout)), } } @@ -306,30 +354,7 @@ impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> { } } -impl<'tcx, Prov: Provenance + 'static> PlaceTy<'tcx, Prov> { - /// A place is either an mplace or some local. - #[inline(always)] - pub fn as_mplace_or_local( - &self, - ) -> Either, (usize, mir::Local, Option)> { - match **self { - Place::Ptr(mplace) => Left(MPlaceTy { mplace, layout: self.layout, align: self.align }), - Place::Local { frame, local, offset } => Right((frame, local, offset)), - } - } - - #[inline(always)] - #[cfg_attr(debug_assertions, track_caller)] // only in debug builds due to perf (see #98980) - pub fn assert_mem_place(&self) -> MPlaceTy<'tcx, Prov> { - self.as_mplace_or_local().left().unwrap_or_else(|| { - bug!( - "PlaceTy of type {} was a local when it was expected to be an MPlace", - self.layout.ty - ) - }) - } -} - +/// The `Weiteable` trait describes interpreter values that can be written to. pub trait Writeable<'tcx, Prov: Provenance>: Projectable<'tcx, Prov> { fn as_mplace_or_local( &self, @@ -341,7 +366,7 @@ pub trait Writeable<'tcx, Prov: Provenance>: Projectable<'tcx, Prov> { ) -> InterpResult<'tcx, MPlaceTy<'tcx, Prov>>; } -impl<'tcx, Prov: Provenance + 'static> Writeable<'tcx, Prov> for PlaceTy<'tcx, Prov> { +impl<'tcx, Prov: Provenance> Writeable<'tcx, Prov> for PlaceTy<'tcx, Prov> { #[inline(always)] fn as_mplace_or_local( &self, @@ -360,7 +385,7 @@ impl<'tcx, Prov: Provenance + 'static> Writeable<'tcx, Prov> for PlaceTy<'tcx, P } } -impl<'tcx, Prov: Provenance + 'static> Writeable<'tcx, Prov> for MPlaceTy<'tcx, Prov> { +impl<'tcx, Prov: Provenance> Writeable<'tcx, Prov> for MPlaceTy<'tcx, Prov> { #[inline(always)] fn as_mplace_or_local( &self, @@ -381,7 +406,7 @@ impl<'tcx, Prov: Provenance + 'static> Writeable<'tcx, Prov> for MPlaceTy<'tcx, // FIXME: Working around https://github.com/rust-lang/rust/issues/54385 impl<'mir, 'tcx: 'mir, Prov, M> InterpCx<'mir, 'tcx, M> where - Prov: Provenance + 'static, + Prov: Provenance, M: Machine<'mir, 'tcx, Provenance = Prov>, { /// Take a value, which represents a (thin or wide) reference, and make it a place. @@ -415,7 +440,7 @@ where &self, mplace: &MPlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> { - let imm = mplace.to_ref(self); + let imm = mplace.mplace.to_ref(self); let layout = self.layout_of(Ty::new_mut_ptr(self.tcx.tcx, mplace.layout.ty))?; Ok(ImmTy::from_immediate(imm, layout)) } @@ -449,7 +474,7 @@ where .size_and_align_of_mplace(&mplace)? .unwrap_or((mplace.layout.size, mplace.layout.align.abi)); // Due to packed places, only `mplace.align` matters. - self.get_ptr_alloc(mplace.ptr, size, mplace.align) + self.get_ptr_alloc(mplace.ptr(), size, mplace.align) } #[inline] @@ -462,7 +487,7 @@ where .size_and_align_of_mplace(&mplace)? .unwrap_or((mplace.layout.size, mplace.layout.align.abi)); // Due to packed places, only `mplace.align` matters. - self.get_ptr_alloc_mut(mplace.ptr, size, mplace.align) + self.get_ptr_alloc_mut(mplace.ptr(), size, mplace.align) } /// Check if this mplace is dereferenceable and sufficiently aligned. @@ -473,7 +498,7 @@ where // Due to packed places, only `mplace.align` matters. let align = if M::enforce_alignment(self).should_check() { mplace.align } else { Align::ONE }; - self.check_ptr_access_align(mplace.ptr, size, align, CheckInAllocMsg::DerefTest)?; + self.check_ptr_access_align(mplace.ptr(), size, align, CheckInAllocMsg::DerefTest)?; Ok(()) } @@ -542,7 +567,7 @@ where place = self.project(&place, elem)? } - trace!("{:?}", self.dump_place(place.place)); + trace!("{:?}", self.dump_place(&place)); // Sanity-check the type we ended up with. debug_assert!( mir_assign_valid_types( @@ -618,7 +643,8 @@ where // just fall back to the indirect path. dest.force_mplace(self)? } else { - match M::access_local_mut(self, frame, local)? { + M::before_access_local_mut(self, frame, local)?; + match self.stack_mut()[frame].locals[local].access_mut()? { Operand::Immediate(local_val) => { // Local can be updated in-place. *local_val = src; @@ -738,7 +764,8 @@ where // FIXME: share the logic with `write_immediate_no_validate`. dest.force_mplace(self)? } else { - match M::access_local_mut(self, frame, local)? { + M::before_access_local_mut(self, frame, local)?; + match self.stack_mut()[frame].locals[local].access_mut()? { Operand::Immediate(local) => { *local = Immediate::Uninit; return Ok(()); @@ -832,7 +859,7 @@ where *src_val, src.layout(), dest_mem.align, - *dest_mem, + dest_mem.mplace, ) }; } @@ -859,7 +886,12 @@ where // (Or as the `Assign` docs put it, assignments "not producing primitives" must be // non-overlapping.) self.mem_copy( - src.ptr, src.align, dest.ptr, dest.align, dest_size, /*nonoverlapping*/ true, + src.ptr(), + src.align, + dest.ptr(), + dest.align, + dest_size, + /*nonoverlapping*/ true, ) } @@ -874,7 +906,8 @@ where ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> { let mplace = match place.place { Place::Local { frame, local, offset } => { - let whole_local = match M::access_local_mut(self, frame, local)? { + M::before_access_local_mut(self, frame, local)?; + let whole_local = match self.stack_mut()[frame].locals[local].access_mut()? { &mut Operand::Immediate(local_val) => { // We need to make an allocation. @@ -894,16 +927,16 @@ where local_val, local_layout, local_layout.align.abi, - *mplace, + mplace.mplace, )?; } M::after_local_allocated(self, frame, local, &mplace)?; // Now we can call `access_mut` again, asserting it goes well, and actually // overwrite things. This points to the entire allocation, not just the part // the place refers to, i.e. we do this before we apply `offset`. - *M::access_local_mut(self, frame, local).unwrap() = - Operand::Indirect(*mplace); - *mplace + *self.stack_mut()[frame].locals[local].access_mut().unwrap() = + Operand::Indirect(mplace.mplace); + mplace.mplace } &mut Operand::Indirect(mplace) => mplace, // this already was an indirect local }; @@ -1011,12 +1044,12 @@ where matches!(mplace.layout.ty.kind(), ty::Dynamic(_, _, ty::Dyn)), "`unpack_dyn_trait` only makes sense on `dyn*` types" ); - let vtable = mplace.meta.unwrap_meta().to_pointer(self)?; + let vtable = mplace.meta().unwrap_meta().to_pointer(self)?; let (ty, _) = self.get_ptr_vtable(vtable)?; let layout = self.layout_of(ty)?; let mplace = MPlaceTy { - mplace: MemPlace { meta: MemPlaceMeta::None, ..**mplace }, + mplace: MemPlace { meta: MemPlaceMeta::None, ..mplace.mplace }, layout, align: layout.align.abi, }; diff --git a/compiler/rustc_const_eval/src/interpret/projection.rs b/compiler/rustc_const_eval/src/interpret/projection.rs index c69321d109e49..6c720ac4a574d 100644 --- a/compiler/rustc_const_eval/src/interpret/projection.rs +++ b/compiler/rustc_const_eval/src/interpret/projection.rs @@ -89,7 +89,7 @@ pub trait Projectable<'tcx, Prov: Provenance>: Sized + std::fmt::Debug { } /// A type representing iteration over the elements of an array. -pub struct ArrayIterator<'tcx, 'a, Prov: Provenance + 'static, P: Projectable<'tcx, Prov>> { +pub struct ArrayIterator<'tcx, 'a, Prov: Provenance, P: Projectable<'tcx, Prov>> { base: &'a P, range: Range, stride: Size, @@ -97,9 +97,7 @@ pub struct ArrayIterator<'tcx, 'a, Prov: Provenance + 'static, P: Projectable<'t _phantom: PhantomData, // otherwise it says `Prov` is never used... } -impl<'tcx, 'a, Prov: Provenance + 'static, P: Projectable<'tcx, Prov>> - ArrayIterator<'tcx, 'a, Prov, P> -{ +impl<'tcx, 'a, Prov: Provenance, P: Projectable<'tcx, Prov>> ArrayIterator<'tcx, 'a, Prov, P> { /// Should be the same `ecx` on each call, and match the one used to create the iterator. pub fn next<'mir, M: Machine<'mir, 'tcx, Provenance = Prov>>( &mut self, @@ -113,7 +111,7 @@ impl<'tcx, 'a, Prov: Provenance + 'static, P: Projectable<'tcx, Prov>> // FIXME: Working around https://github.com/rust-lang/rust/issues/54385 impl<'mir, 'tcx: 'mir, Prov, M> InterpCx<'mir, 'tcx, M> where - Prov: Provenance + 'static, + Prov: Provenance, M: Machine<'mir, 'tcx, Provenance = Prov>, { /// Offset a pointer to project to a field of a struct/union. Unlike `place_field`, this is diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 0740894a4ffa6..57f99bd8f617e 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -204,7 +204,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // avoid writing each operand individually and instead just make many copies // of the first element. let elem_size = first.layout.size; - let first_ptr = first.ptr; + let first_ptr = first.ptr(); let rest_ptr = first_ptr.offset(elem_size, self)?; // For the alignment of `rest_ptr`, we crucially do *not* use `first.align` as // that place might be more aligned than its type mandates (a `u8` array could @@ -305,7 +305,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } - trace!("{:?}", self.dump_place(*dest)); + trace!("{:?}", self.dump_place(&dest)); Ok(()) } diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index ca66c4cfb6312..bc4edf1c4b60b 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -793,7 +793,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { throw_ub_custom!(fluent::const_eval_dyn_star_call_vtable_mismatch); } - (vptr, dyn_ty, recv.ptr) + (vptr, dyn_ty, recv.ptr()) } else { // Doesn't have to be a `dyn Trait`, but the unsized tail must be `dyn Trait`. // (For that reason we also cannot use `unpack_dyn_trait`.) @@ -810,7 +810,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { assert!(receiver_place.layout.is_unsized()); // Get the required information from the vtable. - let vptr = receiver_place.meta.unwrap_meta().to_pointer(self)?; + let vptr = receiver_place.meta().unwrap_meta().to_pointer(self)?; let (dyn_ty, dyn_trait) = self.get_ptr_vtable(vptr)?; if dyn_trait != data.principal() { throw_ub_custom!(fluent::const_eval_dyn_call_vtable_mismatch); @@ -819,7 +819,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // It might be surprising that we use a pointer as the receiver even if this // is a by-val case; this works because by-val passing of an unsized `dyn // Trait` to a function is actually desugared to a pointer. - (vptr, dyn_ty, receiver_place.ptr) + (vptr, dyn_ty, receiver_place.ptr()) }; // Now determine the actual method to call. We can do that in two different ways and diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 0d08d6be91944..8e2b35fd5b619 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -360,7 +360,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' // Handle wide pointers. // Check metadata early, for better diagnostics if place.layout.is_unsized() { - self.check_wide_ptr_meta(place.meta, place.layout)?; + self.check_wide_ptr_meta(place.meta(), place.layout)?; } // Make sure this is dereferenceable and all. let size_and_align = try_validation!( @@ -379,7 +379,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' // Direct call to `check_ptr_access_align` checks alignment even on CTFE machines. try_validation!( self.ecx.check_ptr_access_align( - place.ptr, + place.ptr(), size, align, CheckInAllocMsg::InboundsTest, // will anyway be replaced by validity message @@ -414,7 +414,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' if let Some(ref_tracking) = self.ref_tracking.as_deref_mut() { // Proceed recursively even for ZST, no reason to skip them! // `!` is a ZST and we want to validate it. - if let Ok((alloc_id, _offset, _prov)) = self.ecx.ptr_try_get_alloc_id(place.ptr) { + if let Ok((alloc_id, _offset, _prov)) = self.ecx.ptr_try_get_alloc_id(place.ptr()) { // Let's see what kind of memory this points to. let alloc_kind = self.ecx.tcx.try_get_global_alloc(alloc_id); match alloc_kind { @@ -521,7 +521,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' let place = self.ecx.ref_to_mplace(&self.read_immediate(value, ExpectedKind::RawPtr)?)?; if place.layout.is_unsized() { - self.check_wide_ptr_meta(place.meta, place.layout)?; + self.check_wide_ptr_meta(place.meta(), place.layout)?; } Ok(true) } @@ -739,7 +739,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> let mplace = op.assert_mem_place(); // strings are unsized and hence never immediate let len = mplace.len(self.ecx)?; try_validation!( - self.ecx.read_bytes_ptr_strip_provenance(mplace.ptr, Size::from_bytes(len)), + self.ecx.read_bytes_ptr_strip_provenance(mplace.ptr(), Size::from_bytes(len)), self.path, Ub(InvalidUninitBytes(..)) => Uninit { expected: ExpectedKind::Str }, Unsup(ReadPointerAsInt(_)) => PointerAsInt { expected: ExpectedKind::Str } @@ -789,7 +789,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> // to reject those pointers, we just do not have the machinery to // talk about parts of a pointer. // We also accept uninit, for consistency with the slow path. - let alloc = self.ecx.get_ptr_alloc(mplace.ptr, size, mplace.align)?.expect("we already excluded size 0"); + let alloc = self.ecx.get_ptr_alloc(mplace.ptr(), size, mplace.align)?.expect("we already excluded size 0"); match alloc.get_bytes_strip_provenance() { // In the happy case, we needn't check anything else. diff --git a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs index 2d1970791cacd..e9e0690f07df1 100644 --- a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs +++ b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs @@ -54,7 +54,7 @@ fn might_permit_raw_init_strict<'tcx>( if kind == ValidityRequirement::Zero { cx.write_bytes_ptr( - allocated.ptr, + allocated.ptr(), std::iter::repeat(0_u8).take(ty.layout.size().bytes_usize()), ) .expect("failed to write bytes for zero valid check"); diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index 65d04919357f3..1c9ce1cb1308c 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -103,7 +103,7 @@ impl PointerArithmetic for T {} /// mostly opaque; the `Machine` trait extends it with some more operations that also have access to /// some global state. /// The `Debug` rendering is used to display bare provenance, and for the default impl of `fmt`. -pub trait Provenance: Copy + fmt::Debug { +pub trait Provenance: Copy + fmt::Debug + 'static { /// Says whether the `offset` field of `Pointer`s with this provenance is the actual physical address. /// - If `false`, the offset *must* be relative. This means the bytes representing a pointer are /// different from what the Abstract Machine prescribes, so the interpreter must prevent any diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index 0aaa3f75c8268..5f135e96980f1 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -22,8 +22,7 @@ use rustc_target::spec::abi::Abi as CallAbi; use crate::MirPass; use rustc_const_eval::interpret::{ self, compile_time_machine, AllocId, ConstAllocation, ConstValue, FnArg, Frame, ImmTy, - Immediate, InterpCx, InterpResult, LocalValue, MemoryKind, OpTy, PlaceTy, Pointer, Scalar, - StackPopCleanup, + Immediate, InterpCx, InterpResult, MemoryKind, OpTy, PlaceTy, Pointer, Scalar, StackPopCleanup, }; /// The maximum number of bytes that we'll allocate space for a local or the return value. @@ -225,11 +224,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> throw_machine_stop_str!("pointer arithmetic or comparisons aren't supported in ConstProp") } - fn access_local_mut<'a>( + fn before_access_local_mut<'a>( ecx: &'a mut InterpCx<'mir, 'tcx, Self>, frame: usize, local: Local, - ) -> InterpResult<'tcx, &'a mut interpret::Operand> { + ) -> InterpResult<'tcx> { assert_eq!(frame, 0); match ecx.machine.can_const_prop[local] { ConstPropMode::NoPropagation => { @@ -242,7 +241,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> } ConstPropMode::FullConstProp => {} } - ecx.machine.stack[frame].locals[local].access_mut() + Ok(()) } fn before_access_global( @@ -382,8 +381,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { // mark those as live... We rely on `local_to_place`/`local_to_op` in the interpreter // stopping us before those unsized immediates can cause issues deeper in the // interpreter. - ecx.frame_mut().locals[local].value = - LocalValue::Live(interpret::Operand::Immediate(Immediate::Uninit)); + ecx.frame_mut().locals[local].make_live_uninit(); } ConstPropagator { ecx, tcx, param_env, local_decls: &dummy_body.local_decls } @@ -392,7 +390,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { fn get_const(&self, place: Place<'tcx>) -> Option> { let op = match self.ecx.eval_place_to_op(place, None) { Ok(op) => { - if matches!(*op, interpret::Operand::Immediate(Immediate::Uninit)) { + if op + .as_mplace_or_imm() + .right() + .is_some_and(|imm| matches!(*imm, Immediate::Uninit)) + { // Make sure nobody accidentally uses this value. return None; } @@ -415,8 +417,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { /// Remove `local` from the pool of `Locals`. Allows writing to them, /// but not reading from them anymore. fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, local: Local) { - ecx.frame_mut().locals[local].value = - LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit)); + ecx.frame_mut().locals[local].make_live_uninit(); ecx.machine.written_only_inside_own_block_locals.remove(&local); } @@ -743,7 +744,8 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> { ) -> Option> { if let PlaceElem::Index(local) = elem && let Some(value) = self.get_const(local.into()) - && let interpret::Operand::Immediate(Immediate::Scalar(scalar)) = *value + && let Some(imm) = value.as_mplace_or_imm().right() + && let Immediate::Scalar(scalar) = *imm && let Ok(offset) = scalar.to_target_usize(&self.tcx) && let Some(min_length) = offset.checked_add(1) { diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index dec79ddf58cf8..4b51beed09558 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -7,7 +7,7 @@ use either::Left; use rustc_const_eval::interpret::Immediate; use rustc_const_eval::interpret::{ - self, InterpCx, InterpResult, LocalValue, MemoryKind, OpTy, Scalar, StackPopCleanup, + InterpCx, InterpResult, MemoryKind, OpTy, Scalar, StackPopCleanup, }; use rustc_const_eval::ReportErrorExt; use rustc_hir::def::DefKind; @@ -212,8 +212,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { // mark those as live... We rely on `local_to_place`/`local_to_op` in the interpreter // stopping us before those unsized immediates can cause issues deeper in the // interpreter. - ecx.frame_mut().locals[local].value = - LocalValue::Live(interpret::Operand::Immediate(Immediate::Uninit)); + ecx.frame_mut().locals[local].make_live_uninit(); } ConstPropagator { @@ -236,7 +235,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { fn get_const(&self, place: Place<'tcx>) -> Option> { let op = match self.ecx.eval_place_to_op(place, None) { Ok(op) => { - if matches!(*op, interpret::Operand::Immediate(Immediate::Uninit)) { + if op + .as_mplace_or_imm() + .right() + .is_some_and(|imm| matches!(*imm, Immediate::Uninit)) + { // Make sure nobody accidentally uses this value. return None; } @@ -259,8 +262,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { /// Remove `local` from the pool of `Locals`. Allows writing to them, /// but not reading from them anymore. fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, local: Local) { - ecx.frame_mut().locals[local].value = - LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit)); + ecx.frame_mut().locals[local].make_live_uninit(); ecx.machine.written_only_inside_own_block_locals.remove(&local); } @@ -656,12 +658,12 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> { } StatementKind::StorageLive(local) => { let frame = self.ecx.frame_mut(); - frame.locals[local].value = - LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit)); + frame.locals[local].make_live_uninit(); } StatementKind::StorageDead(local) => { let frame = self.ecx.frame_mut(); - frame.locals[local].value = LocalValue::Dead; + // We don't actually track liveness, so the local remains live. But forget its value. + frame.locals[local].make_live_uninit(); } _ => {} } diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index 0351f586872eb..a54bd32cd4097 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -615,7 +615,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' ) -> InterpResult<'tcx, Option> { let this = self.eval_context_mut(); // Ensure we bail out if the pointer goes out-of-bounds (see miri#1050). - this.check_ptr_access_align(place.ptr, size, Align::ONE, CheckInAllocMsg::InboundsTest)?; + this.check_ptr_access_align(place.ptr(), size, Align::ONE, CheckInAllocMsg::InboundsTest)?; // It is crucial that this gets called on all code paths, to ensure we track tag creation. let log_creation = |this: &MiriInterpCx<'mir, 'tcx>, @@ -682,7 +682,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' trace!( "reborrow of size 0: reference {:?} derived from {:?} (pointee {})", new_tag, - place.ptr, + place.ptr(), place.layout.ty, ); // Don't update any stacks for a zero-sized access; borrow stacks are per-byte and this @@ -692,7 +692,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' // attempt to use it for a non-zero-sized access. // Dangling slices are a common case here; it's valid to get their length but with raw // pointer tagging for example all calls to get_unchecked on them are invalid. - if let Ok((alloc_id, base_offset, orig_tag)) = this.ptr_try_get_alloc_id(place.ptr) { + if let Ok((alloc_id, base_offset, orig_tag)) = this.ptr_try_get_alloc_id(place.ptr()) { log_creation(this, Some((alloc_id, base_offset, orig_tag)))?; // Still give it the new provenance, it got retagged after all. return Ok(Some(Provenance::Concrete { alloc_id, tag: new_tag })); @@ -700,11 +700,11 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' // This pointer doesn't come with an AllocId. :shrug: log_creation(this, None)?; // Provenance unchanged. - return Ok(place.ptr.provenance); + return Ok(place.ptr().provenance); } } - let (alloc_id, base_offset, orig_tag) = this.ptr_get_alloc_id(place.ptr)?; + let (alloc_id, base_offset, orig_tag) = this.ptr_get_alloc_id(place.ptr())?; log_creation(this, Some((alloc_id, base_offset, orig_tag)))?; trace!( diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs index 08b138c68aec8..8dd925a0ad80a 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs @@ -172,7 +172,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' let this = self.eval_context_mut(); // Ensure we bail out if the pointer goes out-of-bounds (see miri#1050). this.check_ptr_access_align( - place.ptr, + place.ptr(), ptr_size, Align::ONE, CheckInAllocMsg::InboundsTest, @@ -197,7 +197,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' }; trace!("Reborrow of size {:?}", ptr_size); - let (alloc_id, base_offset, parent_prov) = match this.ptr_try_get_alloc_id(place.ptr) { + let (alloc_id, base_offset, parent_prov) = match this.ptr_try_get_alloc_id(place.ptr()) { Ok(data) => { // Unlike SB, we *do* a proper retag for size 0 if can identify the allocation. // After all, the pointer may be lazily initialized outside this initial range. @@ -210,18 +210,18 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<' trace!( "reborrow of size 0: reference {:?} derived from {:?} (pointee {})", new_tag, - place.ptr, + place.ptr(), place.layout.ty, ); log_creation(this, None)?; // Keep original provenance. - return Ok(place.ptr.provenance); + return Ok(place.ptr().provenance); } }; log_creation(this, Some((alloc_id, base_offset, parent_prov)))?; let orig_tag = match parent_prov { - ProvenanceExtra::Wildcard => return Ok(place.ptr.provenance), // TODO: handle wildcard pointers + ProvenanceExtra::Wildcard => return Ok(place.ptr().provenance), // TODO: handle wildcard pointers ProvenanceExtra::Concrete(tag) => tag, }; diff --git a/src/tools/miri/src/concurrency/data_race.rs b/src/tools/miri/src/concurrency/data_race.rs index 37125337d6f0e..513cec1f6c374 100644 --- a/src/tools/miri/src/concurrency/data_race.rs +++ b/src/tools/miri/src/concurrency/data_race.rs @@ -1018,7 +1018,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { // be 8-aligned). let align = Align::from_bytes(place.layout.size.bytes()).unwrap(); this.check_ptr_access_align( - place.ptr, + place.ptr(), place.layout.size, align, CheckInAllocMsg::MemoryAccessTest, @@ -1031,7 +1031,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { // We avoid `get_ptr_alloc` since we do *not* want to run the access hooks -- the actual // access will happen later. let (alloc_id, _offset, _prov) = - this.ptr_try_get_alloc_id(place.ptr).expect("there are no zero-sized atomic accesses"); + this.ptr_try_get_alloc_id(place.ptr()).expect("there are no zero-sized atomic accesses"); if this.get_alloc_mutability(alloc_id)? == Mutability::Not { // FIXME: make this prettier, once these messages have separate title/span/help messages. throw_ub_format!( @@ -1135,7 +1135,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { if let Some(data_race) = &this.machine.data_race { if data_race.race_detecting() { let size = place.layout.size; - let (alloc_id, base_offset, _prov) = this.ptr_get_alloc_id(place.ptr)?; + let (alloc_id, base_offset, _prov) = this.ptr_get_alloc_id(place.ptr())?; // Load and log the atomic operation. // Note that atomic loads are possible even from read-only allocations, so `get_alloc_extra_mut` is not an option. let alloc_meta = this.get_alloc_extra(alloc_id)?.data_race.as_ref().unwrap(); @@ -1143,7 +1143,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { "Atomic op({}) with ordering {:?} on {:?} (size={})", description, &atomic, - place.ptr, + place.ptr(), size.bytes() ); @@ -1186,7 +1186,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { { log::trace!( "Updated atomic memory({:?}, size={}) to {:#?}", - place.ptr, + place.ptr(), size.bytes(), mem_clocks.atomic_ops ); diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 9c11ad85aefd3..295d86fd24021 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -8,6 +8,7 @@ use std::task::Poll; use std::time::{Duration, SystemTime}; use log::trace; +use either::Either; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; @@ -259,8 +260,15 @@ impl VisitTags for Frame<'_, '_, Provenance, FrameExtra<'_>> { return_place.visit_tags(visit); // Locals. for local in locals.iter() { - if let LocalValue::Live(value) = &local.value { - value.visit_tags(visit); + match local.as_mplace_or_imm() { + None => {} + Some(Either::Left((ptr, meta))) => { + ptr.visit_tags(visit); + meta.visit_tags(visit); + } + Some(Either::Right(imm)) => { + imm.visit_tags(visit); + } } } diff --git a/src/tools/miri/src/concurrency/weak_memory.rs b/src/tools/miri/src/concurrency/weak_memory.rs index c1395468fee2e..6781b1f6dd382 100644 --- a/src/tools/miri/src/concurrency/weak_memory.rs +++ b/src/tools/miri/src/concurrency/weak_memory.rs @@ -481,7 +481,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>: place: &MPlaceTy<'tcx, Provenance>, ) -> InterpResult<'tcx> { let this = self.eval_context_ref(); - let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?; + let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr())?; if let crate::AllocExtra { weak_memory: Some(alloc_buffers), data_race: Some(alloc_clocks), @@ -512,7 +512,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>: init: Scalar, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?; + let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr())?; if let ( crate::AllocExtra { weak_memory: Some(alloc_buffers), .. }, crate::MiriMachine { data_race: Some(global), threads, .. }, @@ -539,7 +539,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>: ) -> InterpResult<'tcx, Scalar> { let this = self.eval_context_ref(); if let Some(global) = &this.machine.data_race { - let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?; + let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr())?; if let Some(alloc_buffers) = this.get_alloc_extra(alloc_id)?.weak_memory.as_ref() { if atomic == AtomicReadOrd::SeqCst { global.sc_read(&this.machine.threads); @@ -577,7 +577,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>: init: Scalar, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(dest.ptr)?; + let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(dest.ptr())?; if let ( crate::AllocExtra { weak_memory: Some(alloc_buffers), .. }, crate::MiriMachine { data_race: Some(global), threads, .. }, @@ -627,7 +627,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>: global.sc_read(&this.machine.threads); } let size = place.layout.size; - let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr)?; + let (alloc_id, base_offset, ..) = this.ptr_get_alloc_id(place.ptr())?; if let Some(alloc_buffers) = this.get_alloc_extra(alloc_id)?.weak_memory.as_ref() { let buffer = alloc_buffers .get_or_create_store_buffer(alloc_range(base_offset, size), init)?; diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index 298c53675229b..4f249acda1df1 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -376,9 +376,9 @@ pub fn report_error<'tcx, 'mir>( for (i, frame) in ecx.active_thread_stack().iter().enumerate() { trace!("-------------------"); trace!("Frame {}", i); - trace!(" return: {:?}", *frame.return_place); + trace!(" return: {:?}", frame.return_place); for (i, local) in frame.locals.iter().enumerate() { - trace!(" local {}: {:?}", i, local.value); + trace!(" local {}: {:?}", i, local); } } diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index 88e7d5386db79..beb13ebdfe6fd 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -242,10 +242,7 @@ impl MainThreadState { }, Done => { // Figure out exit code. - let ret_place = MPlaceTy::from_aligned_ptr( - this.machine.main_fn_ret_place.unwrap().ptr, - this.machine.layouts.isize, - ); + let ret_place = this.machine.main_fn_ret_place.clone().unwrap(); let exit_code = this.read_target_isize(&ret_place)?; // Need to call this ourselves since we are not going to return to the scheduler // loop, and we want the main thread TLS to not show up as memory leaks. @@ -308,7 +305,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( let arg_type = Ty::new_array(tcx, tcx.types.u8, size); let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Machine.into())?; - ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?; + ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr(), size)?; ecx.mark_immutable(&arg_place); argvs.push(arg_place.to_ref(&ecx)); } @@ -332,7 +329,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( ecx.allocate(ecx.machine.layouts.isize, MiriMemoryKind::Machine.into())?; ecx.write_scalar(argc, &argc_place)?; ecx.mark_immutable(&argc_place); - ecx.machine.argc = Some(*argc_place); + ecx.machine.argc = Some(argc_place.ptr()); let argv_place = ecx.allocate( ecx.layout_of(Ty::new_imm_ptr(tcx, tcx.types.unit))?, @@ -340,7 +337,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( )?; ecx.write_immediate(argv, &argv_place)?; ecx.mark_immutable(&argv_place); - ecx.machine.argv = Some(*argv_place); + ecx.machine.argv = Some(argv_place.ptr()); } // Store command line as UTF-16 for Windows `GetCommandLineW`. { @@ -351,7 +348,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( Ty::new_array(tcx, tcx.types.u16, u64::try_from(cmd_utf16.len()).unwrap()); let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Machine.into())?; - ecx.machine.cmd_line = Some(*cmd_place); + ecx.machine.cmd_line = Some(cmd_place.ptr()); // Store the UTF-16 string. We just allocated so we know the bounds are fine. for (idx, &c) in cmd_utf16.iter().enumerate() { let place = ecx.project_field(&cmd_place, idx)?; @@ -364,7 +361,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( // Return place (in static memory so that it does not count as leak). let ret_place = ecx.allocate(ecx.machine.layouts.isize, MiriMemoryKind::Machine.into())?; - ecx.machine.main_fn_ret_place = Some(*ret_place); + ecx.machine.main_fn_ret_place = Some(ret_place.clone()); // Call start function. match entry_type { diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 844827889a7b2..0c7e82781476d 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -381,7 +381,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // Store how far we proceeded into the place so far. Everything to the left of // this offset has already been handled, in the sense that the frozen parts // have had `action` called on them. - let start_addr = place.ptr.addr(); + let start_addr = place.ptr().addr(); let mut cur_addr = start_addr; // Called when we detected an `UnsafeCell` at the given offset and size. // Calls `action` and advances `cur_ptr`. @@ -413,7 +413,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let mut visitor = UnsafeCellVisitor { ecx: this, unsafe_cell_action: |place| { - trace!("unsafe_cell_action on {:?}", place.ptr); + trace!("unsafe_cell_action on {:?}", place.ptr()); // We need a size to go on. let unsafe_cell_size = this .size_and_align_of_mplace(place)? @@ -422,7 +422,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { .unwrap_or_else(|| place.layout.size); // Now handle this `UnsafeCell`, unless it is empty. if unsafe_cell_size != Size::ZERO { - unsafe_cell_action(&place.ptr, unsafe_cell_size) + unsafe_cell_action(&place.ptr(), unsafe_cell_size) } else { Ok(()) } @@ -432,7 +432,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } // The part between the end_ptr and the end of the place is also frozen. // So pretend there is a 0-sized `UnsafeCell` at the end. - unsafe_cell_action(&place.ptr.offset(size, this)?, Size::ZERO)?; + unsafe_cell_action(&place.ptr().offset(size, this)?, Size::ZERO)?; // Done! return Ok(()); @@ -994,10 +994,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } /// Mark a machine allocation that was just created as immutable. - fn mark_immutable(&mut self, mplace: &MemPlace) { + fn mark_immutable(&mut self, mplace: &MPlaceTy<'tcx, Provenance>) { let this = self.eval_context_mut(); // This got just allocated, so there definitely is a pointer here. - let provenance = mplace.ptr.into_pointer_or_addr().unwrap().provenance; + let provenance = mplace.ptr().into_pointer_or_addr().unwrap().provenance; this.alloc_mark_immutable(provenance.get_alloc_id().unwrap()).unwrap(); } diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 9d01a04bf4adb..80f8318044802 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -396,14 +396,14 @@ pub struct MiriMachine<'mir, 'tcx> { pub(crate) env_vars: EnvVars<'tcx>, /// Return place of the main function. - pub(crate) main_fn_ret_place: Option>, + pub(crate) main_fn_ret_place: Option>, /// Program arguments (`Option` because we can only initialize them after creating the ecx). /// These are *pointers* to argc/argv because macOS. /// We also need the full command line as one string because of Windows. - pub(crate) argc: Option>, - pub(crate) argv: Option>, - pub(crate) cmd_line: Option>, + pub(crate) argc: Option>>, + pub(crate) argv: Option>>, + pub(crate) cmd_line: Option>>, /// TLS state. pub(crate) tls: TlsData<'tcx>, @@ -670,7 +670,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { ) -> InterpResult<'tcx> { let place = this.allocate(val.layout, MiriMemoryKind::ExternStatic.into())?; this.write_immediate(*val, &place)?; - Self::add_extern_static(this, name, place.ptr); + Self::add_extern_static(this, name, place.ptr()); Ok(()) } @@ -686,7 +686,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { Self::add_extern_static( this, "environ", - this.machine.env_vars.environ.as_ref().unwrap().ptr, + this.machine.env_vars.environ.as_ref().unwrap().ptr(), ); // A couple zero-initialized pointer-sized extern statics. // Most of them are for weak symbols, which we all set to null (indicating that the @@ -703,7 +703,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { Self::add_extern_static( this, "environ", - this.machine.env_vars.environ.as_ref().unwrap().ptr, + this.machine.env_vars.environ.as_ref().unwrap().ptr(), ); } "android" => { @@ -1415,7 +1415,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { local: mir::Local, mplace: &MPlaceTy<'tcx, Provenance>, ) -> InterpResult<'tcx> { - let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr.provenance else { + let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr().provenance else { panic!("after_local_allocated should only be called on fresh allocations"); }; let local_decl = &ecx.active_thread_stack()[frame].body.local_decls[local]; diff --git a/src/tools/miri/src/shims/backtrace.rs b/src/tools/miri/src/shims/backtrace.rs index a3297bf819f0a..c4c9f77fab7f9 100644 --- a/src/tools/miri/src/shims/backtrace.rs +++ b/src/tools/miri/src/shims/backtrace.rs @@ -89,7 +89,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } this.write_immediate( - Immediate::new_slice(Scalar::from_maybe_pointer(alloc.ptr, this), len, this), + Immediate::new_slice(Scalar::from_maybe_pointer(alloc.ptr(), this), len, this), dest, )?; } diff --git a/src/tools/miri/src/shims/env.rs b/src/tools/miri/src/shims/env.rs index 3694ea51da6c6..154a7f6983343 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -459,7 +459,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let place = this.project_field(&vars_place, idx)?; this.write_pointer(var, &place)?; } - this.write_pointer(vars_place.ptr, &this.machine.env_vars.environ.clone().unwrap())?; + this.write_pointer(vars_place.ptr(), &this.machine.env_vars.environ.clone().unwrap())?; Ok(()) } diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 7996e72615f0e..47cbd4419f3dc 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -324,7 +324,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // Second: functions that return immediately. match this.emulate_foreign_item_by_name(link_name, abi, args, dest)? { EmulateByNameResult::NeedsJumping => { - trace!("{:?}", this.dump_place(**dest)); + trace!("{:?}", this.dump_place(dest)); this.go_to_block(ret); } EmulateByNameResult::AlreadyJumped => (), diff --git a/src/tools/miri/src/shims/intrinsics/mod.rs b/src/tools/miri/src/shims/intrinsics/mod.rs index 8a84b4f51b7f2..ef9d071044818 100644 --- a/src/tools/miri/src/shims/intrinsics/mod.rs +++ b/src/tools/miri/src/shims/intrinsics/mod.rs @@ -62,7 +62,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // The rest jumps to `ret` immediately. this.emulate_intrinsic_by_name(intrinsic_name, args, dest)?; - trace!("{:?}", this.dump_place(**dest)); + trace!("{:?}", this.dump_place(dest)); this.go_to_block(ret); Ok(()) } diff --git a/src/tools/miri/src/shims/os_str.rs b/src/tools/miri/src/shims/os_str.rs index a94b1ddcd95b9..f6e76545a4d8d 100644 --- a/src/tools/miri/src/shims/os_str.rs +++ b/src/tools/miri/src/shims/os_str.rs @@ -143,9 +143,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let arg_type = Ty::new_array(this.tcx.tcx, this.tcx.types.u8, size); let arg_place = this.allocate(this.layout_of(arg_type).unwrap(), memkind)?; - let (written, _) = self.write_os_str_to_c_str(os_str, arg_place.ptr, size).unwrap(); + let (written, _) = self.write_os_str_to_c_str(os_str, arg_place.ptr(), size).unwrap(); assert!(written); - Ok(arg_place.ptr) + Ok(arg_place.ptr()) } /// Allocate enough memory to store the given `OsStr` as a null-terminated sequence of `u16`. @@ -160,9 +160,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let arg_type = Ty::new_array(this.tcx.tcx, this.tcx.types.u16, size); let arg_place = this.allocate(this.layout_of(arg_type).unwrap(), memkind)?; let (written, _) = - self.write_os_str_to_wide_str(os_str, arg_place.ptr, size, /*truncate*/ false).unwrap(); + self.write_os_str_to_wide_str(os_str, arg_place.ptr(), size, /*truncate*/ false).unwrap(); assert!(written); - Ok(arg_place.ptr) + Ok(arg_place.ptr()) } /// Read a null-terminated sequence of bytes, and perform path separator conversion if needed. diff --git a/src/tools/miri/src/shims/unix/android/dlsym.rs b/src/tools/miri/src/shims/unix/android/dlsym.rs index b0c9d729c9d90..451bc0bd5e153 100644 --- a/src/tools/miri/src/shims/unix/android/dlsym.rs +++ b/src/tools/miri/src/shims/unix/android/dlsym.rs @@ -47,7 +47,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } } - log::trace!("{:?}", this.dump_place(**dest)); + log::trace!("{:?}", this.dump_place(dest)); this.go_to_block(ret); Ok(()) } diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index 3a48019053563..865f01931f706 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -597,7 +597,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.write_pointer(buf, &pw_dir)?; if written { - this.write_pointer(pwd.ptr, &result)?; + this.write_pointer(pwd.ptr(), &result)?; this.write_null(dest)?; } else { this.write_null(&result)?; diff --git a/src/tools/miri/src/shims/unix/fs.rs b/src/tools/miri/src/shims/unix/fs.rs index dd2da3d22f286..8963dfb97a6e5 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -1439,7 +1439,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let file_name = dir_entry.file_name(); // not a Path as there are no separators! let (name_fits, file_name_buf_len) = this.write_os_str_to_c_str( &file_name, - name_place.ptr, + name_place.ptr(), name_place.layout.size.bytes(), )?; let file_name_len = file_name_buf_len.checked_sub(1).unwrap(); diff --git a/src/tools/miri/src/shims/unix/linux/sync.rs b/src/tools/miri/src/shims/unix/linux/sync.rs index 0474c9fd90a5c..7d15abfbfb2d8 100644 --- a/src/tools/miri/src/shims/unix/linux/sync.rs +++ b/src/tools/miri/src/shims/unix/linux/sync.rs @@ -35,7 +35,7 @@ pub fn futex<'tcx>( let thread = this.get_active_thread(); // This is a vararg function so we have to bring our own type for this pointer. let addr = MPlaceTy::from_aligned_ptr(addr, this.machine.layouts.i32); - let addr_usize = addr.ptr.addr().bytes(); + let addr_usize = addr.ptr().addr().bytes(); let futex_private = this.eval_libc_i32("FUTEX_PRIVATE_FLAG"); let futex_wait = this.eval_libc_i32("FUTEX_WAIT"); @@ -90,7 +90,7 @@ pub fn futex<'tcx>( &this.read_immediate(&args[3])?, this.libc_ty_layout("timespec"), )?; - let timeout_time = if this.ptr_is_null(timeout.ptr)? { + let timeout_time = if this.ptr_is_null(timeout.ptr())? { None } else { let realtime = op & futex_realtime == futex_realtime; diff --git a/src/tools/miri/src/shims/unix/macos/dlsym.rs b/src/tools/miri/src/shims/unix/macos/dlsym.rs index 9177ecefe1207..63ad680de60fa 100644 --- a/src/tools/miri/src/shims/unix/macos/dlsym.rs +++ b/src/tools/miri/src/shims/unix/macos/dlsym.rs @@ -45,7 +45,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } } - trace!("{:?}", this.dump_place(**dest)); + trace!("{:?}", this.dump_place(dest)); this.go_to_block(ret); Ok(()) } diff --git a/src/tools/miri/src/shims/unix/macos/foreign_items.rs b/src/tools/miri/src/shims/unix/macos/foreign_items.rs index f073daab8ed8e..3524fd70bcf85 100644 --- a/src/tools/miri/src/shims/unix/macos/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/macos/foreign_items.rs @@ -91,7 +91,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { .environ .as_ref() .expect("machine must be initialized") - .ptr, + .ptr(), dest, )?; } @@ -113,14 +113,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { "_NSGetArgc" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; this.write_pointer( - this.machine.argc.expect("machine must be initialized").ptr, + this.machine.argc.expect("machine must be initialized"), dest, )?; } "_NSGetArgv" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; this.write_pointer( - this.machine.argv.expect("machine must be initialized").ptr, + this.machine.argv.expect("machine must be initialized"), dest, )?; } diff --git a/src/tools/miri/src/shims/windows/dlsym.rs b/src/tools/miri/src/shims/windows/dlsym.rs index 7e2051fc98a0e..e5afee35905d0 100644 --- a/src/tools/miri/src/shims/windows/dlsym.rs +++ b/src/tools/miri/src/shims/windows/dlsym.rs @@ -75,7 +75,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } } - trace!("{:?}", this.dump_place(**dest)); + trace!("{:?}", this.dump_place(dest)); this.go_to_block(ret); Ok(()) } diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index cb90ed57ffe99..28999268ba052 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -190,7 +190,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.deref_pointer_as(system_info, this.windows_ty_layout("SYSTEM_INFO"))?; // Initialize with `0`. this.write_bytes_ptr( - system_info.ptr, + system_info.ptr(), iter::repeat(0u8).take(system_info.layout.size.bytes_usize()), )?; // Set selected fields. @@ -235,7 +235,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { "GetCommandLineW" => { let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; this.write_pointer( - this.machine.cmd_line.expect("machine must be initialized").ptr, + this.machine.cmd_line.expect("machine must be initialized"), dest, )?; } diff --git a/src/tools/miri/src/tag_gc.rs b/src/tools/miri/src/tag_gc.rs index cefdcc2b5b83d..3cccdd3635388 100644 --- a/src/tools/miri/src/tag_gc.rs +++ b/src/tools/miri/src/tag_gc.rs @@ -1,3 +1,5 @@ +use either::Either; + use rustc_data_structures::fx::FxHashSet; use crate::*; @@ -81,46 +83,33 @@ impl VisitTags for MemPlaceMeta { } } -impl VisitTags for MemPlace { +impl VisitTags for ImmTy<'_, Provenance> { fn visit_tags(&self, visit: &mut dyn FnMut(BorTag)) { - let MemPlace { ptr, meta } = self; - ptr.visit_tags(visit); - meta.visit_tags(visit); + (**self).visit_tags(visit) } } impl VisitTags for MPlaceTy<'_, Provenance> { fn visit_tags(&self, visit: &mut dyn FnMut(BorTag)) { - (**self).visit_tags(visit) - } -} - -impl VisitTags for Place { - fn visit_tags(&self, visit: &mut dyn FnMut(BorTag)) { - match self { - Place::Ptr(p) => p.visit_tags(visit), - Place::Local { .. } => { - // Will be visited as part of the stack frame. - } - } + self.ptr().visit_tags(visit); + self.meta().visit_tags(visit); } } impl VisitTags for PlaceTy<'_, Provenance> { fn visit_tags(&self, visit: &mut dyn FnMut(BorTag)) { - (**self).visit_tags(visit) + match self.as_mplace_or_local() { + Either::Left(mplace) => mplace.visit_tags(visit), + Either::Right(_) => (), + } } } -impl VisitTags for Operand { +impl VisitTags for OpTy<'_, Provenance> { fn visit_tags(&self, visit: &mut dyn FnMut(BorTag)) { - match self { - Operand::Immediate(imm) => { - imm.visit_tags(visit); - } - Operand::Indirect(p) => { - p.visit_tags(visit); - } + match self.as_mplace_or_imm() { + Either::Left(mplace) => mplace.visit_tags(visit), + Either::Right(imm) => imm.visit_tags(visit), } } } From 7a183806a96f748b2e90b1532a0af3933acbff46 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 4 Sep 2023 15:54:21 +0000 Subject: [PATCH 49/73] Update doc. --- compiler/rustc_span/src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 34714957aefe1..7b57ae2324b84 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1109,7 +1109,7 @@ impl fmt::Debug for SpanData { /// Identifies an offset of a multi-byte character in a `SourceFile`. #[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)] pub struct MultiByteChar { - /// The absolute offset of the character in the `SourceMap`. + /// The relative offset of the character in the `SourceFile`. pub pos: RelativeBytePos, /// The number of bytes, `>= 2`. pub bytes: u8, @@ -1136,7 +1136,7 @@ impl NonNarrowChar { } } - /// Returns the absolute offset of the character in the `SourceMap`. + /// Returns the relative offset of the character in the `SourceFile`. pub fn pos(&self) -> RelativeBytePos { match *self { NonNarrowChar::ZeroWidth(p) | NonNarrowChar::Wide(p) | NonNarrowChar::Tab(p) => p, @@ -1180,7 +1180,7 @@ impl Sub for NonNarrowChar { /// Identifies an offset of a character that was normalized away from `SourceFile`. #[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)] pub struct NormalizedPos { - /// The absolute offset of the character in the `SourceMap`. + /// The relative offset of the character in the `SourceFile`. pub pos: RelativeBytePos, /// The difference between original and normalized string at position. pub diff: u32, @@ -1351,7 +1351,7 @@ pub struct SourceFile { pub external_src: Lock, /// The start position of this source in the `SourceMap`. pub start_pos: BytePos, - /// The end position of this source in the `SourceMap`. + /// The byte length of this source. pub source_len: RelativeBytePos, /// Locations of lines beginnings in the source code. pub lines: Lock, @@ -1794,7 +1794,7 @@ impl SourceFile { BytePos::from_u32(self.start_pos.0 + offset - diff) } - /// Converts an absolute `BytePos` to a `CharPos` relative to the `SourceFile`. + /// Converts an relative `RelativeBytePos` to a `CharPos` relative to the `SourceFile`. fn bytepos_to_file_charpos(&self, bpos: RelativeBytePos) -> CharPos { // The number of extra bytes due to multibyte chars in the `SourceFile`. let mut total_extra_bytes = 0; @@ -1818,7 +1818,7 @@ impl SourceFile { } /// Looks up the file's (1-based) line number and (0-based `CharPos`) column offset, for a - /// given `BytePos`. + /// given `RelativeBytePos`. fn lookup_file_pos(&self, pos: RelativeBytePos) -> (usize, CharPos) { let chpos = self.bytepos_to_file_charpos(pos); match self.lookup_line(pos) { @@ -2028,8 +2028,6 @@ impl_pos! { pub struct BytePos(pub u32); /// A byte offset relative to file beginning. - /// - /// Keep this small (currently 32-bits), as AST contains a lot of them. #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] pub struct RelativeBytePos(pub u32); From 4b417c1b8d74d40fe426c2de384a2c12e9f560a1 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 4 Sep 2023 15:57:13 +0000 Subject: [PATCH 50/73] Remove always-zero field. --- compiler/rustc_span/src/lib.rs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 7b57ae2324b84..f1a6e9059d725 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1314,11 +1314,6 @@ impl SourceFileLines { /// small crates where very little of `std`'s metadata is used. #[derive(Clone)] pub struct SourceFileDiffs { - /// Position of the first line. Note that this is always encoded as a - /// `BytePos` because it is often much larger than any of the - /// differences. - line_start: RelativeBytePos, - /// Always 1, 2, or 4. Always as small as possible, while being big /// enough to hold the length of the longest line in the source file. /// The 1 case is by far the most common. @@ -1422,7 +1417,7 @@ impl Encodable for SourceFile { s.emit_u8(bytes_per_diff as u8); // Encode the first element. - lines[0].encode(s); + assert_eq!(lines[0], RelativeBytePos(0)); // Encode the difference list. let diff_iter = lines.array_windows().map(|&[fst, snd]| snd - fst); @@ -1472,18 +1467,10 @@ impl Decodable for SourceFile { // Read the number of bytes used per diff. let bytes_per_diff = d.read_u8() as usize; - // Read the first element. - let line_start: RelativeBytePos = Decodable::decode(d); - // Read the difference list. let num_diffs = num_lines as usize - 1; let raw_diffs = d.read_raw_bytes(bytes_per_diff * num_diffs).to_vec(); - SourceFileLines::Diffs(SourceFileDiffs { - line_start, - bytes_per_diff, - num_diffs, - raw_diffs, - }) + SourceFileLines::Diffs(SourceFileDiffs { bytes_per_diff, num_diffs, raw_diffs }) } else { SourceFileLines::Lines(vec![]) } @@ -1562,15 +1549,11 @@ impl SourceFile { let mut guard = self.lines.borrow_mut(); match &*guard { SourceFileLines::Lines(lines) => f(lines), - SourceFileLines::Diffs(SourceFileDiffs { - mut line_start, - bytes_per_diff, - num_diffs, - raw_diffs, - }) => { + SourceFileLines::Diffs(SourceFileDiffs { bytes_per_diff, num_diffs, raw_diffs }) => { // Convert from "diffs" form to "lines" form. let num_lines = num_diffs + 1; let mut lines = Vec::with_capacity(num_lines); + let mut line_start = RelativeBytePos(0); lines.push(line_start); assert_eq!(*num_diffs, raw_diffs.len() / bytes_per_diff); From 3edeac06a5722e9b29c350a22e54b8cc1396c62d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 4 Sep 2023 16:02:28 +0000 Subject: [PATCH 51/73] Pass StableSourceFileId. --- compiler/rustc_span/src/source_map.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 50c30a079b457..81730f2f60869 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -262,10 +262,9 @@ impl SourceMap { fn register_source_file( &self, + file_id: StableSourceFileId, mut file: SourceFile, ) -> Result, OffsetOverflowError> { - let file_id = StableSourceFileId::new(&file); - let mut files = self.files.borrow_mut(); file.start_pos = BytePos(if let Some(last_file) = files.source_files.last() { @@ -313,7 +312,7 @@ impl SourceMap { // the ID we generate for the SourceFile we just created. debug_assert_eq!(StableSourceFileId::new(&source_file), file_id); - self.register_source_file(source_file) + self.register_source_file(file_id, source_file) } } } @@ -355,7 +354,8 @@ impl SourceMap { cnum, }; - self.register_source_file(source_file) + let file_id = StableSourceFileId::new(&source_file); + self.register_source_file(file_id, source_file) .expect("not enough address space for imported source file") } From 56d10a883e716fe252a60622d1e117a6f1970e3a Mon Sep 17 00:00:00 2001 From: ouz-a Date: Mon, 4 Sep 2023 13:06:36 +0300 Subject: [PATCH 52/73] provide more useful info for DefId Debug --- compiler/rustc_smir/src/rustc_smir/mod.rs | 5 +++++ compiler/rustc_smir/src/stable_mir/mod.rs | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 822a6e4865862..b4c150c591c48 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -37,9 +37,14 @@ impl<'tcx> Context for Tables<'tcx> { }) } + fn name_of_def_id(&self, def_id: stable_mir::DefId) -> String { + self.tcx.def_path_str(self[def_id]) + } + fn all_local_items(&mut self) -> stable_mir::CrateItems { self.tcx.mir_keys(()).iter().map(|item| self.crate_item(item.to_def_id())).collect() } + fn entry_fn(&mut self) -> Option { Some(self.crate_item(self.tcx.entry_fn(())?.0)) } diff --git a/compiler/rustc_smir/src/stable_mir/mod.rs b/compiler/rustc_smir/src/stable_mir/mod.rs index dad7c75c3406f..bfc2c15a42eb0 100644 --- a/compiler/rustc_smir/src/stable_mir/mod.rs +++ b/compiler/rustc_smir/src/stable_mir/mod.rs @@ -12,6 +12,8 @@ //! If you need an internal construct, consider using `rustc_internal` or `rustc_smir`. use std::cell::Cell; +use std::fmt; +use std::fmt::Debug; use self::ty::{ GenericPredicates, Generics, ImplDef, ImplTrait, Span, TraitDecl, TraitDef, Ty, TyKind, @@ -29,9 +31,18 @@ pub type Symbol = String; pub type CrateNum = usize; /// A unique identification number for each item accessible for the current compilation unit. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, PartialEq, Eq)] pub struct DefId(pub(crate) usize); +impl Debug for DefId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("DefId:") + .field("id", &self.0) + .field("name", &with(|cx| cx.name_of_def_id(*self))) + .finish() + } +} + /// A unique identification number for each provenance #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct AllocId(pub(crate) usize); @@ -127,6 +138,9 @@ pub trait Context { /// Find a crate with the given name. fn find_crate(&self, name: &str) -> Option; + /// Prints the name of given `DefId` + fn name_of_def_id(&self, def_id: DefId) -> String; + /// Obtain the representation of a type. fn ty_kind(&mut self, ty: Ty) -> TyKind; From 7093903ba7a71c1d30e817daa41a4328dc6a8db2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 4 Sep 2023 15:32:07 +0200 Subject: [PATCH 53/73] read_via_copy: don't prematurely optimize away the read --- .../src/lower_intrinsics.rs | 23 +++++++++---------- ...inhabited.LowerIntrinsics.panic-abort.diff | 1 + ...nhabited.LowerIntrinsics.panic-unwind.diff | 1 + tests/ui/consts/const-eval/ub-uninhabit.rs | 16 +++++++++++++ .../ui/consts/const-eval/ub-uninhabit.stderr | 14 +++++++---- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index fc36c6e4124a6..a8dc91ca43969 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -176,23 +176,22 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } else { span_bug!(terminator.source_info.span, "Only passing a local is supported"); }; + // Add new statement at the end of the block that does the read, and patch + // up the terminator. + block.statements.push(Statement { + source_info: terminator.source_info, + kind: StatementKind::Assign(Box::new(( + *destination, + Rvalue::Use(Operand::Copy(derefed_place)), + ))), + }); terminator.kind = match *target { None => { // No target means this read something uninhabited, - // so it must be unreachable, and we don't need to - // preserve the assignment either. + // so it must be unreachable. TerminatorKind::Unreachable } - Some(target) => { - block.statements.push(Statement { - source_info: terminator.source_info, - kind: StatementKind::Assign(Box::new(( - *destination, - Rvalue::Use(Operand::Copy(derefed_place)), - ))), - }); - TerminatorKind::Goto { target } - } + Some(target) => TerminatorKind::Goto { target }, } } sym::write_via_move => { diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-abort.diff index 95a4a83d66386..b2cf3cc1ccac5 100644 --- a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-abort.diff @@ -12,6 +12,7 @@ StorageLive(_2); _2 = &raw const (*_1); - _0 = read_via_copy::(move _2) -> unwind unreachable; ++ _0 = (*_2); + unreachable; } } diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-unwind.diff index 95a4a83d66386..b2cf3cc1ccac5 100644 --- a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-unwind.diff @@ -12,6 +12,7 @@ StorageLive(_2); _2 = &raw const (*_1); - _0 = read_via_copy::(move _2) -> unwind unreachable; ++ _0 = (*_2); + unreachable; } } diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index 10edae437ee74..01600f545ae03 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -1,7 +1,10 @@ // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +#![feature(core_intrinsics)] +#![feature(never_type)] +use std::intrinsics; use std::mem; #[derive(Copy, Clone)] @@ -15,11 +18,24 @@ union MaybeUninit { const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed +//~| constructing invalid value const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; //~^ ERROR it is undefined behavior to use this value +//~| constructing invalid value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed +//~| constructing invalid value + + +const READ_NEVER: () = unsafe { + let mem = [0u32; 8]; + let ptr = mem.as_ptr().cast::(); + let _val = intrinsics::read_via_copy(ptr); + //~^ ERROR evaluation of constant value failed + //~| constructing invalid value +}; + fn main() {} diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index f1ad0f04d3dbe..d26f4e03666e9 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:16:35 + --> $DIR/ub-uninhabit.rs:19:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:19:1 + --> $DIR/ub-uninhabit.rs:23:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -16,11 +16,17 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:22:42 + --> $DIR/ub-uninhabit.rs:27:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` -error: aborting due to 3 previous errors +error[E0080]: evaluation of constant value failed + --> $DIR/ub-uninhabit.rs:35:16 + | +LL | let _val = intrinsics::read_via_copy(ptr); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0080`. From fe6c863f0bdfffaeb8fbbb520ece8696581383ce Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 4 Sep 2023 13:21:05 -0400 Subject: [PATCH 54/73] Mirror the rustc-perf source This avoids issues with the GitHub /archive/ links which can be somewhat unreliable and are currently causing CI issues. --- src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile | 2 +- src/tools/opt-dist/src/environment/windows.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index 319989df33460..f6954275ad440 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -60,7 +60,7 @@ ENV CC=clang CXX=clang++ # rustc-perf version from 2023-05-30 # Should also be changed in the opt-dist tool for other environments. ENV PERF_COMMIT 8b2ac3042e1ff2c0074455a0a3618adef97156b1 -RUN curl -LS -o perf.zip https://github.com/rust-lang/rustc-perf/archive/$PERF_COMMIT.zip && \ +RUN curl -LS -o perf.zip https://ci-mirrors.rust-lang.org/rustc/rustc-perf-$PERF_COMMIT.zip && \ unzip perf.zip && \ mv rustc-perf-$PERF_COMMIT rustc-perf && \ rm perf.zip diff --git a/src/tools/opt-dist/src/environment/windows.rs b/src/tools/opt-dist/src/environment/windows.rs index 8a9733d64965f..67f63c7359d24 100644 --- a/src/tools/opt-dist/src/environment/windows.rs +++ b/src/tools/opt-dist/src/environment/windows.rs @@ -42,7 +42,7 @@ impl Environment for WindowsEnvironment { // rustc-perf version from 2023-05-30 const PERF_COMMIT: &str = "8b2ac3042e1ff2c0074455a0a3618adef97156b1"; - let url = format!("https://github.com/rust-lang/rustc-perf/archive/{PERF_COMMIT}.zip"); + let url = format!("https://ci-mirrors.rust-lang.org/rustc/rustc-perf-{PERF_COMMIT}.zip"); let response = reqwest::blocking::get(url)?.error_for_status()?.bytes()?.to_vec(); let mut archive = ZipArchive::new(Cursor::new(response))?; From c98455fe872f1db7286c4e21a0304aff78389f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Mon, 4 Sep 2023 20:15:05 +0200 Subject: [PATCH 55/73] Retry download of rustc-perf in opt-dist This should help resolving spurious network errors. It also increases the timeout for the archive download. --- src/tools/opt-dist/src/environment/windows.rs | 12 +++++++++++- src/tools/opt-dist/src/utils/mod.rs | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/tools/opt-dist/src/environment/windows.rs b/src/tools/opt-dist/src/environment/windows.rs index 67f63c7359d24..79399391798cb 100644 --- a/src/tools/opt-dist/src/environment/windows.rs +++ b/src/tools/opt-dist/src/environment/windows.rs @@ -1,8 +1,10 @@ use crate::environment::Environment; use crate::exec::cmd; use crate::utils::io::move_directory; +use crate::utils::retry_action; use camino::Utf8PathBuf; use std::io::Cursor; +use std::time::Duration; use zip::ZipArchive; pub(super) struct WindowsEnvironment { @@ -43,7 +45,15 @@ impl Environment for WindowsEnvironment { const PERF_COMMIT: &str = "8b2ac3042e1ff2c0074455a0a3618adef97156b1"; let url = format!("https://ci-mirrors.rust-lang.org/rustc/rustc-perf-{PERF_COMMIT}.zip"); - let response = reqwest::blocking::get(url)?.error_for_status()?.bytes()?.to_vec(); + let client = reqwest::blocking::Client::builder() + .timeout(Duration::from_secs(60 * 2)) + .connect_timeout(Duration::from_secs(60 * 2)) + .build()?; + let response = retry_action( + || Ok(client.get(&url).send()?.error_for_status()?.bytes()?.to_vec()), + "Download rustc-perf archive", + 5, + )?; let mut archive = ZipArchive::new(Cursor::new(response))?; archive.extract(self.rustc_perf_dir())?; diff --git a/src/tools/opt-dist/src/utils/mod.rs b/src/tools/opt-dist/src/utils/mod.rs index 9a3df15e302bb..2af28077ed12e 100644 --- a/src/tools/opt-dist/src/utils/mod.rs +++ b/src/tools/opt-dist/src/utils/mod.rs @@ -3,6 +3,7 @@ pub mod io; use crate::environment::Environment; use crate::utils::io::{delete_directory, get_files_from_dir}; use humansize::{format_size, BINARY}; +use std::time::Duration; use sysinfo::{DiskExt, RefreshKind, System, SystemExt}; pub fn format_env_variables() -> String { @@ -70,6 +71,24 @@ pub fn with_log_group R, R>(group: &str, func: F) -> R { } } +#[allow(unused)] +pub fn retry_action anyhow::Result, R>( + action: F, + name: &str, + count: u64, +) -> anyhow::Result { + for attempt in 0..count { + match action() { + Ok(result) => return Ok(result), + Err(error) => { + log::error!("Failed to perform action `{name}`, attempt #{attempt}: {error:?}"); + std::thread::sleep(Duration::from_secs(5)); + } + } + } + Err(anyhow::anyhow!("Failed to perform action `{name}` after {count} retries")) +} + fn is_in_ci() -> bool { std::env::var("GITHUB_ACTIONS").is_ok() } From 1367104cb22ba5e9f8bc95c7bc719a12dc80d2c6 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 11 Aug 2023 11:52:37 +1000 Subject: [PATCH 56/73] Add tool `src/tools/coverage-dump` for use by some new coverage tests --- Cargo.lock | 18 ++ Cargo.toml | 1 + src/bootstrap/builder.rs | 3 +- src/bootstrap/tool.rs | 1 + src/tools/coverage-dump/Cargo.toml | 14 + src/tools/coverage-dump/README.md | 8 + src/tools/coverage-dump/src/covfun.rs | 296 ++++++++++++++++++++ src/tools/coverage-dump/src/main.rs | 17 ++ src/tools/coverage-dump/src/parser.rs | 80 ++++++ src/tools/coverage-dump/src/parser/tests.rs | 38 +++ src/tools/coverage-dump/src/prf_names.rs | 87 ++++++ 11 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 src/tools/coverage-dump/Cargo.toml create mode 100644 src/tools/coverage-dump/README.md create mode 100644 src/tools/coverage-dump/src/covfun.rs create mode 100644 src/tools/coverage-dump/src/main.rs create mode 100644 src/tools/coverage-dump/src/parser.rs create mode 100644 src/tools/coverage-dump/src/parser/tests.rs create mode 100644 src/tools/coverage-dump/src/prf_names.rs diff --git a/Cargo.lock b/Cargo.lock index bdbafb8623bb8..35a9fdccf9cdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -722,6 +722,18 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "coverage-dump" +version = "0.1.0" +dependencies = [ + "anyhow", + "leb128", + "md-5", + "miniz_oxide", + "regex", + "rustc-demangle", +] + [[package]] name = "coverage_test_macros" version = "0.0.0" @@ -2041,6 +2053,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "levenshtein" version = "1.0.5" diff --git a/Cargo.toml b/Cargo.toml index d2e84d5426f9f..9b11ae8744b4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ members = [ "src/tools/generate-windows-sys", "src/tools/rustdoc-gui-test", "src/tools/opt-dist", + "src/tools/coverage-dump", ] exclude = [ diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index b366619285338..73c0a192cef94 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -703,7 +703,8 @@ impl<'a> Builder<'a> { llvm::Lld, llvm::CrtBeginEnd, tool::RustdocGUITest, - tool::OptimizedDist + tool::OptimizedDist, + tool::CoverageDump, ), Kind::Check | Kind::Clippy | Kind::Fix => describe!( check::Std, diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 07ff3da6b4aa5..f094dd9d7c90b 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -306,6 +306,7 @@ bootstrap_tool!( GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys"; RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = "test"; OptimizedDist, "src/tools/opt-dist", "opt-dist"; + CoverageDump, "src/tools/coverage-dump", "coverage-dump"; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] diff --git a/src/tools/coverage-dump/Cargo.toml b/src/tools/coverage-dump/Cargo.toml new file mode 100644 index 0000000000000..7f14286b5d0c4 --- /dev/null +++ b/src/tools/coverage-dump/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "coverage-dump" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.71" +leb128 = "0.2.5" +md5 = { package = "md-5" , version = "0.10.5" } +miniz_oxide = "0.7.1" +regex = "1.8.4" +rustc-demangle = "0.1.23" diff --git a/src/tools/coverage-dump/README.md b/src/tools/coverage-dump/README.md new file mode 100644 index 0000000000000..e2625d5adf27e --- /dev/null +++ b/src/tools/coverage-dump/README.md @@ -0,0 +1,8 @@ +This tool extracts coverage mapping information from an LLVM IR assembly file +(`.ll`), and prints it in a more human-readable form that can be used for +snapshot tests. + +The output format is mostly arbitrary, so it's OK to change the output as long +as any affected tests are also re-blessed. However, the output should be +consistent across different executions on different platforms, so avoid +printing any information that is platform-specific or non-deterministic. diff --git a/src/tools/coverage-dump/src/covfun.rs b/src/tools/coverage-dump/src/covfun.rs new file mode 100644 index 0000000000000..3a5866dea3e05 --- /dev/null +++ b/src/tools/coverage-dump/src/covfun.rs @@ -0,0 +1,296 @@ +use crate::parser::{unescape_llvm_string_contents, Parser}; +use anyhow::{anyhow, Context}; +use regex::Regex; +use std::collections::HashMap; +use std::fmt::{self, Debug, Write as _}; +use std::sync::OnceLock; + +pub(crate) fn dump_covfun_mappings( + llvm_ir: &str, + function_names: &HashMap, +) -> anyhow::Result<()> { + // Extract function coverage entries from the LLVM IR assembly, and associate + // each entry with its (demangled) name. + let mut covfun_entries = llvm_ir + .lines() + .filter_map(covfun_line_data) + .map(|line_data| (function_names.get(&line_data.name_hash).map(String::as_str), line_data)) + .collect::>(); + covfun_entries.sort_by(|a, b| { + // Sort entries primarily by name, to help make the order consistent + // across platforms and relatively insensitive to changes. + // (Sadly we can't use `sort_by_key` because we would need to return references.) + Ord::cmp(&a.0, &b.0) + .then_with(|| Ord::cmp(&a.1.is_used, &b.1.is_used)) + .then_with(|| Ord::cmp(a.1.payload.as_slice(), b.1.payload.as_slice())) + }); + + for (name, line_data) in &covfun_entries { + let name = name.unwrap_or("(unknown)"); + let unused = if line_data.is_used { "" } else { " (unused)" }; + println!("Function name: {name}{unused}"); + + let payload: &[u8] = &line_data.payload; + println!("Raw bytes ({len}): 0x{payload:02x?}", len = payload.len()); + + let mut parser = Parser::new(payload); + + let num_files = parser.read_uleb128_u32()?; + println!("Number of files: {num_files}"); + + for i in 0..num_files { + let global_file_id = parser.read_uleb128_u32()?; + println!("- file {i} => global file {global_file_id}"); + } + + let num_expressions = parser.read_uleb128_u32()?; + println!("Number of expressions: {num_expressions}"); + + let mut expression_resolver = ExpressionResolver::new(); + for i in 0..num_expressions { + let lhs = parser.read_simple_term()?; + let rhs = parser.read_simple_term()?; + println!("- expression {i} operands: lhs = {lhs:?}, rhs = {rhs:?}"); + expression_resolver.push_operands(lhs, rhs); + } + + for i in 0..num_files { + let num_mappings = parser.read_uleb128_u32()?; + println!("Number of file {i} mappings: {num_mappings}"); + + for _ in 0..num_mappings { + let (kind, region) = parser.read_mapping_kind_and_region()?; + println!("- {kind:?} at {region:?}"); + + match kind { + // Also print expression mappings in resolved form. + MappingKind::Code(term @ CovTerm::Expression { .. }) + | MappingKind::Gap(term @ CovTerm::Expression { .. }) => { + println!(" = {}", expression_resolver.format_term(term)); + } + // If the mapping is a branch region, print both of its arms + // in resolved form (even if they aren't expressions). + MappingKind::Branch { r#true, r#false } => { + println!(" true = {}", expression_resolver.format_term(r#true)); + println!(" false = {}", expression_resolver.format_term(r#false)); + } + _ => (), + } + } + } + + parser.ensure_empty()?; + println!(); + } + Ok(()) +} + +struct CovfunLineData { + name_hash: u64, + is_used: bool, + payload: Vec, +} + +/// Checks a line of LLVM IR assembly to see if it contains an `__llvm_covfun` +/// entry, and if so extracts relevant data in a `CovfunLineData`. +fn covfun_line_data(line: &str) -> Option { + let re = { + // We cheat a little bit and match variable names `@__covrec_[HASH]u` + // rather than the section name, because the section name is harder to + // extract and differs across Linux/Windows/macOS. We also extract the + // symbol name hash from the variable name rather than the data, since + // it's easier and both should match. + static RE: OnceLock = OnceLock::new(); + RE.get_or_init(|| { + Regex::new( + r#"^@__covrec_(?[0-9A-Z]+)(?u)? = .*\[[0-9]+ x i8\] c"(?[^"]*)".*$"#, + ) + .unwrap() + }) + }; + + let captures = re.captures(line)?; + let name_hash = u64::from_str_radix(&captures["name_hash"], 16).unwrap(); + let is_used = captures.name("is_used").is_some(); + let payload = unescape_llvm_string_contents(&captures["payload"]); + + Some(CovfunLineData { name_hash, is_used, payload }) +} + +// Extra parser methods only needed when parsing `covfun` payloads. +impl<'a> Parser<'a> { + fn read_simple_term(&mut self) -> anyhow::Result { + let raw_term = self.read_uleb128_u32()?; + CovTerm::decode(raw_term).context("decoding term") + } + + fn read_mapping_kind_and_region(&mut self) -> anyhow::Result<(MappingKind, MappingRegion)> { + let mut kind = self.read_raw_mapping_kind()?; + let mut region = self.read_raw_mapping_region()?; + + const HIGH_BIT: u32 = 1u32 << 31; + if region.end_column & HIGH_BIT != 0 { + region.end_column &= !HIGH_BIT; + kind = match kind { + MappingKind::Code(term) => MappingKind::Gap(term), + // LLVM's coverage mapping reader will actually handle this + // case without complaint, but the result is almost certainly + // a meaningless implementation artifact. + _ => return Err(anyhow!("unexpected base kind for gap region: {kind:?}")), + } + } + + Ok((kind, region)) + } + + fn read_raw_mapping_kind(&mut self) -> anyhow::Result { + let raw_mapping_kind = self.read_uleb128_u32()?; + if let Some(term) = CovTerm::decode(raw_mapping_kind) { + return Ok(MappingKind::Code(term)); + } + + assert_eq!(raw_mapping_kind & 0b11, 0); + assert_ne!(raw_mapping_kind, 0); + + let (high, is_expansion) = (raw_mapping_kind >> 3, raw_mapping_kind & 0b100 != 0); + if is_expansion { + Ok(MappingKind::Expansion(high)) + } else { + match high { + 0 => unreachable!("zero kind should have already been handled as a code mapping"), + 2 => Ok(MappingKind::Skip), + 4 => { + let r#true = self.read_simple_term()?; + let r#false = self.read_simple_term()?; + Ok(MappingKind::Branch { r#true, r#false }) + } + _ => Err(anyhow!("unknown mapping kind: {raw_mapping_kind:#x}")), + } + } + } + + fn read_raw_mapping_region(&mut self) -> anyhow::Result { + let start_line_offset = self.read_uleb128_u32()?; + let start_column = self.read_uleb128_u32()?; + let end_line_offset = self.read_uleb128_u32()?; + let end_column = self.read_uleb128_u32()?; + Ok(MappingRegion { start_line_offset, start_column, end_line_offset, end_column }) + } +} + +/// Enum that can hold a constant zero value, the ID of an physical coverage +/// counter, or the ID (and operation) of a coverage-counter expression. +/// +/// Terms are used as the operands of coverage-counter expressions, as the arms +/// of branch mappings, and as the value of code/gap mappings. +#[derive(Clone, Copy, Debug)] +pub(crate) enum CovTerm { + Zero, + Counter(u32), + Expression(u32, Op), +} + +/// Operator (addition or subtraction) used by an expression. +#[derive(Clone, Copy, Debug)] +pub(crate) enum Op { + Sub, + Add, +} + +impl CovTerm { + pub(crate) fn decode(input: u32) -> Option { + let (high, tag) = (input >> 2, input & 0b11); + match tag { + 0b00 if high == 0 => Some(Self::Zero), + 0b01 => Some(Self::Counter(high)), + 0b10 => Some(Self::Expression(high, Op::Sub)), + 0b11 => Some(Self::Expression(high, Op::Add)), + // When reading expression operands or branch arms, the LLVM coverage + // mapping reader will always interpret a `0b00` tag as a zero + // term, even when the high bits are non-zero. + // We treat that case as failure instead, so that this code can be + // shared by the full mapping-kind reader as well. + _ => None, + } + } +} + +#[derive(Debug)] +enum MappingKind { + Code(CovTerm), + Gap(CovTerm), + Expansion(u32), + Skip, + // Using raw identifiers here makes the dump output a little bit nicer + // (via the derived Debug), at the expense of making this tool's source + // code a little bit uglier. + Branch { r#true: CovTerm, r#false: CovTerm }, +} + +struct MappingRegion { + /// Offset of this region's start line, relative to the *start line* of + /// the *previous mapping* (or 0). Line numbers are 1-based. + start_line_offset: u32, + /// This region's start column, absolute and 1-based. + start_column: u32, + /// Offset of this region's end line, relative to the *this mapping's* + /// start line. Line numbers are 1-based. + end_line_offset: u32, + /// This region's end column, absolute, 1-based, and exclusive. + /// + /// If the highest bit is set, that bit is cleared and the associated + /// mapping becomes a gap region mapping. + end_column: u32, +} + +impl Debug for MappingRegion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "(prev + {}, {}) to (start + {}, {})", + self.start_line_offset, self.start_column, self.end_line_offset, self.end_column + ) + } +} + +/// Helper type that prints expressions in a "resolved" form, so that +/// developers reading the dump don't need to resolve expressions by hand. +struct ExpressionResolver { + operands: Vec<(CovTerm, CovTerm)>, +} + +impl ExpressionResolver { + fn new() -> Self { + Self { operands: Vec::new() } + } + + fn push_operands(&mut self, lhs: CovTerm, rhs: CovTerm) { + self.operands.push((lhs, rhs)); + } + + fn format_term(&self, term: CovTerm) -> String { + let mut output = String::new(); + self.write_term(&mut output, term); + output + } + + fn write_term(&self, output: &mut String, term: CovTerm) { + match term { + CovTerm::Zero => output.push_str("Zero"), + CovTerm::Counter(id) => write!(output, "c{id}").unwrap(), + CovTerm::Expression(id, op) => { + let (lhs, rhs) = self.operands[id as usize]; + let op = match op { + Op::Sub => "-", + Op::Add => "+", + }; + + output.push('('); + self.write_term(output, lhs); + write!(output, " {op} ").unwrap(); + self.write_term(output, rhs); + output.push(')'); + } + } + } +} diff --git a/src/tools/coverage-dump/src/main.rs b/src/tools/coverage-dump/src/main.rs new file mode 100644 index 0000000000000..93fed1799e041 --- /dev/null +++ b/src/tools/coverage-dump/src/main.rs @@ -0,0 +1,17 @@ +mod covfun; +mod parser; +mod prf_names; + +fn main() -> anyhow::Result<()> { + use anyhow::Context as _; + + let args = std::env::args().collect::>(); + + let llvm_ir_path = args.get(1).context("LLVM IR file not specified")?; + let llvm_ir = std::fs::read_to_string(llvm_ir_path).context("couldn't read LLVM IR file")?; + + let function_names = crate::prf_names::make_function_names_table(&llvm_ir)?; + crate::covfun::dump_covfun_mappings(&llvm_ir, &function_names)?; + + Ok(()) +} diff --git a/src/tools/coverage-dump/src/parser.rs b/src/tools/coverage-dump/src/parser.rs new file mode 100644 index 0000000000000..eefac1a4f94c1 --- /dev/null +++ b/src/tools/coverage-dump/src/parser.rs @@ -0,0 +1,80 @@ +#[cfg(test)] +mod tests; + +use anyhow::ensure; +use regex::bytes; +use std::sync::OnceLock; + +/// Given the raw contents of a string literal in LLVM IR assembly, decodes any +/// backslash escapes and returns a vector containing the resulting byte string. +pub(crate) fn unescape_llvm_string_contents(contents: &str) -> Vec { + let escape_re = { + static RE: OnceLock = OnceLock::new(); + // LLVM IR supports two string escapes: `\\` and `\xx`. + RE.get_or_init(|| bytes::Regex::new(r"\\\\|\\([0-9A-Za-z]{2})").unwrap()) + }; + + fn u8_from_hex_digits(digits: &[u8]) -> u8 { + // We know that the input contains exactly 2 hex digits, so these calls + // should never fail. + assert_eq!(digits.len(), 2); + let digits = std::str::from_utf8(digits).unwrap(); + u8::from_str_radix(digits, 16).unwrap() + } + + escape_re + .replace_all(contents.as_bytes(), |captures: &bytes::Captures<'_>| { + let byte = match captures.get(1) { + None => b'\\', + Some(hex_digits) => u8_from_hex_digits(hex_digits.as_bytes()), + }; + [byte] + }) + .into_owned() +} + +pub(crate) struct Parser<'a> { + rest: &'a [u8], +} + +impl<'a> Parser<'a> { + pub(crate) fn new(input: &'a [u8]) -> Self { + Self { rest: input } + } + + pub(crate) fn ensure_empty(self) -> anyhow::Result<()> { + ensure!(self.rest.is_empty(), "unparsed bytes: 0x{:02x?}", self.rest); + Ok(()) + } + + pub(crate) fn read_n_bytes(&mut self, n: usize) -> anyhow::Result<&'a [u8]> { + ensure!(n <= self.rest.len()); + + let (bytes, rest) = self.rest.split_at(n); + self.rest = rest; + Ok(bytes) + } + + pub(crate) fn read_uleb128_u32(&mut self) -> anyhow::Result { + self.read_uleb128_u64_and_convert() + } + + pub(crate) fn read_uleb128_usize(&mut self) -> anyhow::Result { + self.read_uleb128_u64_and_convert() + } + + fn read_uleb128_u64_and_convert(&mut self) -> anyhow::Result + where + T: TryFrom + 'static, + T::Error: std::error::Error + Send + Sync, + { + let mut temp_rest = self.rest; + let raw_value: u64 = leb128::read::unsigned(&mut temp_rest)?; + let converted_value = T::try_from(raw_value)?; + + // Only update `self.rest` if the above steps succeeded, so that the + // parser position can be used for error reporting if desired. + self.rest = temp_rest; + Ok(converted_value) + } +} diff --git a/src/tools/coverage-dump/src/parser/tests.rs b/src/tools/coverage-dump/src/parser/tests.rs new file mode 100644 index 0000000000000..a673606b9c4c8 --- /dev/null +++ b/src/tools/coverage-dump/src/parser/tests.rs @@ -0,0 +1,38 @@ +use super::unescape_llvm_string_contents; + +// WARNING: These tests don't necessarily run in CI, and were mainly used to +// help track down problems when originally developing this tool. +// (The tool is still tested indirectly by snapshot tests that rely on it.) + +// Tests for `unescape_llvm_string_contents`: + +#[test] +fn unescape_empty() { + assert_eq!(unescape_llvm_string_contents(""), &[]); +} + +#[test] +fn unescape_noop() { + let input = "The quick brown fox jumps over the lazy dog."; + assert_eq!(unescape_llvm_string_contents(input), input.as_bytes()); +} + +#[test] +fn unescape_backslash() { + let input = r"\\Hello\\world\\"; + assert_eq!(unescape_llvm_string_contents(input), r"\Hello\world\".as_bytes()); +} + +#[test] +fn unescape_hex() { + let input = r"\01\02\03\04\0a\0b\0C\0D\fd\fE\FF"; + let expected: &[u8] = &[0x01, 0x02, 0x03, 0x04, 0x0a, 0x0b, 0x0c, 0x0d, 0xfd, 0xfe, 0xff]; + assert_eq!(unescape_llvm_string_contents(input), expected); +} + +#[test] +fn unescape_mixed() { + let input = r"\\01.\5c\5c"; + let expected: &[u8] = br"\01.\\"; + assert_eq!(unescape_llvm_string_contents(input), expected); +} diff --git a/src/tools/coverage-dump/src/prf_names.rs b/src/tools/coverage-dump/src/prf_names.rs new file mode 100644 index 0000000000000..d3f7b819e4837 --- /dev/null +++ b/src/tools/coverage-dump/src/prf_names.rs @@ -0,0 +1,87 @@ +use crate::parser::{unescape_llvm_string_contents, Parser}; +use anyhow::{anyhow, ensure}; +use regex::Regex; +use std::collections::HashMap; +use std::sync::OnceLock; + +/// Scans through the contents of an LLVM IR assembly file to find `__llvm_prf_names` +/// entries, decodes them, and creates a table that maps name hash values to +/// (demangled) function names. +pub(crate) fn make_function_names_table(llvm_ir: &str) -> anyhow::Result> { + fn prf_names_payload(line: &str) -> Option<&str> { + let re = { + // We cheat a little bit and match the variable name `@__llvm_prf_nm` + // rather than the section name, because the section name is harder + // to extract and differs across Linux/Windows/macOS. + static RE: OnceLock = OnceLock::new(); + RE.get_or_init(|| { + Regex::new(r#"^@__llvm_prf_nm =.*\[[0-9]+ x i8\] c"([^"]*)".*$"#).unwrap() + }) + }; + + let payload = re.captures(line)?.get(1).unwrap().as_str(); + Some(payload) + } + + /// LLVM's profiler/coverage metadata often uses an MD5 hash truncated to + /// 64 bits as a way to associate data stored in different tables/sections. + fn truncated_md5(bytes: &[u8]) -> u64 { + use md5::{Digest, Md5}; + let mut hasher = Md5::new(); + hasher.update(bytes); + let hash: [u8; 8] = hasher.finalize().as_slice()[..8].try_into().unwrap(); + // The truncated hash is explicitly little-endian, regardless of host + // or target platform. (See `MD5Result::low` in LLVM's `MD5.h`.) + u64::from_le_bytes(hash) + } + + fn demangle_if_able(symbol_name_bytes: &[u8]) -> anyhow::Result { + // In practice, raw symbol names should always be ASCII. + let symbol_name_str = std::str::from_utf8(symbol_name_bytes)?; + match rustc_demangle::try_demangle(symbol_name_str) { + Ok(d) => Ok(format!("{d:#}")), + // If demangling failed, don't treat it as an error. This lets us + // run the dump tool against non-Rust coverage maps produced by + // `clang`, for testing purposes. + Err(_) => Ok(format!("(couldn't demangle) {symbol_name_str}")), + } + } + + let mut map = HashMap::new(); + + for payload in llvm_ir.lines().filter_map(prf_names_payload).map(unescape_llvm_string_contents) + { + let mut parser = Parser::new(&payload); + let uncompressed_len = parser.read_uleb128_usize()?; + let compressed_len = parser.read_uleb128_usize()?; + + let uncompressed_bytes_vec; + let uncompressed_bytes: &[u8] = if compressed_len == 0 { + // The symbol name bytes are uncompressed, so read them directly. + parser.read_n_bytes(uncompressed_len)? + } else { + // The symbol name bytes are compressed, so read and decompress them. + let compressed_bytes = parser.read_n_bytes(compressed_len)?; + + uncompressed_bytes_vec = miniz_oxide::inflate::decompress_to_vec_zlib_with_limit( + compressed_bytes, + uncompressed_len, + ) + .map_err(|e| anyhow!("{e:?}"))?; + ensure!(uncompressed_bytes_vec.len() == uncompressed_len); + + &uncompressed_bytes_vec + }; + + // Symbol names in the payload are separated by `0x01` bytes. + for raw_name in uncompressed_bytes.split(|&b| b == 0x01) { + let hash = truncated_md5(raw_name); + let demangled = demangle_if_able(raw_name)?; + map.insert(hash, demangled); + } + + parser.ensure_empty()?; + } + + Ok(map) +} From 004db4728bc6ccc62416f93ba6473b144def7fe8 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 14 Aug 2023 13:00:28 +1000 Subject: [PATCH 57/73] Add test suite `coverage-map` to test coverage mappings emitted by LLVM We compile each test file to LLVM IR assembly, and then pass that IR to a dedicated program that can decode LLVM coverage maps and print them in a more human-readable format. We can then check that output against known-good snapshots. This test suite has some advantages over the existing `run-coverage` tests: - We can test coverage instrumentation without needing to run target binaries. - We can observe subtle improvements/regressions in the underlying coverage mappings that don't make a visible difference to coverage reports. --- src/bootstrap/builder.rs | 1 + src/bootstrap/test.rs | 14 +++ src/tools/compiletest/src/common.rs | 6 + src/tools/compiletest/src/lib.rs | 2 + src/tools/compiletest/src/runtest.rs | 71 ++++++++++- tests/coverage-map/if.cov-map | 15 +++ tests/coverage-map/if.rs | 9 ++ tests/coverage-map/long_and_wide.cov-map | 32 +++++ tests/coverage-map/long_and_wide.rs | 150 +++++++++++++++++++++++ tests/coverage-map/trivial.cov-map | 8 ++ tests/coverage-map/trivial.rs | 3 + 11 files changed, 306 insertions(+), 5 deletions(-) create mode 100644 tests/coverage-map/if.cov-map create mode 100644 tests/coverage-map/if.rs create mode 100644 tests/coverage-map/long_and_wide.cov-map create mode 100644 tests/coverage-map/long_and_wide.rs create mode 100644 tests/coverage-map/trivial.cov-map create mode 100644 tests/coverage-map/trivial.rs diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 73c0a192cef94..a24a6a4636d48 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -726,6 +726,7 @@ impl<'a> Builder<'a> { test::Tidy, test::Ui, test::RunPassValgrind, + test::CoverageMap, test::RunCoverage, test::MirOpt, test::Codegen, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index d1018978f78c9..d78e0deda69f0 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1340,6 +1340,12 @@ host_test!(RunMakeFullDeps { default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" }); +default_test!(CoverageMap { + path: "tests/coverage-map", + mode: "coverage-map", + suite: "coverage-map" +}); + host_test!(RunCoverage { path: "tests/run-coverage", mode: "run-coverage", suite: "run-coverage" }); host_test!(RunCoverageRustdoc { path: "tests/run-coverage-rustdoc", @@ -1545,6 +1551,14 @@ note: if you're sure you want to do this, please open an issue as to why. In the .arg(builder.ensure(tool::JsonDocLint { compiler: json_compiler, target })); } + if mode == "coverage-map" { + let coverage_dump = builder.ensure(tool::CoverageDump { + compiler: compiler.with_stage(0), + target: compiler.host, + }); + cmd.arg("--coverage-dump-path").arg(coverage_dump); + } + if mode == "run-make" || mode == "run-coverage" { let rust_demangler = builder .ensure(tool::RustDemangler { diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 7c17e92d0dfe2..b91d5a958bb62 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -66,6 +66,7 @@ string_enum! { JsDocTest => "js-doc-test", MirOpt => "mir-opt", Assembly => "assembly", + CoverageMap => "coverage-map", RunCoverage => "run-coverage", } } @@ -161,6 +162,9 @@ pub struct Config { /// The rust-demangler executable. pub rust_demangler_path: Option, + /// The coverage-dump executable. + pub coverage_dump_path: Option, + /// The Python executable to use for LLDB and htmldocck. pub python: String, @@ -639,6 +643,7 @@ pub const UI_EXTENSIONS: &[&str] = &[ UI_STDERR_32, UI_STDERR_16, UI_COVERAGE, + UI_COVERAGE_MAP, ]; pub const UI_STDERR: &str = "stderr"; pub const UI_STDOUT: &str = "stdout"; @@ -649,6 +654,7 @@ pub const UI_STDERR_64: &str = "64bit.stderr"; pub const UI_STDERR_32: &str = "32bit.stderr"; pub const UI_STDERR_16: &str = "16bit.stderr"; pub const UI_COVERAGE: &str = "coverage"; +pub const UI_COVERAGE_MAP: &str = "cov-map"; /// Absolute path to the directory where all output for all tests in the given /// `relative_dir` group should reside. Example: diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 1a765477fe501..619ff9b322114 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -48,6 +48,7 @@ pub fn parse_config(args: Vec) -> Config { .reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH") .optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH") .optopt("", "rust-demangler-path", "path to rust-demangler to use in tests", "PATH") + .optopt("", "coverage-dump-path", "path to coverage-dump to use in tests", "PATH") .reqopt("", "python", "path to python to use for doc tests", "PATH") .optopt("", "jsondocck-path", "path to jsondocck to use for doc tests", "PATH") .optopt("", "jsondoclint-path", "path to jsondoclint to use for doc tests", "PATH") @@ -218,6 +219,7 @@ pub fn parse_config(args: Vec) -> Config { rustc_path: opt_path(matches, "rustc-path"), rustdoc_path: matches.opt_str("rustdoc-path").map(PathBuf::from), rust_demangler_path: matches.opt_str("rust-demangler-path").map(PathBuf::from), + coverage_dump_path: matches.opt_str("coverage-dump-path").map(PathBuf::from), python: matches.opt_str("python").unwrap(), jsondocck_path: matches.opt_str("jsondocck-path"), jsondoclint_path: matches.opt_str("jsondoclint-path"), diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index dd4c59fdff513..670441aacbd08 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -6,8 +6,8 @@ use crate::common::{Assembly, Incremental, JsDocTest, MirOpt, RunMake, RustdocJs use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc}; use crate::common::{CompareMode, FailMode, PassMode}; use crate::common::{Config, TestPaths}; -use crate::common::{Pretty, RunCoverage, RunPassValgrind}; -use crate::common::{UI_COVERAGE, UI_RUN_STDERR, UI_RUN_STDOUT}; +use crate::common::{CoverageMap, Pretty, RunCoverage, RunPassValgrind}; +use crate::common::{UI_COVERAGE, UI_COVERAGE_MAP, UI_RUN_STDERR, UI_RUN_STDOUT}; use crate::compute_diff::{write_diff, write_filtered_diff}; use crate::errors::{self, Error, ErrorKind}; use crate::header::TestProps; @@ -254,6 +254,7 @@ impl<'test> TestCx<'test> { MirOpt => self.run_mir_opt_test(), Assembly => self.run_assembly_test(), JsDocTest => self.run_js_doc_test(), + CoverageMap => self.run_coverage_map_test(), RunCoverage => self.run_coverage_test(), } } @@ -467,6 +468,46 @@ impl<'test> TestCx<'test> { } } + fn run_coverage_map_test(&self) { + let Some(coverage_dump_path) = &self.config.coverage_dump_path else { + self.fatal("missing --coverage-dump"); + }; + + let proc_res = self.compile_test_and_save_ir(); + if !proc_res.status.success() { + self.fatal_proc_rec("compilation failed!", &proc_res); + } + drop(proc_res); + + let llvm_ir_path = self.output_base_name().with_extension("ll"); + + let mut dump_command = Command::new(coverage_dump_path); + dump_command.arg(llvm_ir_path); + let proc_res = self.run_command_to_procres(&mut dump_command); + if !proc_res.status.success() { + self.fatal_proc_rec("coverage-dump failed!", &proc_res); + } + + let kind = UI_COVERAGE_MAP; + + let expected_coverage_dump = self.load_expected_output(kind); + let actual_coverage_dump = self.normalize_output(&proc_res.stdout, &[]); + + let coverage_dump_errors = self.compare_output( + kind, + &actual_coverage_dump, + &expected_coverage_dump, + self.props.compare_output_lines_by_subset, + ); + + if coverage_dump_errors > 0 { + self.fatal_proc_rec( + &format!("{coverage_dump_errors} errors occurred comparing coverage output."), + &proc_res, + ); + } + } + fn run_coverage_test(&self) { let should_run = self.run_if_enabled(); let proc_res = self.compile_test(should_run, Emit::None); @@ -650,6 +691,10 @@ impl<'test> TestCx<'test> { let mut cmd = Command::new(tool_path); configure_cmd_fn(&mut cmd); + self.run_command_to_procres(&mut cmd) + } + + fn run_command_to_procres(&self, cmd: &mut Command) -> ProcRes { let output = cmd.output().unwrap_or_else(|_| panic!("failed to exec `{cmd:?}`")); let proc_res = ProcRes { @@ -2321,9 +2366,11 @@ impl<'test> TestCx<'test> { } } DebugInfo => { /* debuginfo tests must be unoptimized */ } - RunCoverage => { - // Coverage reports are affected by optimization level, and - // the current snapshots assume no optimization by default. + CoverageMap | RunCoverage => { + // Coverage mappings and coverage reports are affected by + // optimization level, so they ignore the optimize-tests + // setting and set an optimization level in their mode's + // compile flags (below) or in per-test `compile-flags`. } _ => { rustc.arg("-O"); @@ -2392,8 +2439,22 @@ impl<'test> TestCx<'test> { rustc.arg(dir_opt); } + CoverageMap => { + rustc.arg("-Cinstrument-coverage"); + // These tests only compile to MIR, so they don't need the + // profiler runtime to be present. + rustc.arg("-Zno-profiler-runtime"); + // Coverage mappings are sensitive to MIR optimizations, and + // the current snapshots assume `opt-level=2` unless overridden + // by `compile-flags`. + rustc.arg("-Copt-level=2"); + } RunCoverage => { rustc.arg("-Cinstrument-coverage"); + // Coverage reports are sometimes sensitive to optimizations, + // and the current snapshots assume no optimization unless + // overridden by `compile-flags`. + rustc.arg("-Copt-level=0"); } RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake | CodegenUnits | JsDocTest | Assembly => { diff --git a/tests/coverage-map/if.cov-map b/tests/coverage-map/if.cov-map new file mode 100644 index 0000000000000..3cedb5ffbecb1 --- /dev/null +++ b/tests/coverage-map/if.cov-map @@ -0,0 +1,15 @@ +Function name: if::main +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 3, 1) to (start + 2, 12) +- Code(Counter(1)) at (prev + 2, 13) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 1, 2) + = (c1 + (c0 - c1)) + diff --git a/tests/coverage-map/if.rs b/tests/coverage-map/if.rs new file mode 100644 index 0000000000000..ed3f69bdc98d2 --- /dev/null +++ b/tests/coverage-map/if.rs @@ -0,0 +1,9 @@ +// compile-flags: --edition=2021 + +fn main() { + let cond = std::env::args().len() == 1; + if cond { + println!("true"); + } + println!("done"); +} diff --git a/tests/coverage-map/long_and_wide.cov-map b/tests/coverage-map/long_and_wide.cov-map new file mode 100644 index 0000000000000..97aebf9b18ab0 --- /dev/null +++ b/tests/coverage-map/long_and_wide.cov-map @@ -0,0 +1,32 @@ +Function name: long_and_wide::far_function +Raw bytes (10): 0x[01, 01, 00, 01, 01, 96, 01, 01, 00, 15] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 150, 1) to (start + 0, 21) + +Function name: long_and_wide::long_function +Raw bytes (10): 0x[01, 01, 00, 01, 01, 10, 01, 84, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 16, 1) to (start + 132, 2) + +Function name: long_and_wide::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 04, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 7, 1) to (start + 4, 2) + +Function name: long_and_wide::wide_function +Raw bytes (10): 0x[01, 01, 00, 01, 01, 0e, 01, 00, 8b, 01] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 14, 1) to (start + 0, 139) + diff --git a/tests/coverage-map/long_and_wide.rs b/tests/coverage-map/long_and_wide.rs new file mode 100644 index 0000000000000..a7cbcd4802791 --- /dev/null +++ b/tests/coverage-map/long_and_wide.rs @@ -0,0 +1,150 @@ +// compile-flags: --edition=2021 +// ignore-tidy-linelength + +// This file deliberately contains line and column numbers larger than 127, +// to verify that `coverage-dump`'s ULEB128 parser can handle them. + +fn main() { + wide_function(); + long_function(); + far_function(); +} + +#[rustfmt::skip] +fn wide_function() { /* */ (); } + +fn long_function() { + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // +} + +fn far_function() {} diff --git a/tests/coverage-map/trivial.cov-map b/tests/coverage-map/trivial.cov-map new file mode 100644 index 0000000000000..874e294a1c498 --- /dev/null +++ b/tests/coverage-map/trivial.cov-map @@ -0,0 +1,8 @@ +Function name: trivial::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 01, 00, 0d] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 13) + diff --git a/tests/coverage-map/trivial.rs b/tests/coverage-map/trivial.rs new file mode 100644 index 0000000000000..d0a9b44fb3605 --- /dev/null +++ b/tests/coverage-map/trivial.rs @@ -0,0 +1,3 @@ +// compile-flags: --edition=2021 + +fn main() {} From 3141177995f52fc3cbb64d66cf0a98ea0f754fca Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 14 Aug 2023 21:29:41 +1000 Subject: [PATCH 58/73] Copy most of `tests/run-coverage` into `tests/coverage-map/status-quo` The output of these tests is too complicated to comfortably verify by hand, but we can still use them to observe changes to the underlying mappings produced by codegen/LLVM. If these tests fail due to non-coverage changes (e.g. in HIR-to-MIR lowering or MIR optimizations), it should usually be OK to just `--bless` them, as long as the `run-coverage` test suite still works. --- tests/coverage-map/README.md | 13 + tests/coverage-map/status-quo/abort.cov-map | 57 +++ tests/coverage-map/status-quo/abort.rs | 66 ++++ tests/coverage-map/status-quo/assert.cov-map | 40 +++ tests/coverage-map/status-quo/assert.rs | 32 ++ tests/coverage-map/status-quo/async.cov-map | 340 ++++++++++++++++++ tests/coverage-map/status-quo/async.rs | 128 +++++++ tests/coverage-map/status-quo/async2.cov-map | 136 +++++++ tests/coverage-map/status-quo/async2.rs | 57 +++ tests/coverage-map/status-quo/closure.cov-map | 324 +++++++++++++++++ tests/coverage-map/status-quo/closure.rs | 220 ++++++++++++ .../status-quo/closure_macro.cov-map | 40 +++ .../coverage-map/status-quo/closure_macro.rs | 40 +++ .../status-quo/closure_macro_async.cov-map | 48 +++ .../status-quo/closure_macro_async.rs | 77 ++++ .../status-quo/conditions.cov-map | 261 ++++++++++++++ tests/coverage-map/status-quo/conditions.rs | 86 +++++ .../coverage-map/status-quo/continue.cov-map | 85 +++++ tests/coverage-map/status-quo/continue.rs | 69 ++++ .../coverage-map/status-quo/dead_code.cov-map | 37 ++ tests/coverage-map/status-quo/dead_code.rs | 37 ++ .../status-quo/drop_trait.cov-map | 21 ++ tests/coverage-map/status-quo/drop_trait.rs | 33 ++ .../coverage-map/status-quo/generator.cov-map | 58 +++ tests/coverage-map/status-quo/generator.rs | 30 ++ .../coverage-map/status-quo/generics.cov-map | 45 +++ tests/coverage-map/status-quo/generics.rs | 44 +++ tests/coverage-map/status-quo/if.cov-map | 15 + tests/coverage-map/status-quo/if.rs | 28 ++ tests/coverage-map/status-quo/if_else.cov-map | 25 ++ tests/coverage-map/status-quo/if_else.rs | 40 +++ .../status-quo/inline-dead.cov-map | 45 +++ tests/coverage-map/status-quo/inline-dead.rs | 27 ++ tests/coverage-map/status-quo/inline.cov-map | 82 +++++ tests/coverage-map/status-quo/inline.rs | 51 +++ .../status-quo/inner_items.cov-map | 49 +++ tests/coverage-map/status-quo/inner_items.rs | 57 +++ .../status-quo/issue-83601.cov-map | 28 ++ tests/coverage-map/status-quo/issue-83601.rs | 14 + .../status-quo/issue-84561.cov-map | 233 ++++++++++++ tests/coverage-map/status-quo/issue-84561.rs | 182 ++++++++++ .../status-quo/issue-93054.cov-map | 24 ++ tests/coverage-map/status-quo/issue-93054.rs | 30 ++ .../status-quo/lazy_boolean.cov-map | 223 ++++++++++++ tests/coverage-map/status-quo/lazy_boolean.rs | 61 ++++ .../status-quo/loop_break_value.cov-map | 8 + .../status-quo/loop_break_value.rs | 13 + .../status-quo/loops_branches.cov-map | 193 ++++++++++ .../coverage-map/status-quo/loops_branches.rs | 60 ++++ .../status-quo/match_or_pattern.cov-map | 83 +++++ .../status-quo/match_or_pattern.rs | 43 +++ .../status-quo/nested_loops.cov-map | 51 +++ tests/coverage-map/status-quo/nested_loops.rs | 25 ++ .../status-quo/no_cov_crate.cov-map | 78 ++++ tests/coverage-map/status-quo/no_cov_crate.rs | 88 +++++ .../coverage-map/status-quo/overflow.cov-map | 43 +++ tests/coverage-map/status-quo/overflow.rs | 63 ++++ .../status-quo/panic_unwind.cov-map | 40 +++ tests/coverage-map/status-quo/panic_unwind.rs | 31 ++ .../status-quo/partial_eq.cov-map | 64 ++++ tests/coverage-map/status-quo/partial_eq.rs | 46 +++ .../status-quo/simple_loop.cov-map | 28 ++ tests/coverage-map/status-quo/simple_loop.rs | 35 ++ .../status-quo/simple_match.cov-map | 36 ++ tests/coverage-map/status-quo/simple_match.rs | 43 +++ .../status-quo/sort_groups.cov-map | 68 ++++ tests/coverage-map/status-quo/sort_groups.rs | 23 ++ .../status-quo/test_harness.cov-map | 24 ++ tests/coverage-map/status-quo/test_harness.rs | 10 + .../status-quo/tight_inf_loop.cov-map | 12 + .../coverage-map/status-quo/tight_inf_loop.rs | 5 + .../status-quo/try_error_result.cov-map | 226 ++++++++++++ .../status-quo/try_error_result.rs | 118 ++++++ tests/coverage-map/status-quo/unused.cov-map | 94 +++++ tests/coverage-map/status-quo/unused.rs | 41 +++ tests/coverage-map/status-quo/while.cov-map | 15 + tests/coverage-map/status-quo/while.rs | 5 + .../status-quo/while_early_ret.cov-map | 26 ++ .../status-quo/while_early_ret.rs | 42 +++ tests/coverage-map/status-quo/yield.cov-map | 72 ++++ tests/coverage-map/status-quo/yield.rs | 37 ++ 81 files changed, 5527 insertions(+) create mode 100644 tests/coverage-map/README.md create mode 100644 tests/coverage-map/status-quo/abort.cov-map create mode 100644 tests/coverage-map/status-quo/abort.rs create mode 100644 tests/coverage-map/status-quo/assert.cov-map create mode 100644 tests/coverage-map/status-quo/assert.rs create mode 100644 tests/coverage-map/status-quo/async.cov-map create mode 100644 tests/coverage-map/status-quo/async.rs create mode 100644 tests/coverage-map/status-quo/async2.cov-map create mode 100644 tests/coverage-map/status-quo/async2.rs create mode 100644 tests/coverage-map/status-quo/closure.cov-map create mode 100644 tests/coverage-map/status-quo/closure.rs create mode 100644 tests/coverage-map/status-quo/closure_macro.cov-map create mode 100644 tests/coverage-map/status-quo/closure_macro.rs create mode 100644 tests/coverage-map/status-quo/closure_macro_async.cov-map create mode 100644 tests/coverage-map/status-quo/closure_macro_async.rs create mode 100644 tests/coverage-map/status-quo/conditions.cov-map create mode 100644 tests/coverage-map/status-quo/conditions.rs create mode 100644 tests/coverage-map/status-quo/continue.cov-map create mode 100644 tests/coverage-map/status-quo/continue.rs create mode 100644 tests/coverage-map/status-quo/dead_code.cov-map create mode 100644 tests/coverage-map/status-quo/dead_code.rs create mode 100644 tests/coverage-map/status-quo/drop_trait.cov-map create mode 100644 tests/coverage-map/status-quo/drop_trait.rs create mode 100644 tests/coverage-map/status-quo/generator.cov-map create mode 100644 tests/coverage-map/status-quo/generator.rs create mode 100644 tests/coverage-map/status-quo/generics.cov-map create mode 100644 tests/coverage-map/status-quo/generics.rs create mode 100644 tests/coverage-map/status-quo/if.cov-map create mode 100644 tests/coverage-map/status-quo/if.rs create mode 100644 tests/coverage-map/status-quo/if_else.cov-map create mode 100644 tests/coverage-map/status-quo/if_else.rs create mode 100644 tests/coverage-map/status-quo/inline-dead.cov-map create mode 100644 tests/coverage-map/status-quo/inline-dead.rs create mode 100644 tests/coverage-map/status-quo/inline.cov-map create mode 100644 tests/coverage-map/status-quo/inline.rs create mode 100644 tests/coverage-map/status-quo/inner_items.cov-map create mode 100644 tests/coverage-map/status-quo/inner_items.rs create mode 100644 tests/coverage-map/status-quo/issue-83601.cov-map create mode 100644 tests/coverage-map/status-quo/issue-83601.rs create mode 100644 tests/coverage-map/status-quo/issue-84561.cov-map create mode 100644 tests/coverage-map/status-quo/issue-84561.rs create mode 100644 tests/coverage-map/status-quo/issue-93054.cov-map create mode 100644 tests/coverage-map/status-quo/issue-93054.rs create mode 100644 tests/coverage-map/status-quo/lazy_boolean.cov-map create mode 100644 tests/coverage-map/status-quo/lazy_boolean.rs create mode 100644 tests/coverage-map/status-quo/loop_break_value.cov-map create mode 100644 tests/coverage-map/status-quo/loop_break_value.rs create mode 100644 tests/coverage-map/status-quo/loops_branches.cov-map create mode 100644 tests/coverage-map/status-quo/loops_branches.rs create mode 100644 tests/coverage-map/status-quo/match_or_pattern.cov-map create mode 100644 tests/coverage-map/status-quo/match_or_pattern.rs create mode 100644 tests/coverage-map/status-quo/nested_loops.cov-map create mode 100644 tests/coverage-map/status-quo/nested_loops.rs create mode 100644 tests/coverage-map/status-quo/no_cov_crate.cov-map create mode 100644 tests/coverage-map/status-quo/no_cov_crate.rs create mode 100644 tests/coverage-map/status-quo/overflow.cov-map create mode 100644 tests/coverage-map/status-quo/overflow.rs create mode 100644 tests/coverage-map/status-quo/panic_unwind.cov-map create mode 100644 tests/coverage-map/status-quo/panic_unwind.rs create mode 100644 tests/coverage-map/status-quo/partial_eq.cov-map create mode 100644 tests/coverage-map/status-quo/partial_eq.rs create mode 100644 tests/coverage-map/status-quo/simple_loop.cov-map create mode 100644 tests/coverage-map/status-quo/simple_loop.rs create mode 100644 tests/coverage-map/status-quo/simple_match.cov-map create mode 100644 tests/coverage-map/status-quo/simple_match.rs create mode 100644 tests/coverage-map/status-quo/sort_groups.cov-map create mode 100644 tests/coverage-map/status-quo/sort_groups.rs create mode 100644 tests/coverage-map/status-quo/test_harness.cov-map create mode 100644 tests/coverage-map/status-quo/test_harness.rs create mode 100644 tests/coverage-map/status-quo/tight_inf_loop.cov-map create mode 100644 tests/coverage-map/status-quo/tight_inf_loop.rs create mode 100644 tests/coverage-map/status-quo/try_error_result.cov-map create mode 100644 tests/coverage-map/status-quo/try_error_result.rs create mode 100644 tests/coverage-map/status-quo/unused.cov-map create mode 100644 tests/coverage-map/status-quo/unused.rs create mode 100644 tests/coverage-map/status-quo/while.cov-map create mode 100644 tests/coverage-map/status-quo/while.rs create mode 100644 tests/coverage-map/status-quo/while_early_ret.cov-map create mode 100644 tests/coverage-map/status-quo/while_early_ret.rs create mode 100644 tests/coverage-map/status-quo/yield.cov-map create mode 100644 tests/coverage-map/status-quo/yield.rs diff --git a/tests/coverage-map/README.md b/tests/coverage-map/README.md new file mode 100644 index 0000000000000..60d1352cd64f1 --- /dev/null +++ b/tests/coverage-map/README.md @@ -0,0 +1,13 @@ +The tests in `./status-quo` were copied from `tests/run-coverage` in order to +capture the current behavior of the instrumentor on non-trivial programs. +The actual mappings have not been closely inspected. + +## Maintenance note + +These tests can be sensitive to small changes in MIR spans or MIR control flow, +especially in HIR-to-MIR lowering or MIR optimizations. + +If you haven't touched the coverage code directly, and the `run-coverage` test +suite still works, then it should usually be OK to just `--bless` these +coverage mapping tests as necessary, without worrying too much about the exact +changes. diff --git a/tests/coverage-map/status-quo/abort.cov-map b/tests/coverage-map/status-quo/abort.cov-map new file mode 100644 index 0000000000000..45d3795eff8f3 --- /dev/null +++ b/tests/coverage-map/status-quo/abort.cov-map @@ -0,0 +1,57 @@ +Function name: abort::main +Raw bytes (105): 0x[01, 01, 12, 01, 47, 05, 09, 03, 0d, 42, 11, 03, 0d, 11, 3e, 42, 11, 03, 0d, 3b, 15, 11, 3e, 42, 11, 03, 0d, 15, 36, 3b, 15, 11, 3e, 42, 11, 03, 0d, 05, 09, 0d, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 42, 01, 0c, 00, 19, 11, 00, 1a, 02, 0a, 3e, 02, 0a, 00, 0b, 3b, 02, 0c, 00, 19, 15, 00, 1a, 00, 31, 36, 00, 31, 00, 32, 33, 04, 0c, 00, 19, 05, 00, 1a, 00, 31, 09, 00, 31, 00, 32, 47, 01, 09, 00, 17, 0d, 02, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 18 +- expression 0 operands: lhs = Counter(0), rhs = Expression(17, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Expression(16, Sub), rhs = Counter(4) +- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(4), rhs = Expression(15, Sub) +- expression 6 operands: lhs = Expression(16, Sub), rhs = Counter(4) +- expression 7 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 8 operands: lhs = Expression(14, Add), rhs = Counter(5) +- expression 9 operands: lhs = Counter(4), rhs = Expression(15, Sub) +- expression 10 operands: lhs = Expression(16, Sub), rhs = Counter(4) +- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 12 operands: lhs = Counter(5), rhs = Expression(13, Sub) +- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(5) +- expression 14 operands: lhs = Counter(4), rhs = Expression(15, Sub) +- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(4) +- expression 16 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 17 operands: lhs = Counter(1), rhs = Counter(2) +Number of file 0 mappings: 13 +- Code(Counter(0)) at (prev + 13, 1) to (start + 1, 27) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) + = (c0 + (c1 + c2)) +- Code(Expression(16, Sub)) at (prev + 1, 12) to (start + 0, 25) + = ((c0 + (c1 + c2)) - c3) +- Code(Counter(4)) at (prev + 0, 26) to (start + 2, 10) +- Code(Expression(15, Sub)) at (prev + 2, 10) to (start + 0, 11) + = (((c0 + (c1 + c2)) - c3) - c4) +- Code(Expression(14, Add)) at (prev + 2, 12) to (start + 0, 25) + = (c4 + (((c0 + (c1 + c2)) - c3) - c4)) +- Code(Counter(5)) at (prev + 0, 26) to (start + 0, 49) +- Code(Expression(13, Sub)) at (prev + 0, 49) to (start + 0, 50) + = ((c4 + (((c0 + (c1 + c2)) - c3) - c4)) - c5) +- Code(Expression(12, Add)) at (prev + 4, 12) to (start + 0, 25) + = (c5 + ((c4 + (((c0 + (c1 + c2)) - c3) - c4)) - c5)) +- Code(Counter(1)) at (prev + 0, 26) to (start + 0, 49) +- Code(Counter(2)) at (prev + 0, 49) to (start + 0, 50) +- Code(Expression(17, Add)) at (prev + 1, 9) to (start + 0, 23) + = (c1 + c2) +- Code(Counter(3)) at (prev + 2, 5) to (start + 1, 2) + +Function name: abort::might_abort +Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 01, 14, 05, 02, 09, 01, 24, 02, 02, 0c, 03, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20) +- Code(Counter(1)) at (prev + 2, 9) to (start + 1, 36) +- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 3, 2) + = (c0 - c1) + diff --git a/tests/coverage-map/status-quo/abort.rs b/tests/coverage-map/status-quo/abort.rs new file mode 100644 index 0000000000000..98264bdc1afe5 --- /dev/null +++ b/tests/coverage-map/status-quo/abort.rs @@ -0,0 +1,66 @@ +#![feature(c_unwind)] +#![allow(unused_assignments)] + +extern "C" fn might_abort(should_abort: bool) { + if should_abort { + println!("aborting..."); + panic!("panics and aborts"); + } else { + println!("Don't Panic"); + } +} + +fn main() -> Result<(), u8> { + let mut countdown = 10; + while countdown > 0 { + if countdown < 5 { + might_abort(false); + } + // See discussion (below the `Notes` section) on coverage results for the closing brace. + if countdown < 5 { might_abort(false); } // Counts for different regions on one line. + // For the following example, the closing brace is the last character on the line. + // This shows the character after the closing brace is highlighted, even if that next + // character is a newline. + if countdown < 5 { might_abort(false); } + countdown -= 1; + } + Ok(()) +} + +// Notes: +// 1. Compare this program and its coverage results to those of the similar tests +// `panic_unwind.rs` and `try_error_result.rs`. +// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`. +// 3. The test does not invoke the abort. By executing to a successful completion, the coverage +// results show where the program did and did not execute. +// 4. If the program actually aborted, the coverage counters would not be saved (which "works as +// intended"). Coverage results would show no executed coverage regions. +// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status +// (on Linux at least). + +/* + +Expect the following coverage results: + +```text + 16| 11| while countdown > 0 { + 17| 10| if countdown < 5 { + 18| 4| might_abort(false); + 19| 6| } +``` + +This is actually correct. + +The condition `countdown < 5` executed 10 times (10 loop iterations). + +It evaluated to `true` 4 times, and executed the `might_abort()` call. + +It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit +`else`, the coverage implementation injects a counter, at the character immediately after the `if`s +closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the +non-true condition. + +As another example of why this is important, say the condition was `countdown < 50`, which is always +`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called. +The closing brace would have a count of `0`, highlighting the missed coverage. +*/ diff --git a/tests/coverage-map/status-quo/assert.cov-map b/tests/coverage-map/status-quo/assert.cov-map new file mode 100644 index 0000000000000..dd413123de729 --- /dev/null +++ b/tests/coverage-map/status-quo/assert.cov-map @@ -0,0 +1,40 @@ +Function name: assert::main +Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 09, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 8 +- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add) +- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1) +- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 9, 1) to (start + 1, 27) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) + = (c0 + (c1 + (c2 + c3))) +- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) + = ((c0 + (c1 + (c2 + c3))) - c4) +- Code(Counter(1)) at (prev + 0, 27) to (start + 2, 10) +- Code(Expression(4, Sub)) at (prev + 2, 19) to (start + 0, 32) + = (((c0 + (c1 + (c2 + c3))) - c4) - c1) +- Code(Counter(2)) at (prev + 0, 33) to (start + 2, 10) +- Code(Counter(3)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23) + = (c1 + (c2 + c3)) +- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) + +Function name: assert::might_fail_assert +Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 02, 0f, 02, 02, 25, 00, 3d, 05, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 15) +- Code(Expression(0, Sub)) at (prev + 2, 37) to (start + 0, 61) + = (c0 - c1) +- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) + diff --git a/tests/coverage-map/status-quo/assert.rs b/tests/coverage-map/status-quo/assert.rs new file mode 100644 index 0000000000000..85e6662a6adc8 --- /dev/null +++ b/tests/coverage-map/status-quo/assert.rs @@ -0,0 +1,32 @@ +#![allow(unused_assignments)] +// failure-status: 101 + +fn might_fail_assert(one_plus_one: u32) { + println!("does 1 + 1 = {}?", one_plus_one); + assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); +} + +fn main() -> Result<(), u8> { + let mut countdown = 10; + while countdown > 0 { + if countdown == 1 { + might_fail_assert(3); + } else if countdown < 5 { + might_fail_assert(2); + } + countdown -= 1; + } + Ok(()) +} + +// Notes: +// 1. Compare this program and its coverage results to those of the very similar test +// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`. +// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or +// related `assert_*!()` macro. +// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce +// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to +// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails). +// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test +// (and in many other coverage tests). The `Assert` terminator is typically generated by the +// Rust compiler to check for runtime failures, such as numeric overflows. diff --git a/tests/coverage-map/status-quo/async.cov-map b/tests/coverage-map/status-quo/async.cov-map new file mode 100644 index 0000000000000..5f28252ef806e --- /dev/null +++ b/tests/coverage-map/status-quo/async.cov-map @@ -0,0 +1,340 @@ +Function name: async::c +Raw bytes (9): 0x[01, 01, 00, 01, 01, 05, 01, 00, 19] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 25) + +Function name: async::c::{closure#0} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 5, 25) to (start + 1, 14) +- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: async::d +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 01, 00, 14] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 20) + +Function name: async::d::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 14, 00, 19] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 13, 20) to (start + 0, 25) + +Function name: async::e (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 01, 00, 14] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 15, 1) to (start + 0, 20) + +Function name: async::e::{closure#0} (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 14, 00, 19] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 15, 20) to (start + 0, 25) + +Function name: async::executor::block_on::> +Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 6e, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 110, 5) to (start + 10, 54) +- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35) + = ((c0 + c1) - c1) +- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73) + = (c0 + c1) +- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26) + = (((c0 + c1) - c1) + Zero) +- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15) +- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6) + = (((c0 + c1) - c1) + Zero) + +Function name: async::executor::block_on::VTABLE::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 72, 11, 00, 33] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 114, 17) to (start + 0, 51) + +Function name: async::executor::block_on::VTABLE::{closure#1} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 73, 11, 00, 33] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 115, 17) to (start + 0, 51) + +Function name: async::executor::block_on::VTABLE::{closure#2} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 74, 11, 00, 33] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 116, 17) to (start + 0, 51) + +Function name: async::executor::block_on::VTABLE::{closure#3} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 75, 11, 00, 13] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 117, 17) to (start + 0, 19) + +Function name: async::f +Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 00, 14] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 17, 1) to (start + 0, 20) + +Function name: async::f::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 14, 00, 19] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 17, 20) to (start + 0, 25) + +Function name: async::foo (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 1e] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 30) + +Function name: async::foo::{closure#0} (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 1e, 00, 2d] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 19, 30) to (start + 0, 45) + +Function name: async::g +Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 17] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 23) + +Function name: async::g::{closure#0} (unused) +Raw bytes (69): 0x[01, 01, 00, 0d, 00, 15, 17, 01, 0c, 00, 02, 09, 00, 0a, 01, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 13 +- Code(Zero) at (prev + 21, 23) to (start + 1, 12) +- Code(Zero) at (prev + 2, 9) to (start + 0, 10) +- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) +- Code(Zero) at (prev + 0, 18) to (start + 0, 23) +- Code(Zero) at (prev + 0, 27) to (start + 0, 28) +- Code(Zero) at (prev + 0, 32) to (start + 0, 34) +- Code(Zero) at (prev + 1, 9) to (start + 0, 10) +- Code(Zero) at (prev + 0, 14) to (start + 0, 17) +- Code(Zero) at (prev + 0, 18) to (start + 0, 23) +- Code(Zero) at (prev + 0, 27) to (start + 0, 28) +- Code(Zero) at (prev + 0, 32) to (start + 0, 34) +- Code(Zero) at (prev + 1, 14) to (start + 0, 16) +- Code(Zero) at (prev + 2, 1) to (start + 0, 2) + +Function name: async::h +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 00, 16] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 29, 1) to (start + 0, 22) + +Function name: async::h::{closure#0} (unused) +Raw bytes (44): 0x[01, 01, 00, 08, 00, 1d, 16, 03, 0c, 00, 04, 09, 00, 0a, 01, 00, 0e, 00, 13, 00, 00, 14, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 8 +- Code(Zero) at (prev + 29, 22) to (start + 3, 12) +- Code(Zero) at (prev + 4, 9) to (start + 0, 10) +- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 19) +- Code(Zero) at (prev + 0, 20) to (start + 0, 25) +- Code(Zero) at (prev + 0, 26) to (start + 0, 27) +- Code(Zero) at (prev + 0, 32) to (start + 0, 34) +- Code(Zero) at (prev + 1, 14) to (start + 0, 16) +- Code(Zero) at (prev + 2, 1) to (start + 0, 2) + +Function name: async::i +Raw bytes (9): 0x[01, 01, 00, 01, 01, 26, 01, 00, 13] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 38, 1) to (start + 0, 19) + +Function name: async::i::{closure#0} +Raw bytes (84): 0x[01, 01, 05, 01, 00, 0d, 00, 1d, 00, 19, 13, 1d, 21, 0e, 01, 26, 13, 04, 0c, 0d, 05, 09, 00, 0a, 03, 00, 0e, 00, 12, 05, 00, 13, 00, 18, 09, 00, 1c, 00, 21, 07, 00, 27, 00, 2a, 15, 00, 2b, 00, 30, 1d, 01, 09, 00, 0a, 11, 00, 0e, 00, 11, 25, 00, 12, 00, 17, 29, 00, 1b, 00, 20, 0b, 00, 24, 00, 26, 21, 01, 0e, 00, 10, 0f, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Counter(3), rhs = Zero +- expression 2 operands: lhs = Counter(7), rhs = Zero +- expression 3 operands: lhs = Counter(6), rhs = Expression(4, Add) +- expression 4 operands: lhs = Counter(7), rhs = Counter(8) +Number of file 0 mappings: 14 +- Code(Counter(0)) at (prev + 38, 19) to (start + 4, 12) +- Code(Counter(3)) at (prev + 5, 9) to (start + 0, 10) +- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 18) + = (c0 + Zero) +- Code(Counter(1)) at (prev + 0, 19) to (start + 0, 24) +- Code(Counter(2)) at (prev + 0, 28) to (start + 0, 33) +- Code(Expression(1, Add)) at (prev + 0, 39) to (start + 0, 42) + = (c3 + Zero) +- Code(Counter(5)) at (prev + 0, 43) to (start + 0, 48) +- Code(Counter(7)) at (prev + 1, 9) to (start + 0, 10) +- Code(Counter(4)) at (prev + 0, 14) to (start + 0, 17) +- Code(Counter(9)) at (prev + 0, 18) to (start + 0, 23) +- Code(Counter(10)) at (prev + 0, 27) to (start + 0, 32) +- Code(Expression(2, Add)) at (prev + 0, 36) to (start + 0, 38) + = (c7 + Zero) +- Code(Counter(8)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(3, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c6 + (c7 + c8)) + +Function name: async::j +Raw bytes (59): 0x[01, 01, 05, 01, 00, 05, 00, 09, 00, 05, 13, 09, 0d, 09, 01, 31, 01, 13, 0c, 05, 14, 09, 00, 0a, 03, 00, 0e, 00, 1b, 07, 00, 1f, 00, 27, 09, 01, 09, 00, 0a, 11, 00, 0e, 00, 1a, 0b, 00, 1e, 00, 20, 0d, 01, 0e, 00, 10, 0f, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Counter(1), rhs = Zero +- expression 2 operands: lhs = Counter(2), rhs = Zero +- expression 3 operands: lhs = Counter(1), rhs = Expression(4, Add) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 49, 1) to (start + 19, 12) +- Code(Counter(1)) at (prev + 20, 9) to (start + 0, 10) +- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 27) + = (c0 + Zero) +- Code(Expression(1, Add)) at (prev + 0, 31) to (start + 0, 39) + = (c1 + Zero) +- Code(Counter(2)) at (prev + 1, 9) to (start + 0, 10) +- Code(Counter(4)) at (prev + 0, 14) to (start + 0, 26) +- Code(Expression(2, Add)) at (prev + 0, 30) to (start + 0, 32) + = (c2 + Zero) +- Code(Counter(3)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(3, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c1 + (c2 + c3)) + +Function name: async::j::c +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 33, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 51, 5) to (start + 1, 18) +- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 14) +- Code(Expression(0, Sub)) at (prev + 10, 13) to (start + 0, 14) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6) + = (c1 + (c0 - c1)) + +Function name: async::j::d +Raw bytes (9): 0x[01, 01, 00, 01, 01, 42, 05, 00, 17] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 66, 5) to (start + 0, 23) + +Function name: async::j::f +Raw bytes (9): 0x[01, 01, 00, 01, 01, 43, 05, 00, 17] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 67, 5) to (start + 0, 23) + +Function name: async::k (unused) +Raw bytes (29): 0x[01, 01, 00, 05, 01, 4b, 01, 01, 0c, 00, 02, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 5 +- Code(Counter(0)) at (prev + 75, 1) to (start + 1, 12) +- Code(Zero) at (prev + 2, 14) to (start + 0, 16) +- Code(Zero) at (prev + 1, 14) to (start + 0, 16) +- Code(Zero) at (prev + 1, 14) to (start + 0, 16) +- Code(Zero) at (prev + 2, 1) to (start + 0, 2) + +Function name: async::l +Raw bytes (37): 0x[01, 01, 04, 01, 07, 09, 05, 09, 0f, 05, 02, 05, 01, 53, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 4 +- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) +- expression 1 operands: lhs = Counter(2), rhs = Counter(1) +- expression 2 operands: lhs = Counter(2), rhs = Expression(3, Add) +- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 5 +- Code(Counter(0)) at (prev + 83, 1) to (start + 1, 12) +- Code(Expression(0, Sub)) at (prev + 2, 14) to (start + 0, 16) + = (c0 - (c2 + c1)) +- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 16) +- Code(Counter(2)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(2, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c2 + (c1 + (c0 - (c2 + c1)))) + +Function name: async::m +Raw bytes (9): 0x[01, 01, 00, 01, 01, 5b, 01, 00, 19] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 91, 1) to (start + 0, 25) + +Function name: async::m::{closure#0} (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 5b, 19, 00, 22] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 91, 25) to (start + 0, 34) + +Function name: async::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 5d, 01, 08, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 93, 1) to (start + 8, 2) + diff --git a/tests/coverage-map/status-quo/async.rs b/tests/coverage-map/status-quo/async.rs new file mode 100644 index 0000000000000..efd9e62d64e1d --- /dev/null +++ b/tests/coverage-map/status-quo/async.rs @@ -0,0 +1,128 @@ +#![allow(unused_assignments, dead_code)] + +// compile-flags: --edition=2018 -C opt-level=1 + +async fn c(x: u8) -> u8 { + if x == 8 { + 1 + } else { + 0 + } +} + +async fn d() -> u8 { 1 } + +async fn e() -> u8 { 1 } // unused function; executor does not block on `g()` + +async fn f() -> u8 { 1 } + +async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()` + +pub async fn g(x: u8) { + match x { + y if e().await == y => (), + y if f().await == y => (), + _ => (), + } +} + +async fn h(x: usize) { // The function signature is counted when called, but the body is not + // executed (not awaited) so the open brace has a `0` count (at least when + // displayed with `llvm-cov show` in color-mode). + match x { + y if foo().await[y] => (), + _ => (), + } +} + +async fn i(x: u8) { // line coverage is 1, but there are 2 regions: + // (a) the function signature, counted when the function is called; and + // (b) the open brace for the function body, counted once when the body is + // executed asynchronously. + match x { + y if c(x).await == y + 1 => { d().await; } + y if f().await == y + 1 => (), + _ => (), + } +} + +fn j(x: u8) { + // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`. + fn c(x: u8) -> u8 { + if x == 8 { + 1 // This line appears covered, but the 1-character expression span covering the `1` + // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because + // `fn j()` executes the open brace for the function body, followed by the function's + // first executable statement, `match x`. Inner function declarations are not + // "visible" to the MIR for `j()`, so the code region counts all lines between the + // open brace and the first statement as executed, which is, in a sense, true. + // `llvm-cov show` overcomes this kind of situation by showing the actual counts + // of the enclosed coverages, (that is, the `1` expression was not executed, and + // accurately displays a `0`). + } else { + 0 + } + } + fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed + fn f() -> u8 { 1 } + match x { + y if c(x) == y + 1 => { d(); } + y if f() == y + 1 => (), + _ => (), + } +} + +fn k(x: u8) { // unused function + match x { + 1 => (), + 2 => (), + _ => (), + } +} + +fn l(x: u8) { + match x { + 1 => (), + 2 => (), + _ => (), + } +} + +async fn m(x: u8) -> u8 { x - 1 } + +fn main() { + let _ = g(10); + let _ = h(9); + let mut future = Box::pin(i(8)); + j(7); + l(6); + let _ = m(5); + executor::block_on(future.as_mut()); +} + +mod executor { + use core::{ + future::Future, + pin::Pin, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + }; + + pub fn block_on(mut future: F) -> F::Output { + let mut future = unsafe { Pin::new_unchecked(&mut future) }; + use std::hint::unreachable_unchecked; + static VTABLE: RawWakerVTable = RawWakerVTable::new( + |_| unsafe { unreachable_unchecked() }, // clone + |_| unsafe { unreachable_unchecked() }, // wake + |_| unsafe { unreachable_unchecked() }, // wake_by_ref + |_| (), + ); + let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + let mut context = Context::from_waker(&waker); + + loop { + if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + break val; + } + } + } +} diff --git a/tests/coverage-map/status-quo/async2.cov-map b/tests/coverage-map/status-quo/async2.cov-map new file mode 100644 index 0000000000000..fe74dcd88403f --- /dev/null +++ b/tests/coverage-map/status-quo/async2.cov-map @@ -0,0 +1,136 @@ +Function name: async2::async_func +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 01, 00, 17] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 23) + +Function name: async2::async_func::{closure#0} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 17, 03, 09, 05, 03, 0a, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 11, 23) to (start + 3, 9) +- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: async2::async_func_just_println +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 24] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 36) + +Function name: async2::async_func_just_println::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 24, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 19, 36) to (start + 2, 2) + +Function name: async2::executor::block_on:: +Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54) +- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35) + = ((c0 + c1) - c1) +- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73) + = (c0 + c1) +- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26) + = (((c0 + c1) - c1) + Zero) +- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15) +- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6) + = (((c0 + c1) - c1) + Zero) + +Function name: async2::executor::block_on:: +Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54) +- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35) + = ((c0 + c1) - c1) +- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73) + = (c0 + c1) +- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26) + = (((c0 + c1) - c1) + Zero) +- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15) +- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6) + = (((c0 + c1) - c1) + Zero) + +Function name: async2::executor::block_on::VTABLE::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 2b, 11, 00, 33] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 43, 17) to (start + 0, 51) + +Function name: async2::executor::block_on::VTABLE::{closure#1} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 11, 00, 33] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 44, 17) to (start + 0, 51) + +Function name: async2::executor::block_on::VTABLE::{closure#2} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 2d, 11, 00, 33] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 45, 17) to (start + 0, 51) + +Function name: async2::executor::block_on::VTABLE::{closure#3} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 2e, 11, 00, 13] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 46, 17) to (start + 0, 19) + +Function name: async2::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 07, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 23, 1) to (start + 7, 2) + +Function name: async2::non_async_func +Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 03, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 3, 1) to (start + 3, 9) +- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + Zero) + diff --git a/tests/coverage-map/status-quo/async2.rs b/tests/coverage-map/status-quo/async2.rs new file mode 100644 index 0000000000000..2884ff297affd --- /dev/null +++ b/tests/coverage-map/status-quo/async2.rs @@ -0,0 +1,57 @@ +// compile-flags: --edition=2018 + +fn non_async_func() { + println!("non_async_func was covered"); + let b = true; + if b { + println!("non_async_func println in block"); + } +} + +async fn async_func() { + println!("async_func was covered"); + let b = true; + if b { + println!("async_func println in block"); + } +} + +async fn async_func_just_println() { + println!("async_func_just_println was covered"); +} + +fn main() { + println!("codecovsample::main"); + + non_async_func(); + + executor::block_on(async_func()); + executor::block_on(async_func_just_println()); +} + +mod executor { + use core::{ + future::Future, + pin::Pin, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + }; + + pub fn block_on(mut future: F) -> F::Output { + let mut future = unsafe { Pin::new_unchecked(&mut future) }; + use std::hint::unreachable_unchecked; + static VTABLE: RawWakerVTable = RawWakerVTable::new( + |_| unsafe { unreachable_unchecked() }, // clone + |_| unsafe { unreachable_unchecked() }, // wake + |_| unsafe { unreachable_unchecked() }, // wake_by_ref + |_| (), + ); + let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + let mut context = Context::from_waker(&waker); + + loop { + if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + break val; + } + } + } +} diff --git a/tests/coverage-map/status-quo/closure.cov-map b/tests/coverage-map/status-quo/closure.cov-map new file mode 100644 index 0000000000000..f3a32f091a91b --- /dev/null +++ b/tests/coverage-map/status-quo/closure.cov-map @@ -0,0 +1,324 @@ +Function name: closure::main +Raw bytes (170): 0x[01, 01, 17, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 05, 05, 5a, 01, 05, 18, 01, 08, 01, 0f, 0d, 03, 16, 0e, 06, 0a, 07, 10, 05, 13, 0d, 0b, 1a, 0e, 08, 09, 0f, 10, 05, 0e, 09, 13, 16, 05, 0d, 18, 17, 19, 09, 01, 21, 1b, 04, 09, 00, 29, 1f, 01, 09, 00, 2d, 23, 01, 09, 00, 24, 27, 05, 09, 00, 24, 2b, 02, 09, 00, 21, 2f, 04, 09, 00, 21, 33, 04, 09, 00, 28, 37, 09, 09, 00, 32, 3b, 04, 09, 00, 33, 3f, 07, 09, 00, 4b, 43, 08, 09, 01, 09, 47, 0a, 09, 01, 09, 4b, 08, 09, 01, 09, 4f, 0a, 08, 00, 10, 05, 00, 11, 04, 06, 5a, 04, 06, 00, 07, 57, 01, 05, 03, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 23 +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Counter(0), rhs = Zero +- expression 2 operands: lhs = Counter(0), rhs = Zero +- expression 3 operands: lhs = Counter(0), rhs = Zero +- expression 4 operands: lhs = Counter(0), rhs = Zero +- expression 5 operands: lhs = Counter(0), rhs = Zero +- expression 6 operands: lhs = Counter(0), rhs = Zero +- expression 7 operands: lhs = Counter(0), rhs = Zero +- expression 8 operands: lhs = Counter(0), rhs = Zero +- expression 9 operands: lhs = Counter(0), rhs = Zero +- expression 10 operands: lhs = Counter(0), rhs = Zero +- expression 11 operands: lhs = Counter(0), rhs = Zero +- expression 12 operands: lhs = Counter(0), rhs = Zero +- expression 13 operands: lhs = Counter(0), rhs = Zero +- expression 14 operands: lhs = Counter(0), rhs = Zero +- expression 15 operands: lhs = Counter(0), rhs = Zero +- expression 16 operands: lhs = Counter(0), rhs = Zero +- expression 17 operands: lhs = Counter(0), rhs = Zero +- expression 18 operands: lhs = Counter(0), rhs = Zero +- expression 19 operands: lhs = Counter(0), rhs = Zero +- expression 20 operands: lhs = Counter(0), rhs = Counter(1) +- expression 21 operands: lhs = Counter(1), rhs = Expression(22, Sub) +- expression 22 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 24 +- Code(Counter(0)) at (prev + 8, 1) to (start + 15, 13) +- Code(Expression(0, Add)) at (prev + 22, 14) to (start + 6, 10) + = (c0 + Zero) +- Code(Expression(1, Add)) at (prev + 16, 5) to (start + 19, 13) + = (c0 + Zero) +- Code(Expression(2, Add)) at (prev + 26, 14) to (start + 8, 9) + = (c0 + Zero) +- Code(Expression(3, Add)) at (prev + 16, 5) to (start + 14, 9) + = (c0 + Zero) +- Code(Expression(4, Add)) at (prev + 22, 5) to (start + 13, 24) + = (c0 + Zero) +- Code(Expression(5, Add)) at (prev + 25, 9) to (start + 1, 33) + = (c0 + Zero) +- Code(Expression(6, Add)) at (prev + 4, 9) to (start + 0, 41) + = (c0 + Zero) +- Code(Expression(7, Add)) at (prev + 1, 9) to (start + 0, 45) + = (c0 + Zero) +- Code(Expression(8, Add)) at (prev + 1, 9) to (start + 0, 36) + = (c0 + Zero) +- Code(Expression(9, Add)) at (prev + 5, 9) to (start + 0, 36) + = (c0 + Zero) +- Code(Expression(10, Add)) at (prev + 2, 9) to (start + 0, 33) + = (c0 + Zero) +- Code(Expression(11, Add)) at (prev + 4, 9) to (start + 0, 33) + = (c0 + Zero) +- Code(Expression(12, Add)) at (prev + 4, 9) to (start + 0, 40) + = (c0 + Zero) +- Code(Expression(13, Add)) at (prev + 9, 9) to (start + 0, 50) + = (c0 + Zero) +- Code(Expression(14, Add)) at (prev + 4, 9) to (start + 0, 51) + = (c0 + Zero) +- Code(Expression(15, Add)) at (prev + 7, 9) to (start + 0, 75) + = (c0 + Zero) +- Code(Expression(16, Add)) at (prev + 8, 9) to (start + 1, 9) + = (c0 + Zero) +- Code(Expression(17, Add)) at (prev + 10, 9) to (start + 1, 9) + = (c0 + Zero) +- Code(Expression(18, Add)) at (prev + 8, 9) to (start + 1, 9) + = (c0 + Zero) +- Code(Expression(19, Add)) at (prev + 10, 8) to (start + 0, 16) + = (c0 + Zero) +- Code(Counter(1)) at (prev + 0, 17) to (start + 4, 6) +- Code(Expression(22, Sub)) at (prev + 4, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(21, Add)) at (prev + 1, 5) to (start + 3, 2) + = (c1 + (c0 - c1)) + +Function name: closure::main::{closure#0} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 27, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 39, 5) to (start + 2, 20) +- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10) +- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6) + = (c1 + (c0 - c1)) + +Function name: closure::main::{closure#10} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, 9a, 01, 07, 00, 21] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 154, 7) to (start + 0, 33) + +Function name: closure::main::{closure#11} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, 9e, 01, 07, 00, 21] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 158, 7) to (start + 0, 33) + +Function name: closure::main::{closure#12} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, a6, 01, 01, 00, 17] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 166, 1) to (start + 0, 23) + +Function name: closure::main::{closure#13} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, ab, 01, 0d, 02, 0e] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 171, 13) to (start + 2, 14) + +Function name: closure::main::{closure#14} +Raw bytes (38): 0x[01, 01, 04, 05, 0a, 01, 05, 01, 05, 03, 00, 05, 03, b2, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0a, 00, 2f, 00, 33, 0f, 01, 0d, 00, 0e] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 4 +- expression 0 operands: lhs = Counter(1), rhs = Expression(2, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 3 operands: lhs = Expression(0, Add), rhs = Zero +Number of file 0 mappings: 5 +- Code(Expression(0, Add)) at (prev + 178, 13) to (start + 0, 21) + = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 27) +- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37) +- Code(Expression(2, Sub)) at (prev + 0, 47) to (start + 0, 51) + = (c0 - c1) +- Code(Expression(3, Add)) at (prev + 1, 13) to (start + 0, 14) + = ((c1 + (c0 - c1)) + Zero) + +Function name: closure::main::{closure#15} +Raw bytes (45): 0x[01, 01, 05, 05, 0e, 01, 05, 01, 00, 01, 05, 03, 00, 06, 01, ba, 01, 09, 00, 0a, 03, 01, 0d, 00, 15, 0b, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0e, 00, 2f, 00, 33, 13, 02, 09, 00, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(1), rhs = Expression(3, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Zero +- expression 3 operands: lhs = Counter(0), rhs = Counter(1) +- expression 4 operands: lhs = Expression(0, Add), rhs = Zero +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 186, 9) to (start + 0, 10) +- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 0, 21) + = (c1 + (c0 - c1)) +- Code(Expression(2, Add)) at (prev + 1, 17) to (start + 1, 27) + = (c0 + Zero) +- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37) +- Code(Expression(3, Sub)) at (prev + 0, 47) to (start + 0, 51) + = (c0 - c1) +- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 0, 10) + = ((c1 + (c0 - c1)) + Zero) + +Function name: closure::main::{closure#16} +Raw bytes (38): 0x[01, 01, 04, 05, 0a, 01, 05, 01, 05, 03, 00, 05, 03, c4, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0a, 00, 2f, 00, 33, 0f, 01, 0d, 00, 0e] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 4 +- expression 0 operands: lhs = Counter(1), rhs = Expression(2, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 3 operands: lhs = Expression(0, Add), rhs = Zero +Number of file 0 mappings: 5 +- Code(Expression(0, Add)) at (prev + 196, 13) to (start + 0, 21) + = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 27) +- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37) +- Code(Expression(2, Sub)) at (prev + 0, 47) to (start + 0, 51) + = (c0 - c1) +- Code(Expression(3, Add)) at (prev + 1, 13) to (start + 0, 14) + = ((c1 + (c0 - c1)) + Zero) + +Function name: closure::main::{closure#17} +Raw bytes (45): 0x[01, 01, 05, 05, 0e, 01, 05, 01, 00, 01, 05, 03, 00, 06, 01, cc, 01, 09, 00, 0a, 03, 01, 0d, 00, 15, 0b, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0e, 00, 2f, 00, 33, 13, 02, 09, 00, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(1), rhs = Expression(3, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Zero +- expression 3 operands: lhs = Counter(0), rhs = Counter(1) +- expression 4 operands: lhs = Expression(0, Add), rhs = Zero +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 204, 9) to (start + 0, 10) +- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 0, 21) + = (c1 + (c0 - c1)) +- Code(Expression(2, Add)) at (prev + 1, 17) to (start + 1, 27) + = (c0 + Zero) +- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37) +- Code(Expression(3, Sub)) at (prev + 0, 47) to (start + 0, 51) + = (c0 - c1) +- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 0, 10) + = ((c1 + (c0 - c1)) + Zero) + +Function name: closure::main::{closure#18} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 18, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 24, 13) to (start + 2, 28) +- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18) +- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14) + = (c1 + (c0 - c1)) + +Function name: closure::main::{closure#19} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 42, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 66, 13) to (start + 2, 28) +- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18) +- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14) + = (c1 + (c0 - c1)) + +Function name: closure::main::{closure#1} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 51, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 81, 5) to (start + 2, 20) +- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10) +- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6) + = (c1 + (c0 - c1)) + +Function name: closure::main::{closure#2} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 67, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 103, 5) to (start + 2, 20) +- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10) +- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6) + = (c1 + (c0 - c1)) + +Function name: closure::main::{closure#3} (unused) +Raw bytes (25): 0x[01, 01, 00, 04, 01, 80, 01, 05, 01, 14, 00, 01, 15, 02, 0a, 00, 02, 0a, 00, 0b, 00, 01, 09, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 128, 5) to (start + 1, 20) +- Code(Zero) at (prev + 1, 21) to (start + 2, 10) +- Code(Zero) at (prev + 2, 10) to (start + 0, 11) +- Code(Zero) at (prev + 1, 9) to (start + 1, 6) + +Function name: closure::main::{closure#4} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, 88, 01, 35, 00, 43] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 136, 53) to (start + 0, 67) + +Function name: closure::main::{closure#5} +Raw bytes (10): 0x[01, 01, 00, 01, 01, 8b, 01, 3d, 00, 4f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 139, 61) to (start + 0, 79) + +Function name: closure::main::{closure#6} +Raw bytes (10): 0x[01, 01, 00, 01, 01, 8c, 01, 41, 00, 57] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 140, 65) to (start + 0, 87) + +Function name: closure::main::{closure#7} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, 8d, 01, 3b, 00, 51] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 141, 59) to (start + 0, 81) + +Function name: closure::main::{closure#8} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, 92, 01, 3b, 00, 55] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 146, 59) to (start + 0, 85) + +Function name: closure::main::{closure#9} (unused) +Raw bytes (10): 0x[01, 01, 00, 01, 01, 94, 01, 38, 02, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 148, 56) to (start + 2, 6) + diff --git a/tests/coverage-map/status-quo/closure.rs b/tests/coverage-map/status-quo/closure.rs new file mode 100644 index 0000000000000..16a2c4e33bd48 --- /dev/null +++ b/tests/coverage-map/status-quo/closure.rs @@ -0,0 +1,220 @@ +#![allow(unused_assignments, unused_variables)] +// compile-flags: -C opt-level=2 + +// This test used to be sensitive to certain coverage-specific hacks in +// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by +// . + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + let is_false = !is_true; + + let mut some_string = Some(String::from("the string content")); + println!( + "The string or alt: {}" + , + some_string + . + unwrap_or_else + ( + || + { + let mut countdown = 0; + if is_false { + countdown = 10; + } + "alt string 1".to_owned() + } + ) + ); + + some_string = Some(String::from("the string content")); + let + a + = + || + { + let mut countdown = 0; + if is_false { + countdown = 10; + } + "alt string 2".to_owned() + }; + println!( + "The string or alt: {}" + , + some_string + . + unwrap_or_else + ( + a + ) + ); + + some_string = None; + println!( + "The string or alt: {}" + , + some_string + . + unwrap_or_else + ( + || + { + let mut countdown = 0; + if is_false { + countdown = 10; + } + "alt string 3".to_owned() + } + ) + ); + + some_string = None; + let + a + = + || + { + let mut countdown = 0; + if is_false { + countdown = 10; + } + "alt string 4".to_owned() + }; + println!( + "The string or alt: {}" + , + some_string + . + unwrap_or_else + ( + a + ) + ); + + let + quote_closure + = + |val| + { + let mut countdown = 0; + if is_false { + countdown = 10; + } + format!("'{}'", val) + }; + println!( + "Repeated, quoted string: {:?}" + , + std::iter::repeat("repeat me") + .take(5) + .map + ( + quote_closure + ) + .collect::>() + ); + + let + _unused_closure + = + | + mut countdown + | + { + if is_false { + countdown = 10; + } + "closure should be unused".to_owned() + }; + + let mut countdown = 10; + let _short_unused_closure = | _unused_arg: u8 | countdown += 1; + + + let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); + let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); + let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); + + + + + let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") }; + + let _shortish_unused_closure = | _unused_arg: u8 | { + println!("not called") + }; + + let _as_short_unused_closure = | + _unused_arg: u8 + | { println!("not called") }; + + let _almost_as_short_unused_closure = | + _unused_arg: u8 + | { println!("not called") } + ; + + + + + + let _short_unused_closure_line_break_no_block = | _unused_arg: u8 | +println!("not called") + ; + + let _short_unused_closure_line_break_no_block2 = + | _unused_arg: u8 | + println!( + "not called" + ) + ; + + let short_used_not_covered_closure_line_break_no_block_embedded_branch = + | _unused_arg: u8 | + println!( + "not called: {}", + if is_true { "check" } else { "me" } + ) + ; + + let short_used_not_covered_closure_line_break_block_embedded_branch = + | _unused_arg: u8 | + { + println!( + "not called: {}", + if is_true { "check" } else { "me" } + ) + } + ; + + let short_used_covered_closure_line_break_no_block_embedded_branch = + | _unused_arg: u8 | + println!( + "not called: {}", + if is_true { "check" } else { "me" } + ) + ; + + let short_used_covered_closure_line_break_block_embedded_branch = + | _unused_arg: u8 | + { + println!( + "not called: {}", + if is_true { "check" } else { "me" } + ) + } + ; + + if is_false { + short_used_not_covered_closure_macro(0); + short_used_not_covered_closure_line_break_no_block_embedded_branch(0); + short_used_not_covered_closure_line_break_block_embedded_branch(0); + } + short_used_covered_closure_macro(0); + short_used_covered_closure_line_break_no_block_embedded_branch(0); + short_used_covered_closure_line_break_block_embedded_branch(0); +} diff --git a/tests/coverage-map/status-quo/closure_macro.cov-map b/tests/coverage-map/status-quo/closure_macro.cov-map new file mode 100644 index 0000000000000..ac017eb446818 --- /dev/null +++ b/tests/coverage-map/status-quo/closure_macro.cov-map @@ -0,0 +1,40 @@ +Function name: closure_macro::load_configuration_files +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2) + +Function name: closure_macro::main +Raw bytes (49): 0x[01, 01, 05, 01, 05, 02, 00, 05, 00, 02, 00, 05, 02, 07, 01, 21, 01, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 07, 00, 12, 00, 13, 0b, 00, 54, 00, 55, 0f, 02, 09, 02, 0b, 13, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 2 operands: lhs = Counter(1), rhs = Zero +- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 7 +- Code(Counter(0)) at (prev + 33, 1) to (start + 1, 33) +- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15) + = (c0 - c1) +- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) +- Code(Expression(1, Add)) at (prev + 0, 18) to (start + 0, 19) + = ((c0 - c1) + Zero) +- Code(Expression(2, Add)) at (prev + 0, 84) to (start + 0, 85) + = (c1 + Zero) +- Code(Expression(3, Add)) at (prev + 2, 9) to (start + 2, 11) + = ((c0 - c1) + Zero) +- Code(Expression(4, Add)) at (prev + 3, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: closure_macro::main::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 12, 00, 54] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 35, 18) to (start + 0, 84) + diff --git a/tests/coverage-map/status-quo/closure_macro.rs b/tests/coverage-map/status-quo/closure_macro.rs new file mode 100644 index 0000000000000..5e3b00d1ef54b --- /dev/null +++ b/tests/coverage-map/status-quo/closure_macro.rs @@ -0,0 +1,40 @@ +// compile-flags: --edition=2018 +#![feature(no_coverage)] + +macro_rules! bail { + ($msg:literal $(,)?) => { + if $msg.len() > 0 { + println!("no msg"); + } else { + println!($msg); + } + return Err(String::from($msg)); + }; +} + +macro_rules! on_error { + ($value:expr, $error_message:expr) => { + $value.or_else(|e| { // FIXME(85000): no coverage in closure macros + let message = format!($error_message, e); + if message.len() > 0 { + println!("{}", message); + Ok(String::from("ok")) + } else { + bail!("error"); + } + }) + }; +} + +fn load_configuration_files() -> Result { + Ok(String::from("config")) +} + +pub fn main() -> Result<(), String> { + println!("Starting service"); + let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; + + let startup_delay_duration = String::from("arg"); + let _ = (config, startup_delay_duration); + Ok(()) +} diff --git a/tests/coverage-map/status-quo/closure_macro_async.cov-map b/tests/coverage-map/status-quo/closure_macro_async.cov-map new file mode 100644 index 0000000000000..c9a142e5aebcd --- /dev/null +++ b/tests/coverage-map/status-quo/closure_macro_async.cov-map @@ -0,0 +1,48 @@ +Function name: closure_macro_async::load_configuration_files +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2) + +Function name: closure_macro_async::test +Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 00, 2b] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 33, 1) to (start + 0, 43) + +Function name: closure_macro_async::test::{closure#0} +Raw bytes (49): 0x[01, 01, 05, 01, 05, 02, 00, 05, 00, 02, 00, 05, 02, 07, 01, 21, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 07, 00, 12, 00, 13, 0b, 00, 54, 00, 55, 0f, 02, 09, 02, 0b, 13, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 2 operands: lhs = Counter(1), rhs = Zero +- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero +- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 7 +- Code(Counter(0)) at (prev + 33, 43) to (start + 1, 33) +- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15) + = (c0 - c1) +- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) +- Code(Expression(1, Add)) at (prev + 0, 18) to (start + 0, 19) + = ((c0 - c1) + Zero) +- Code(Expression(2, Add)) at (prev + 0, 84) to (start + 0, 85) + = (c1 + Zero) +- Code(Expression(3, Add)) at (prev + 2, 9) to (start + 2, 11) + = ((c0 - c1) + Zero) +- Code(Expression(4, Add)) at (prev + 3, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: closure_macro_async::test::{closure#0}::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 12, 00, 54] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 35, 18) to (start + 0, 84) + diff --git a/tests/coverage-map/status-quo/closure_macro_async.rs b/tests/coverage-map/status-quo/closure_macro_async.rs new file mode 100644 index 0000000000000..3d6bdb38a2ab1 --- /dev/null +++ b/tests/coverage-map/status-quo/closure_macro_async.rs @@ -0,0 +1,77 @@ +// compile-flags: --edition=2018 +#![feature(no_coverage)] + +macro_rules! bail { + ($msg:literal $(,)?) => { + if $msg.len() > 0 { + println!("no msg"); + } else { + println!($msg); + } + return Err(String::from($msg)); + }; +} + +macro_rules! on_error { + ($value:expr, $error_message:expr) => { + $value.or_else(|e| { // FIXME(85000): no coverage in closure macros + let message = format!($error_message, e); + if message.len() > 0 { + println!("{}", message); + Ok(String::from("ok")) + } else { + bail!("error"); + } + }) + }; +} + +fn load_configuration_files() -> Result { + Ok(String::from("config")) +} + +pub async fn test() -> Result<(), String> { + println!("Starting service"); + let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; + + let startup_delay_duration = String::from("arg"); + let _ = (config, startup_delay_duration); + Ok(()) +} + +#[no_coverage] +fn main() { + executor::block_on(test()).unwrap(); +} + +mod executor { + use core::{ + future::Future, + pin::Pin, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + }; + + #[no_coverage] + pub fn block_on(mut future: F) -> F::Output { + let mut future = unsafe { Pin::new_unchecked(&mut future) }; + use std::hint::unreachable_unchecked; + static VTABLE: RawWakerVTable = RawWakerVTable::new( + #[no_coverage] + |_| unsafe { unreachable_unchecked() }, // clone + #[no_coverage] + |_| unsafe { unreachable_unchecked() }, // wake + #[no_coverage] + |_| unsafe { unreachable_unchecked() }, // wake_by_ref + #[no_coverage] + |_| (), + ); + let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + let mut context = Context::from_waker(&waker); + + loop { + if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + break val; + } + } + } +} diff --git a/tests/coverage-map/status-quo/conditions.cov-map b/tests/coverage-map/status-quo/conditions.cov-map new file mode 100644 index 0000000000000..d82b8389b4d0b --- /dev/null +++ b/tests/coverage-map/status-quo/conditions.cov-map @@ -0,0 +1,261 @@ +Function name: conditions::main +Raw bytes (793): 0x[01, 01, 90, 01, 09, 33, 37, 41, 3b, 3d, 35, 39, 05, 00, bf, 04, 09, 05, 00, 0d, 35, 26, 39, 0d, 35, 3b, 3d, 35, 39, 37, 41, 3b, 3d, 35, 39, ba, 04, 0d, bf, 04, 09, 05, 00, 03, 00, 45, 00, 87, 01, 49, 45, 00, 82, 01, 31, 87, 01, 49, 45, 00, 7e, 4d, 82, 01, 31, 87, 01, 49, 45, 00, 7a, 51, 7e, 4d, 82, 01, 31, 87, 01, 49, 45, 00, ab, 01, 55, 4d, 51, a7, 01, 59, ab, 01, 55, 4d, 51, 49, a3, 01, a7, 01, 59, ab, 01, 55, 4d, 51, 61, 00, e7, 01, 65, 61, 00, e2, 01, 2d, e7, 01, 65, 61, 00, de, 01, 69, e2, 01, 2d, e7, 01, 65, 61, 00, da, 01, 6d, de, 01, 69, e2, 01, 2d, e7, 01, 65, 61, 00, 8f, 02, 71, 69, 6d, 8b, 02, 75, 8f, 02, 71, 69, 6d, 83, 02, 00, 65, 87, 02, 8b, 02, 75, 8f, 02, 71, 69, 6d, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, 79, 00, db, 02, 7d, 79, 00, d6, 02, 29, db, 02, 7d, 79, 00, d2, 02, 81, 01, d6, 02, 29, db, 02, 7d, 79, 00, ce, 02, 85, 01, d2, 02, 81, 01, d6, 02, 29, db, 02, 7d, 79, 00, fb, 03, 89, 01, 81, 01, 85, 01, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, 11, 9b, 04, 9f, 04, 21, a3, 04, 1d, 15, 19, ef, 03, 00, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, ea, 03, 25, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, e6, 03, 15, ea, 03, 25, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, e2, 03, 19, e6, 03, 15, ea, 03, 25, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, a3, 04, 1d, 15, 19, 9f, 04, 21, a3, 04, 1d, 15, 19, 97, 04, a7, 04, 11, 9b, 04, 9f, 04, 21, a3, 04, 1d, 15, 19, ab, 04, b6, 04, af, 04, b3, 04, 25, 29, 2d, 31, ba, 04, 0d, bf, 04, 09, 05, 00, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 06, 00, 07, 03, 03, 09, 00, 0a, bf, 04, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, ba, 04, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 26, 00, 1d, 00, 2a, 22, 00, 2e, 00, 3c, 37, 00, 3d, 02, 0a, 41, 02, 0a, 00, 0b, 33, 01, 09, 01, 12, b6, 04, 03, 09, 00, 0f, 4b, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 87, 01, 02, 08, 00, 15, 49, 00, 16, 02, 06, 82, 01, 02, 0f, 00, 1c, 7e, 01, 0c, 00, 19, 7a, 00, 1d, 00, 2a, 76, 00, 2e, 00, 3c, a7, 01, 00, 3d, 02, 0a, 59, 02, 0a, 00, 0b, a3, 01, 01, 09, 00, 17, 31, 02, 09, 00, 0f, 9f, 01, 03, 08, 00, 0c, 5d, 01, 0d, 01, 10, 61, 01, 11, 02, 0a, 00, 02, 0a, 00, 0b, e7, 01, 02, 0c, 00, 19, 65, 00, 1a, 02, 0a, e2, 01, 03, 11, 00, 1e, de, 01, 01, 10, 00, 1d, da, 01, 00, 21, 00, 2e, d6, 01, 00, 32, 00, 40, 8b, 02, 00, 41, 02, 0e, 75, 02, 0e, 00, 0f, 87, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 06, 00, 07, ff, 01, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 06, 00, 07, ef, 03, 02, 09, 00, 0a, db, 02, 00, 10, 00, 1d, 7d, 00, 1e, 02, 06, d6, 02, 02, 0f, 00, 1c, d2, 02, 01, 0c, 00, 19, ce, 02, 00, 1d, 00, 2a, ca, 02, 00, 2e, 00, 3c, f7, 03, 00, 3d, 02, 0a, 8d, 01, 02, 0a, 00, 0b, f3, 03, 01, 09, 00, 17, 29, 02, 0d, 02, 0f, 97, 04, 05, 09, 00, 0a, 83, 03, 00, 10, 00, 1d, 11, 00, 1e, 02, 06, ea, 03, 02, 0f, 00, 1c, e6, 03, 01, 0c, 00, 19, e2, 03, 00, 1d, 00, 2a, de, 03, 00, 2e, 00, 3c, 9f, 04, 00, 3d, 02, 0a, 21, 02, 0a, 00, 0b, 9b, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, 93, 04, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 144 +- expression 0 operands: lhs = Counter(2), rhs = Expression(12, Add) +- expression 1 operands: lhs = Expression(13, Add), rhs = Counter(16) +- expression 2 operands: lhs = Expression(14, Add), rhs = Counter(15) +- expression 3 operands: lhs = Counter(13), rhs = Counter(14) +- expression 4 operands: lhs = Counter(1), rhs = Zero +- expression 5 operands: lhs = Expression(143, Add), rhs = Counter(2) +- expression 6 operands: lhs = Counter(1), rhs = Zero +- expression 7 operands: lhs = Counter(3), rhs = Counter(13) +- expression 8 operands: lhs = Expression(9, Sub), rhs = Counter(14) +- expression 9 operands: lhs = Counter(3), rhs = Counter(13) +- expression 10 operands: lhs = Expression(14, Add), rhs = Counter(15) +- expression 11 operands: lhs = Counter(13), rhs = Counter(14) +- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(16) +- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(15) +- expression 14 operands: lhs = Counter(13), rhs = Counter(14) +- expression 15 operands: lhs = Expression(142, Sub), rhs = Counter(3) +- expression 16 operands: lhs = Expression(143, Add), rhs = Counter(2) +- expression 17 operands: lhs = Counter(1), rhs = Zero +- expression 18 operands: lhs = Expression(0, Add), rhs = Zero +- expression 19 operands: lhs = Counter(17), rhs = Zero +- expression 20 operands: lhs = Expression(33, Add), rhs = Counter(18) +- expression 21 operands: lhs = Counter(17), rhs = Zero +- expression 22 operands: lhs = Expression(32, Sub), rhs = Counter(12) +- expression 23 operands: lhs = Expression(33, Add), rhs = Counter(18) +- expression 24 operands: lhs = Counter(17), rhs = Zero +- expression 25 operands: lhs = Expression(31, Sub), rhs = Counter(19) +- expression 26 operands: lhs = Expression(32, Sub), rhs = Counter(12) +- expression 27 operands: lhs = Expression(33, Add), rhs = Counter(18) +- expression 28 operands: lhs = Counter(17), rhs = Zero +- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(20) +- expression 30 operands: lhs = Expression(31, Sub), rhs = Counter(19) +- expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(12) +- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(18) +- expression 33 operands: lhs = Counter(17), rhs = Zero +- expression 34 operands: lhs = Expression(42, Add), rhs = Counter(21) +- expression 35 operands: lhs = Counter(19), rhs = Counter(20) +- expression 36 operands: lhs = Expression(41, Add), rhs = Counter(22) +- expression 37 operands: lhs = Expression(42, Add), rhs = Counter(21) +- expression 38 operands: lhs = Counter(19), rhs = Counter(20) +- expression 39 operands: lhs = Counter(18), rhs = Expression(40, Add) +- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(22) +- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(21) +- expression 42 operands: lhs = Counter(19), rhs = Counter(20) +- expression 43 operands: lhs = Counter(24), rhs = Zero +- expression 44 operands: lhs = Expression(57, Add), rhs = Counter(25) +- expression 45 operands: lhs = Counter(24), rhs = Zero +- expression 46 operands: lhs = Expression(56, Sub), rhs = Counter(11) +- expression 47 operands: lhs = Expression(57, Add), rhs = Counter(25) +- expression 48 operands: lhs = Counter(24), rhs = Zero +- expression 49 operands: lhs = Expression(55, Sub), rhs = Counter(26) +- expression 50 operands: lhs = Expression(56, Sub), rhs = Counter(11) +- expression 51 operands: lhs = Expression(57, Add), rhs = Counter(25) +- expression 52 operands: lhs = Counter(24), rhs = Zero +- expression 53 operands: lhs = Expression(54, Sub), rhs = Counter(27) +- expression 54 operands: lhs = Expression(55, Sub), rhs = Counter(26) +- expression 55 operands: lhs = Expression(56, Sub), rhs = Counter(11) +- expression 56 operands: lhs = Expression(57, Add), rhs = Counter(25) +- expression 57 operands: lhs = Counter(24), rhs = Zero +- expression 58 operands: lhs = Expression(67, Add), rhs = Counter(28) +- expression 59 operands: lhs = Counter(26), rhs = Counter(27) +- expression 60 operands: lhs = Expression(66, Add), rhs = Counter(29) +- expression 61 operands: lhs = Expression(67, Add), rhs = Counter(28) +- expression 62 operands: lhs = Counter(26), rhs = Counter(27) +- expression 63 operands: lhs = Expression(64, Add), rhs = Zero +- expression 64 operands: lhs = Counter(25), rhs = Expression(65, Add) +- expression 65 operands: lhs = Expression(66, Add), rhs = Counter(29) +- expression 66 operands: lhs = Expression(67, Add), rhs = Counter(28) +- expression 67 operands: lhs = Counter(26), rhs = Counter(27) +- expression 68 operands: lhs = Counter(31), rhs = Expression(124, Add) +- expression 69 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 70 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 71 operands: lhs = Counter(32), rhs = Counter(33) +- expression 72 operands: lhs = Counter(30), rhs = Zero +- expression 73 operands: lhs = Expression(86, Add), rhs = Counter(31) +- expression 74 operands: lhs = Counter(30), rhs = Zero +- expression 75 operands: lhs = Expression(85, Sub), rhs = Counter(10) +- expression 76 operands: lhs = Expression(86, Add), rhs = Counter(31) +- expression 77 operands: lhs = Counter(30), rhs = Zero +- expression 78 operands: lhs = Expression(84, Sub), rhs = Counter(32) +- expression 79 operands: lhs = Expression(85, Sub), rhs = Counter(10) +- expression 80 operands: lhs = Expression(86, Add), rhs = Counter(31) +- expression 81 operands: lhs = Counter(30), rhs = Zero +- expression 82 operands: lhs = Expression(83, Sub), rhs = Counter(33) +- expression 83 operands: lhs = Expression(84, Sub), rhs = Counter(32) +- expression 84 operands: lhs = Expression(85, Sub), rhs = Counter(10) +- expression 85 operands: lhs = Expression(86, Add), rhs = Counter(31) +- expression 86 operands: lhs = Counter(30), rhs = Zero +- expression 87 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 88 operands: lhs = Counter(32), rhs = Counter(33) +- expression 89 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 90 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 91 operands: lhs = Counter(32), rhs = Counter(33) +- expression 92 operands: lhs = Counter(4), rhs = Expression(134, Add) +- expression 93 operands: lhs = Expression(135, Add), rhs = Counter(8) +- expression 94 operands: lhs = Expression(136, Add), rhs = Counter(7) +- expression 95 operands: lhs = Counter(5), rhs = Counter(6) +- expression 96 operands: lhs = Expression(123, Add), rhs = Zero +- expression 97 operands: lhs = Counter(31), rhs = Expression(124, Add) +- expression 98 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 99 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 100 operands: lhs = Counter(32), rhs = Counter(33) +- expression 101 operands: lhs = Expression(123, Add), rhs = Counter(4) +- expression 102 operands: lhs = Counter(31), rhs = Expression(124, Add) +- expression 103 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 104 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 105 operands: lhs = Counter(32), rhs = Counter(33) +- expression 106 operands: lhs = Expression(122, Sub), rhs = Counter(9) +- expression 107 operands: lhs = Expression(123, Add), rhs = Counter(4) +- expression 108 operands: lhs = Counter(31), rhs = Expression(124, Add) +- expression 109 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 110 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 111 operands: lhs = Counter(32), rhs = Counter(33) +- expression 112 operands: lhs = Expression(121, Sub), rhs = Counter(5) +- expression 113 operands: lhs = Expression(122, Sub), rhs = Counter(9) +- expression 114 operands: lhs = Expression(123, Add), rhs = Counter(4) +- expression 115 operands: lhs = Counter(31), rhs = Expression(124, Add) +- expression 116 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 117 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 118 operands: lhs = Counter(32), rhs = Counter(33) +- expression 119 operands: lhs = Expression(120, Sub), rhs = Counter(6) +- expression 120 operands: lhs = Expression(121, Sub), rhs = Counter(5) +- expression 121 operands: lhs = Expression(122, Sub), rhs = Counter(9) +- expression 122 operands: lhs = Expression(123, Add), rhs = Counter(4) +- expression 123 operands: lhs = Counter(31), rhs = Expression(124, Add) +- expression 124 operands: lhs = Expression(125, Add), rhs = Counter(35) +- expression 125 operands: lhs = Expression(126, Add), rhs = Counter(34) +- expression 126 operands: lhs = Counter(32), rhs = Counter(33) +- expression 127 operands: lhs = Expression(136, Add), rhs = Counter(7) +- expression 128 operands: lhs = Counter(5), rhs = Counter(6) +- expression 129 operands: lhs = Expression(135, Add), rhs = Counter(8) +- expression 130 operands: lhs = Expression(136, Add), rhs = Counter(7) +- expression 131 operands: lhs = Counter(5), rhs = Counter(6) +- expression 132 operands: lhs = Expression(133, Add), rhs = Expression(137, Add) +- expression 133 operands: lhs = Counter(4), rhs = Expression(134, Add) +- expression 134 operands: lhs = Expression(135, Add), rhs = Counter(8) +- expression 135 operands: lhs = Expression(136, Add), rhs = Counter(7) +- expression 136 operands: lhs = Counter(5), rhs = Counter(6) +- expression 137 operands: lhs = Expression(138, Add), rhs = Expression(141, Sub) +- expression 138 operands: lhs = Expression(139, Add), rhs = Expression(140, Add) +- expression 139 operands: lhs = Counter(9), rhs = Counter(10) +- expression 140 operands: lhs = Counter(11), rhs = Counter(12) +- expression 141 operands: lhs = Expression(142, Sub), rhs = Counter(3) +- expression 142 operands: lhs = Expression(143, Add), rhs = Counter(2) +- expression 143 operands: lhs = Counter(1), rhs = Zero +Number of file 0 mappings: 68 +- Code(Counter(0)) at (prev + 3, 1) to (start + 2, 12) +- Code(Counter(1)) at (prev + 2, 13) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(0, Add)) at (prev + 3, 9) to (start + 0, 10) + = (c2 + (((c13 + c14) + c15) + c16)) +- Code(Expression(143, Add)) at (prev + 0, 16) to (start + 0, 29) + = (c1 + Zero) +- Code(Counter(2)) at (prev + 1, 9) to (start + 1, 10) +- Code(Expression(142, Sub)) at (prev + 2, 15) to (start + 0, 28) + = ((c1 + Zero) - c2) +- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 25) +- Code(Expression(9, Sub)) at (prev + 0, 29) to (start + 0, 42) + = (c3 - c13) +- Code(Expression(8, Sub)) at (prev + 0, 46) to (start + 0, 60) + = ((c3 - c13) - c14) +- Code(Expression(13, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c13 + c14) + c15) +- Code(Counter(16)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(12, Add)) at (prev + 1, 9) to (start + 1, 18) + = (((c13 + c14) + c15) + c16) +- Code(Expression(141, Sub)) at (prev + 3, 9) to (start + 0, 15) + = (((c1 + Zero) - c2) - c3) +- Code(Expression(18, Add)) at (prev + 3, 9) to (start + 1, 12) + = ((c2 + (((c13 + c14) + c15) + c16)) + Zero) +- Code(Counter(17)) at (prev + 1, 13) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(33, Add)) at (prev + 2, 8) to (start + 0, 21) + = (c17 + Zero) +- Code(Counter(18)) at (prev + 0, 22) to (start + 2, 6) +- Code(Expression(32, Sub)) at (prev + 2, 15) to (start + 0, 28) + = ((c17 + Zero) - c18) +- Code(Expression(31, Sub)) at (prev + 1, 12) to (start + 0, 25) + = (((c17 + Zero) - c18) - c12) +- Code(Expression(30, Sub)) at (prev + 0, 29) to (start + 0, 42) + = ((((c17 + Zero) - c18) - c12) - c19) +- Code(Expression(29, Sub)) at (prev + 0, 46) to (start + 0, 60) + = (((((c17 + Zero) - c18) - c12) - c19) - c20) +- Code(Expression(41, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c19 + c20) + c21) +- Code(Counter(22)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(40, Add)) at (prev + 1, 9) to (start + 0, 23) + = (((c19 + c20) + c21) + c22) +- Code(Counter(12)) at (prev + 2, 9) to (start + 0, 15) +- Code(Expression(39, Add)) at (prev + 3, 8) to (start + 0, 12) + = (c18 + (((c19 + c20) + c21) + c22)) +- Code(Counter(23)) at (prev + 1, 13) to (start + 1, 16) +- Code(Counter(24)) at (prev + 1, 17) to (start + 2, 10) +- Code(Zero) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(57, Add)) at (prev + 2, 12) to (start + 0, 25) + = (c24 + Zero) +- Code(Counter(25)) at (prev + 0, 26) to (start + 2, 10) +- Code(Expression(56, Sub)) at (prev + 3, 17) to (start + 0, 30) + = ((c24 + Zero) - c25) +- Code(Expression(55, Sub)) at (prev + 1, 16) to (start + 0, 29) + = (((c24 + Zero) - c25) - c11) +- Code(Expression(54, Sub)) at (prev + 0, 33) to (start + 0, 46) + = ((((c24 + Zero) - c25) - c11) - c26) +- Code(Expression(53, Sub)) at (prev + 0, 50) to (start + 0, 64) + = (((((c24 + Zero) - c25) - c11) - c26) - c27) +- Code(Expression(66, Add)) at (prev + 0, 65) to (start + 2, 14) + = ((c26 + c27) + c28) +- Code(Counter(29)) at (prev + 2, 14) to (start + 0, 15) +- Code(Expression(65, Add)) at (prev + 1, 13) to (start + 0, 27) + = (((c26 + c27) + c28) + c29) +- Code(Counter(11)) at (prev + 2, 13) to (start + 0, 19) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(63, Add)) at (prev + 2, 9) to (start + 1, 12) + = ((c25 + (((c26 + c27) + c28) + c29)) + Zero) +- Code(Counter(30)) at (prev + 1, 13) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(123, Add)) at (prev + 2, 9) to (start + 0, 10) + = (c31 + (((c32 + c33) + c34) + c35)) +- Code(Expression(86, Add)) at (prev + 0, 16) to (start + 0, 29) + = (c30 + Zero) +- Code(Counter(31)) at (prev + 0, 30) to (start + 2, 6) +- Code(Expression(85, Sub)) at (prev + 2, 15) to (start + 0, 28) + = ((c30 + Zero) - c31) +- Code(Expression(84, Sub)) at (prev + 1, 12) to (start + 0, 25) + = (((c30 + Zero) - c31) - c10) +- Code(Expression(83, Sub)) at (prev + 0, 29) to (start + 0, 42) + = ((((c30 + Zero) - c31) - c10) - c32) +- Code(Expression(82, Sub)) at (prev + 0, 46) to (start + 0, 60) + = (((((c30 + Zero) - c31) - c10) - c32) - c33) +- Code(Expression(125, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c32 + c33) + c34) +- Code(Counter(35)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(124, Add)) at (prev + 1, 9) to (start + 0, 23) + = (((c32 + c33) + c34) + c35) +- Code(Counter(10)) at (prev + 2, 13) to (start + 2, 15) +- Code(Expression(133, Add)) at (prev + 5, 9) to (start + 0, 10) + = (c4 + (((c5 + c6) + c7) + c8)) +- Code(Expression(96, Add)) at (prev + 0, 16) to (start + 0, 29) + = ((c31 + (((c32 + c33) + c34) + c35)) + Zero) +- Code(Counter(4)) at (prev + 0, 30) to (start + 2, 6) +- Code(Expression(122, Sub)) at (prev + 2, 15) to (start + 0, 28) + = ((c31 + (((c32 + c33) + c34) + c35)) - c4) +- Code(Expression(121, Sub)) at (prev + 1, 12) to (start + 0, 25) + = (((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) +- Code(Expression(120, Sub)) at (prev + 0, 29) to (start + 0, 42) + = ((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) +- Code(Expression(119, Sub)) at (prev + 0, 46) to (start + 0, 60) + = (((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) - c6) +- Code(Expression(135, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c5 + c6) + c7) +- Code(Counter(8)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(134, Add)) at (prev + 1, 9) to (start + 0, 23) + = (((c5 + c6) + c7) + c8) +- Code(Counter(9)) at (prev + 2, 9) to (start + 0, 15) +- Code(Expression(132, Add)) at (prev + 2, 1) to (start + 0, 2) + = ((c4 + (((c5 + c6) + c7) + c8)) + (((c9 + c10) + (c11 + c12)) + (((c1 + Zero) - c2) - c3))) + diff --git a/tests/coverage-map/status-quo/conditions.rs b/tests/coverage-map/status-quo/conditions.rs new file mode 100644 index 0000000000000..fa7f2a116c21e --- /dev/null +++ b/tests/coverage-map/status-quo/conditions.rs @@ -0,0 +1,86 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + let mut countdown = 0; + if true { + countdown = 10; + } + + const B: u32 = 100; + let x = if countdown > 7 { + countdown -= 4; + B + } else if countdown > 2 { + if countdown < 1 || countdown > 5 || countdown != 9 { + countdown = 0; + } + countdown -= 5; + countdown + } else { + return; + }; + + let mut countdown = 0; + if true { + countdown = 10; + } + + if countdown > 7 { + countdown -= 4; + } else if countdown > 2 { + if countdown < 1 || countdown > 5 || countdown != 9 { + countdown = 0; + } + countdown -= 5; + } else { + return; + } + + if true { + let mut countdown = 0; + if true { + countdown = 10; + } + + if countdown > 7 { + countdown -= 4; + } + else if countdown > 2 { + if countdown < 1 || countdown > 5 || countdown != 9 { + countdown = 0; + } + countdown -= 5; + } else { + return; + } + } + + let mut countdown = 0; + if true { + countdown = 1; + } + + let z = if countdown > 7 { + countdown -= 4; + } else if countdown > 2 { + if countdown < 1 || countdown > 5 || countdown != 9 { + countdown = 0; + } + countdown -= 5; + } else { + let should_be_reachable = countdown; + println!("reached"); + return; + }; + + let w = if countdown > 7 { + countdown -= 4; + } else if countdown > 2 { + if countdown < 1 || countdown > 5 || countdown != 9 { + countdown = 0; + } + countdown -= 5; + } else { + return; + }; +} diff --git a/tests/coverage-map/status-quo/continue.cov-map b/tests/coverage-map/status-quo/continue.cov-map new file mode 100644 index 0000000000000..c78cf293079ea --- /dev/null +++ b/tests/coverage-map/status-quo/continue.cov-map @@ -0,0 +1,85 @@ +Function name: continue::main +Raw bytes (216): 0x[01, 01, 1f, 01, 07, 05, 09, 03, 0d, 0d, 1f, 11, 15, 1b, 19, 0d, 1f, 11, 15, 15, 00, 19, 37, 1d, 21, 33, 25, 19, 37, 1d, 21, 1d, 00, 25, 4f, 29, 2d, 4b, 31, 25, 4f, 29, 2d, 31, 67, 35, 39, 5f, 3d, 31, 67, 35, 39, 35, 39, 3d, 41, 73, 45, 3d, 41, 41, 00, 49, 45, 1e, 01, 03, 01, 03, 12, 03, 04, 0e, 00, 13, 0a, 01, 0f, 00, 16, 05, 02, 11, 00, 19, 09, 02, 12, 04, 0e, 1b, 06, 0e, 00, 13, 16, 01, 0f, 00, 16, 15, 01, 16, 02, 0e, 11, 04, 11, 00, 19, 23, 03, 09, 00, 0e, 33, 02, 0e, 00, 13, 2e, 01, 0f, 00, 16, 1d, 01, 15, 02, 0e, 21, 04, 11, 00, 19, 3b, 03, 09, 00, 0e, 4b, 02, 0e, 00, 13, 46, 01, 0c, 00, 13, 29, 01, 0d, 00, 15, 2d, 01, 0a, 01, 0e, 5f, 03, 0e, 00, 13, 5a, 01, 0f, 00, 16, 39, 01, 16, 02, 0e, 35, 03, 12, 02, 0e, 67, 04, 09, 00, 0e, 73, 02, 0e, 00, 13, 6e, 01, 0f, 00, 16, 41, 01, 16, 02, 0e, 49, 04, 11, 00, 16, 77, 03, 09, 00, 0e, 7b, 02, 0d, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 31 +- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(3), rhs = Expression(7, Add) +- expression 4 operands: lhs = Counter(4), rhs = Counter(5) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(6) +- expression 6 operands: lhs = Counter(3), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(4), rhs = Counter(5) +- expression 8 operands: lhs = Counter(5), rhs = Zero +- expression 9 operands: lhs = Counter(6), rhs = Expression(13, Add) +- expression 10 operands: lhs = Counter(7), rhs = Counter(8) +- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(9) +- expression 12 operands: lhs = Counter(6), rhs = Expression(13, Add) +- expression 13 operands: lhs = Counter(7), rhs = Counter(8) +- expression 14 operands: lhs = Counter(7), rhs = Zero +- expression 15 operands: lhs = Counter(9), rhs = Expression(19, Add) +- expression 16 operands: lhs = Counter(10), rhs = Counter(11) +- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(12) +- expression 18 operands: lhs = Counter(9), rhs = Expression(19, Add) +- expression 19 operands: lhs = Counter(10), rhs = Counter(11) +- expression 20 operands: lhs = Counter(12), rhs = Expression(25, Add) +- expression 21 operands: lhs = Counter(13), rhs = Counter(14) +- expression 22 operands: lhs = Expression(23, Add), rhs = Counter(15) +- expression 23 operands: lhs = Counter(12), rhs = Expression(25, Add) +- expression 24 operands: lhs = Counter(13), rhs = Counter(14) +- expression 25 operands: lhs = Counter(13), rhs = Counter(14) +- expression 26 operands: lhs = Counter(15), rhs = Counter(16) +- expression 27 operands: lhs = Expression(28, Add), rhs = Counter(17) +- expression 28 operands: lhs = Counter(15), rhs = Counter(16) +- expression 29 operands: lhs = Counter(16), rhs = Zero +- expression 30 operands: lhs = Counter(18), rhs = Counter(17) +Number of file 0 mappings: 30 +- Code(Counter(0)) at (prev + 3, 1) to (start + 3, 18) +- Code(Expression(0, Add)) at (prev + 4, 14) to (start + 0, 19) + = (c0 + (c1 + c2)) +- Code(Expression(2, Sub)) at (prev + 1, 15) to (start + 0, 22) + = ((c0 + (c1 + c2)) - c3) +- Code(Counter(1)) at (prev + 2, 17) to (start + 0, 25) +- Code(Counter(2)) at (prev + 2, 18) to (start + 4, 14) +- Code(Expression(6, Add)) at (prev + 6, 14) to (start + 0, 19) + = (c3 + (c4 + c5)) +- Code(Expression(5, Sub)) at (prev + 1, 15) to (start + 0, 22) + = ((c3 + (c4 + c5)) - c6) +- Code(Counter(5)) at (prev + 1, 22) to (start + 2, 14) +- Code(Counter(4)) at (prev + 4, 17) to (start + 0, 25) +- Code(Expression(8, Add)) at (prev + 3, 9) to (start + 0, 14) + = (c5 + Zero) +- Code(Expression(12, Add)) at (prev + 2, 14) to (start + 0, 19) + = (c6 + (c7 + c8)) +- Code(Expression(11, Sub)) at (prev + 1, 15) to (start + 0, 22) + = ((c6 + (c7 + c8)) - c9) +- Code(Counter(7)) at (prev + 1, 21) to (start + 2, 14) +- Code(Counter(8)) at (prev + 4, 17) to (start + 0, 25) +- Code(Expression(14, Add)) at (prev + 3, 9) to (start + 0, 14) + = (c7 + Zero) +- Code(Expression(18, Add)) at (prev + 2, 14) to (start + 0, 19) + = (c9 + (c10 + c11)) +- Code(Expression(17, Sub)) at (prev + 1, 12) to (start + 0, 19) + = ((c9 + (c10 + c11)) - c12) +- Code(Counter(10)) at (prev + 1, 13) to (start + 0, 21) +- Code(Counter(11)) at (prev + 1, 10) to (start + 1, 14) +- Code(Expression(23, Add)) at (prev + 3, 14) to (start + 0, 19) + = (c12 + (c13 + c14)) +- Code(Expression(22, Sub)) at (prev + 1, 15) to (start + 0, 22) + = ((c12 + (c13 + c14)) - c15) +- Code(Counter(14)) at (prev + 1, 22) to (start + 2, 14) +- Code(Counter(13)) at (prev + 3, 18) to (start + 2, 14) +- Code(Expression(25, Add)) at (prev + 4, 9) to (start + 0, 14) + = (c13 + c14) +- Code(Expression(28, Add)) at (prev + 2, 14) to (start + 0, 19) + = (c15 + c16) +- Code(Expression(27, Sub)) at (prev + 1, 15) to (start + 0, 22) + = ((c15 + c16) - c17) +- Code(Counter(16)) at (prev + 1, 22) to (start + 2, 14) +- Code(Counter(18)) at (prev + 4, 17) to (start + 0, 22) +- Code(Expression(29, Add)) at (prev + 3, 9) to (start + 0, 14) + = (c16 + Zero) +- Code(Expression(30, Add)) at (prev + 2, 13) to (start + 1, 2) + = (c18 + c17) + diff --git a/tests/coverage-map/status-quo/continue.rs b/tests/coverage-map/status-quo/continue.rs new file mode 100644 index 0000000000000..624aa98341b80 --- /dev/null +++ b/tests/coverage-map/status-quo/continue.rs @@ -0,0 +1,69 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + let is_true = std::env::args().len() == 1; + + let mut x = 0; + for _ in 0..10 { + match is_true { + true => { + continue; + } + _ => { + x = 1; + } + } + x = 3; + } + for _ in 0..10 { + match is_true { + false => { + x = 1; + } + _ => { + continue; + } + } + x = 3; + } + for _ in 0..10 { + match is_true { + true => { + x = 1; + } + _ => { + continue; + } + } + x = 3; + } + for _ in 0..10 { + if is_true { + continue; + } + x = 3; + } + for _ in 0..10 { + match is_true { + false => { + x = 1; + } + _ => { + let _ = x; + } + } + x = 3; + } + for _ in 0..10 { + match is_true { + false => { + x = 1; + } + _ => { + break; + } + } + x = 3; + } + let _ = x; +} diff --git a/tests/coverage-map/status-quo/dead_code.cov-map b/tests/coverage-map/status-quo/dead_code.cov-map new file mode 100644 index 0000000000000..8d5f88e63efba --- /dev/null +++ b/tests/coverage-map/status-quo/dead_code.cov-map @@ -0,0 +1,37 @@ +Function name: dead_code::main +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1b, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 27, 1) to (start + 7, 15) +- Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: dead_code::unused_fn (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 01, 0f, 01, 07, 0f, 00, 07, 10, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 15, 1) to (start + 7, 15) +- Code(Zero) at (prev + 7, 16) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + +Function name: dead_code::unused_pub_fn_not_in_library (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 01, 03, 01, 07, 0f, 00, 07, 10, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15) +- Code(Zero) at (prev + 7, 16) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + diff --git a/tests/coverage-map/status-quo/dead_code.rs b/tests/coverage-map/status-quo/dead_code.rs new file mode 100644 index 0000000000000..3492712a6f98e --- /dev/null +++ b/tests/coverage-map/status-quo/dead_code.rs @@ -0,0 +1,37 @@ +#![allow(dead_code, unused_assignments, unused_variables)] + +pub fn unused_pub_fn_not_in_library() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + if is_true { + countdown = 10; + } +} + +fn unused_fn() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + if is_true { + countdown = 10; + } +} + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + if is_true { + countdown = 10; + } +} diff --git a/tests/coverage-map/status-quo/drop_trait.cov-map b/tests/coverage-map/status-quo/drop_trait.cov-map new file mode 100644 index 0000000000000..203d1048b0547 --- /dev/null +++ b/tests/coverage-map/status-quo/drop_trait.cov-map @@ -0,0 +1,21 @@ +Function name: ::drop +Raw bytes (9): 0x[01, 01, 00, 01, 01, 09, 05, 02, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 9, 5) to (start + 2, 6) + +Function name: drop_trait::main +Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 0e, 01, 05, 0c, 05, 06, 09, 01, 16, 00, 02, 06, 04, 0b, 03, 05, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 14, 1) to (start + 5, 12) +- Code(Counter(1)) at (prev + 6, 9) to (start + 1, 22) +- Code(Zero) at (prev + 2, 6) to (start + 4, 11) +- Code(Expression(0, Add)) at (prev + 5, 1) to (start + 0, 2) + = (c1 + Zero) + diff --git a/tests/coverage-map/status-quo/drop_trait.rs b/tests/coverage-map/status-quo/drop_trait.rs new file mode 100644 index 0000000000000..7b062719c6b02 --- /dev/null +++ b/tests/coverage-map/status-quo/drop_trait.rs @@ -0,0 +1,33 @@ +#![allow(unused_assignments)] +// failure-status: 1 + +struct Firework { + strength: i32, +} + +impl Drop for Firework { + fn drop(&mut self) { + println!("BOOM times {}!!!", self.strength); + } +} + +fn main() -> Result<(), u8> { + let _firecracker = Firework { strength: 1 }; + + let _tnt = Firework { strength: 100 }; + + if true { + println!("Exiting with error..."); + return Err(1); + } + + let _ = Firework { strength: 1000 }; + + Ok(()) +} + +// Expected program output: +// Exiting with error... +// BOOM times 100!!! +// BOOM times 1!!! +// Error: 1 diff --git a/tests/coverage-map/status-quo/generator.cov-map b/tests/coverage-map/status-quo/generator.cov-map new file mode 100644 index 0000000000000..6e10b58a94118 --- /dev/null +++ b/tests/coverage-map/status-quo/generator.cov-map @@ -0,0 +1,58 @@ +Function name: generator::get_u32 +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 01, 01, 0b, 05, 01, 0e, 00, 13, 02, 00, 1d, 00, 3c, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 11, 1) to (start + 1, 11) +- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 19) +- Code(Expression(0, Sub)) at (prev + 0, 29) to (start + 0, 60) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: generator::main +Raw bytes (71): 0x[01, 01, 0b, 01, 00, 05, 0b, 09, 0d, 11, 00, 11, 15, 2a, 19, 11, 15, 15, 19, 26, 00, 2a, 19, 11, 15, 09, 01, 0f, 01, 02, 19, 03, 07, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 07, 01, 0e, 00, 35, 0f, 02, 0b, 00, 2e, 2a, 01, 22, 00, 27, 26, 00, 2c, 00, 2e, 1f, 01, 0e, 00, 35, 23, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 11 +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Counter(4), rhs = Zero +- expression 4 operands: lhs = Counter(4), rhs = Counter(5) +- expression 5 operands: lhs = Expression(10, Sub), rhs = Counter(6) +- expression 6 operands: lhs = Counter(4), rhs = Counter(5) +- expression 7 operands: lhs = Counter(5), rhs = Counter(6) +- expression 8 operands: lhs = Expression(9, Sub), rhs = Zero +- expression 9 operands: lhs = Expression(10, Sub), rhs = Counter(6) +- expression 10 operands: lhs = Counter(4), rhs = Counter(5) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 25) +- Code(Expression(0, Add)) at (prev + 7, 11) to (start + 0, 46) + = (c0 + Zero) +- Code(Counter(4)) at (prev + 1, 43) to (start + 0, 45) +- Code(Expression(1, Add)) at (prev + 1, 14) to (start + 0, 53) + = (c1 + (c2 + c3)) +- Code(Expression(3, Add)) at (prev + 2, 11) to (start + 0, 46) + = (c4 + Zero) +- Code(Expression(10, Sub)) at (prev + 1, 34) to (start + 0, 39) + = (c4 - c5) +- Code(Expression(9, Sub)) at (prev + 0, 44) to (start + 0, 46) + = ((c4 - c5) - c6) +- Code(Expression(7, Add)) at (prev + 1, 14) to (start + 0, 53) + = (c5 + c6) +- Code(Expression(8, Add)) at (prev + 2, 1) to (start + 0, 2) + = (((c4 - c5) - c6) + Zero) + +Function name: generator::main::{closure#0} +Raw bytes (14): 0x[01, 01, 00, 02, 01, 11, 1c, 01, 1f, 05, 02, 10, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 17, 28) to (start + 1, 31) +- Code(Counter(1)) at (prev + 2, 16) to (start + 1, 6) + diff --git a/tests/coverage-map/status-quo/generator.rs b/tests/coverage-map/status-quo/generator.rs new file mode 100644 index 0000000000000..4319991021e78 --- /dev/null +++ b/tests/coverage-map/status-quo/generator.rs @@ -0,0 +1,30 @@ +#![feature(generators, generator_trait)] + +use std::ops::{Generator, GeneratorState}; +use std::pin::Pin; + +// The following implementation of a function called from a `yield` statement +// (apparently requiring the Result and the `String` type or constructor) +// creates conditions where the `generator::StateTransform` MIR transform will +// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic +// to handle this condition, and still report dead block coverage. +fn get_u32(val: bool) -> Result { + if val { Ok(1) } else { Err(String::from("some error")) } +} + +fn main() { + let is_true = std::env::args().len() == 1; + let mut generator = || { + yield get_u32(is_true); + return "foo"; + }; + + match Pin::new(&mut generator).resume(()) { + GeneratorState::Yielded(Ok(1)) => {} + _ => panic!("unexpected return from resume"), + } + match Pin::new(&mut generator).resume(()) { + GeneratorState::Complete("foo") => {} + _ => panic!("unexpected return from resume"), + } +} diff --git a/tests/coverage-map/status-quo/generics.cov-map b/tests/coverage-map/status-quo/generics.cov-map new file mode 100644 index 0000000000000..6079a433cd04e --- /dev/null +++ b/tests/coverage-map/status-quo/generics.cov-map @@ -0,0 +1,45 @@ +Function name: as core::ops::drop::Drop>::drop +Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 05, 02, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 17, 5) to (start + 2, 6) + +Function name: >::set_strength +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 05, 02, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 10, 5) to (start + 2, 6) + +Function name: as core::ops::drop::Drop>::drop +Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 05, 02, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 17, 5) to (start + 2, 6) + +Function name: >::set_strength +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 05, 02, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 10, 5) to (start + 2, 6) + +Function name: generics::main +Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 16, 01, 08, 0c, 05, 09, 09, 01, 16, 00, 02, 06, 04, 0b, 03, 05, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 22, 1) to (start + 8, 12) +- Code(Counter(1)) at (prev + 9, 9) to (start + 1, 22) +- Code(Zero) at (prev + 2, 6) to (start + 4, 11) +- Code(Expression(0, Add)) at (prev + 5, 1) to (start + 0, 2) + = (c1 + Zero) + diff --git a/tests/coverage-map/status-quo/generics.rs b/tests/coverage-map/status-quo/generics.rs new file mode 100644 index 0000000000000..bf4c2d8d68532 --- /dev/null +++ b/tests/coverage-map/status-quo/generics.rs @@ -0,0 +1,44 @@ +#![allow(unused_assignments)] +// failure-status: 1 + +struct Firework where T: Copy + std::fmt::Display { + strength: T, +} + +impl Firework where T: Copy + std::fmt::Display { + #[inline(always)] + fn set_strength(&mut self, new_strength: T) { + self.strength = new_strength; + } +} + +impl Drop for Firework where T: Copy + std::fmt::Display { + #[inline(always)] + fn drop(&mut self) { + println!("BOOM times {}!!!", self.strength); + } +} + +fn main() -> Result<(), u8> { + let mut firecracker = Firework { strength: 1 }; + firecracker.set_strength(2); + + let mut tnt = Firework { strength: 100.1 }; + tnt.set_strength(200.1); + tnt.set_strength(300.3); + + if true { + println!("Exiting with error..."); + return Err(1); + } + + let _ = Firework { strength: 1000 }; + + Ok(()) +} + +// Expected program output: +// Exiting with error... +// BOOM times 100!!! +// BOOM times 1!!! +// Error: 1 diff --git a/tests/coverage-map/status-quo/if.cov-map b/tests/coverage-map/status-quo/if.cov-map new file mode 100644 index 0000000000000..391a69e0e821d --- /dev/null +++ b/tests/coverage-map/status-quo/if.cov-map @@ -0,0 +1,15 @@ +Function name: if::main +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 03, 01, 12, 10, 05, 13, 05, 05, 06, 02, 05, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 3, 1) to (start + 18, 16) +- Code(Counter(1)) at (prev + 19, 5) to (start + 5, 6) +- Code(Expression(0, Sub)) at (prev + 5, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + diff --git a/tests/coverage-map/status-quo/if.rs b/tests/coverage-map/status-quo/if.rs new file mode 100644 index 0000000000000..8ad5042ff7baf --- /dev/null +++ b/tests/coverage-map/status-quo/if.rs @@ -0,0 +1,28 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let + is_true + = + std::env::args().len() + == + 1 + ; + let + mut + countdown + = + 0 + ; + if + is_true + { + countdown + = + 10 + ; + } +} diff --git a/tests/coverage-map/status-quo/if_else.cov-map b/tests/coverage-map/status-quo/if_else.cov-map new file mode 100644 index 0000000000000..da692ca3aa2a7 --- /dev/null +++ b/tests/coverage-map/status-quo/if_else.cov-map @@ -0,0 +1,25 @@ +Function name: if_else::main +Raw bytes (53): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 07, 01, 03, 01, 08, 10, 05, 09, 05, 05, 06, 02, 08, 09, 02, 10, 1b, 06, 09, 00, 10, 09, 01, 05, 05, 06, 16, 07, 05, 05, 06, 13, 06, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 7 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2) +- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 7 +- Code(Counter(0)) at (prev + 3, 1) to (start + 8, 16) +- Code(Counter(1)) at (prev + 9, 5) to (start + 5, 6) +- Code(Expression(0, Sub)) at (prev + 8, 9) to (start + 2, 16) + = (c0 - c1) +- Code(Expression(6, Add)) at (prev + 6, 9) to (start + 0, 16) + = (c1 + (c0 - c1)) +- Code(Counter(2)) at (prev + 1, 5) to (start + 5, 6) +- Code(Expression(5, Sub)) at (prev + 7, 5) to (start + 5, 6) + = ((c1 + (c0 - c1)) - c2) +- Code(Expression(4, Add)) at (prev + 6, 1) to (start + 0, 2) + = (c2 + ((c1 + (c0 - c1)) - c2)) + diff --git a/tests/coverage-map/status-quo/if_else.rs b/tests/coverage-map/status-quo/if_else.rs new file mode 100644 index 0000000000000..3244e1e3afd2b --- /dev/null +++ b/tests/coverage-map/status-quo/if_else.rs @@ -0,0 +1,40 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + if + is_true + { + countdown + = + 10 + ; + } + else // Note coverage region difference without semicolon + { + countdown + = + 100 + } + + if + is_true + { + countdown + = + 10 + ; + } + else + { + countdown + = + 100 + ; + } +} diff --git a/tests/coverage-map/status-quo/inline-dead.cov-map b/tests/coverage-map/status-quo/inline-dead.cov-map new file mode 100644 index 0000000000000..dec43d3e8bbdd --- /dev/null +++ b/tests/coverage-map/status-quo/inline-dead.cov-map @@ -0,0 +1,45 @@ +Function name: inline_dead::dead (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 19, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 25, 1) to (start + 2, 2) + +Function name: inline_dead::live:: +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 16, 1) to (start + 1, 9) +- Code(Zero) at (prev + 2, 9) to (start + 0, 15) +- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: inline_dead::main +Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 04, 01, 03, 0d, 03, 07, 06, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 4, 1) to (start + 3, 13) +- Code(Expression(0, Add)) at (prev + 7, 6) to (start + 2, 2) + = (c0 + Zero) + +Function name: inline_dead::main::{closure#0} +Raw bytes (16): 0x[01, 01, 01, 01, 05, 02, 00, 09, 0d, 00, 0e, 03, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 2 +- Code(Zero) at (prev + 9, 13) to (start + 0, 14) +- Code(Expression(0, Add)) at (prev + 2, 5) to (start + 0, 6) + = (c0 + c1) + diff --git a/tests/coverage-map/status-quo/inline-dead.rs b/tests/coverage-map/status-quo/inline-dead.rs new file mode 100644 index 0000000000000..854fa06296752 --- /dev/null +++ b/tests/coverage-map/status-quo/inline-dead.rs @@ -0,0 +1,27 @@ +// Regression test for issue #98833. +// compile-flags: -Zinline-mir -Cdebug-assertions=off + +fn main() { + println!("{}", live::()); + + let f = |x: bool| { + debug_assert!( + x + ); + }; + f(false); +} + +#[inline] +fn live() -> u32 { + if B { + dead() + } else { + 0 + } +} + +#[inline] +fn dead() -> u32 { + 42 +} diff --git a/tests/coverage-map/status-quo/inline.cov-map b/tests/coverage-map/status-quo/inline.cov-map new file mode 100644 index 0000000000000..57ae85623fb75 --- /dev/null +++ b/tests/coverage-map/status-quo/inline.cov-map @@ -0,0 +1,82 @@ +Function name: inline::display:: +Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 00, 03, 05, 05, 01, 29, 01, 00, 22, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 10, 07, 00, 11, 02, 06, 0a, 03, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 3 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Zero +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(1) +Number of file 0 mappings: 5 +- Code(Counter(0)) at (prev + 41, 1) to (start + 0, 34) +- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 10) +- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 16) + = (c0 + c1) +- Code(Expression(1, Add)) at (prev + 0, 17) to (start + 2, 6) + = (c1 + Zero) +- Code(Expression(2, Sub)) at (prev + 3, 5) to (start + 1, 2) + = ((c0 + c1) - c1) + +Function name: inline::error +Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 49, 1) to (start + 2, 2) + +Function name: inline::length:: +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 2) + +Function name: inline::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 05, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 5, 1) to (start + 2, 2) + +Function name: inline::permutate:: +Raw bytes (54): 0x[01, 01, 05, 01, 05, 02, 0d, 11, 00, 05, 13, 09, 0d, 08, 01, 0f, 01, 02, 0e, 05, 02, 0f, 02, 06, 02, 02, 0f, 00, 14, 11, 01, 0d, 00, 0e, 06, 00, 12, 00, 16, 0b, 00, 17, 04, 0a, 0d, 05, 0c, 02, 06, 0f, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 5 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(3) +- expression 2 operands: lhs = Counter(4), rhs = Zero +- expression 3 operands: lhs = Counter(1), rhs = Expression(4, Add) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +Number of file 0 mappings: 8 +- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 14) +- Code(Counter(1)) at (prev + 2, 15) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 15) to (start + 0, 20) + = (c0 - c1) +- Code(Counter(4)) at (prev + 1, 13) to (start + 0, 14) +- Code(Expression(1, Sub)) at (prev + 0, 18) to (start + 0, 22) + = ((c0 - c1) - c3) +- Code(Expression(2, Add)) at (prev + 0, 23) to (start + 4, 10) + = (c4 + Zero) +- Code(Counter(3)) at (prev + 5, 12) to (start + 2, 6) +- Code(Expression(3, Add)) at (prev + 3, 1) to (start + 0, 2) + = (c1 + (c2 + c3)) + +Function name: inline::permutations:: +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 03, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 10, 1) to (start + 3, 2) + +Function name: inline::swap:: +Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 01, 04, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 35, 1) to (start + 4, 2) + diff --git a/tests/coverage-map/status-quo/inline.rs b/tests/coverage-map/status-quo/inline.rs new file mode 100644 index 0000000000000..9cfab9ddbadf2 --- /dev/null +++ b/tests/coverage-map/status-quo/inline.rs @@ -0,0 +1,51 @@ +// compile-flags: -Zinline-mir + +use std::fmt::Display; + +fn main() { + permutations(&['a', 'b', 'c']); +} + +#[inline(always)] +fn permutations(xs: &[T]) { + let mut ys = xs.to_owned(); + permutate(&mut ys, 0); +} + +fn permutate(xs: &mut [T], k: usize) { + let n = length(xs); + if k == n { + display(xs); + } else if k < n { + for i in k..n { + swap(xs, i, k); + permutate(xs, k + 1); + swap(xs, i, k); + } + } else { + error(); + } +} + +fn length(xs: &[T]) -> usize { + xs.len() +} + +#[inline] +fn swap(xs: &mut [T], i: usize, j: usize) { + let t = xs[i]; + xs[i] = xs[j]; + xs[j] = t; +} + +fn display(xs: &[T]) { + for x in xs { + print!("{}", x); + } + println!(); +} + +#[inline(always)] +fn error() { + panic!("error"); +} diff --git a/tests/coverage-map/status-quo/inner_items.cov-map b/tests/coverage-map/status-quo/inner_items.cov-map new file mode 100644 index 0000000000000..3f39d74efbaca --- /dev/null +++ b/tests/coverage-map/status-quo/inner_items.cov-map @@ -0,0 +1,49 @@ +Function name: ::default_trait_func +Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 09, 03, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 33, 9) to (start + 3, 10) + +Function name: ::trait_func +Raw bytes (9): 0x[01, 01, 00, 01, 01, 28, 09, 03, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 40, 9) to (start + 3, 10) + +Function name: inner_items::main +Raw bytes (53): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 07, 01, 03, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 1b, 24, 08, 00, 0f, 09, 00, 10, 02, 06, 16, 02, 06, 00, 07, 13, 02, 09, 05, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 7 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2) +- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 7 +- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15) +- Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(6, Add)) at (prev + 36, 8) to (start + 0, 15) + = (c1 + (c0 - c1)) +- Code(Counter(2)) at (prev + 0, 16) to (start + 2, 6) +- Code(Expression(5, Sub)) at (prev + 2, 6) to (start + 0, 7) + = ((c1 + (c0 - c1)) - c2) +- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 5, 2) + = (c2 + ((c1 + (c0 - c1)) - c2)) + +Function name: inner_items::main::in_func +Raw bytes (9): 0x[01, 01, 00, 01, 01, 12, 05, 04, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 18, 5) to (start + 4, 6) + diff --git a/tests/coverage-map/status-quo/inner_items.rs b/tests/coverage-map/status-quo/inner_items.rs new file mode 100644 index 0000000000000..bcb62b3031cd9 --- /dev/null +++ b/tests/coverage-map/status-quo/inner_items.rs @@ -0,0 +1,57 @@ +#![allow(unused_assignments, unused_variables, dead_code)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + if is_true { + countdown = 10; + } + + mod in_mod { + const IN_MOD_CONST: u32 = 1000; + } + + fn in_func(a: u32) { + let b = 1; + let c = a + b; + println!("c = {}", c) + } + + struct InStruct { + in_struct_field: u32, + } + + const IN_CONST: u32 = 1234; + + trait InTrait { + fn trait_func(&mut self, incr: u32); + + fn default_trait_func(&mut self) { + in_func(IN_CONST); + self.trait_func(IN_CONST); + } + } + + impl InTrait for InStruct { + fn trait_func(&mut self, incr: u32) { + self.in_struct_field += incr; + in_func(self.in_struct_field); + } + } + + type InType = String; + + if is_true { + in_func(countdown); + } + + let mut val = InStruct { + in_struct_field: 101, + }; + + val.default_trait_func(); +} diff --git a/tests/coverage-map/status-quo/issue-83601.cov-map b/tests/coverage-map/status-quo/issue-83601.cov-map new file mode 100644 index 0000000000000..f5db3a89750c7 --- /dev/null +++ b/tests/coverage-map/status-quo/issue-83601.cov-map @@ -0,0 +1,28 @@ +Function name: ::eq +Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 11, 00, 1a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 3, 17) to (start + 0, 26) + +Function name: ::fmt +Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 0a, 00, 0f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 3, 10) to (start + 0, 15) + +Function name: issue_83601::main +Raw bytes (21): 0x[01, 01, 01, 05, 09, 03, 01, 06, 01, 02, 1c, 05, 03, 09, 01, 1c, 02, 02, 05, 03, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 6, 1) to (start + 2, 28) +- Code(Counter(1)) at (prev + 3, 9) to (start + 1, 28) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 3, 2) + = (c1 - c2) + diff --git a/tests/coverage-map/status-quo/issue-83601.rs b/tests/coverage-map/status-quo/issue-83601.rs new file mode 100644 index 0000000000000..0b72a81947cc7 --- /dev/null +++ b/tests/coverage-map/status-quo/issue-83601.rs @@ -0,0 +1,14 @@ +// Shows that rust-lang/rust/83601 is resolved + +#[derive(Debug, PartialEq, Eq)] +struct Foo(u32); + +fn main() { + let bar = Foo(1); + assert_eq!(bar, Foo(1)); + let baz = Foo(0); + assert_ne!(baz, Foo(1)); + println!("{:?}", Foo(1)); + println!("{:?}", bar); + println!("{:?}", baz); +} diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/status-quo/issue-84561.cov-map new file mode 100644 index 0000000000000..fe098fd396c27 --- /dev/null +++ b/tests/coverage-map/status-quo/issue-84561.cov-map @@ -0,0 +1,233 @@ +Function name: ::eq +Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 0a, 00, 13, 00, 00, 0a, 00, 13] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 4, 10) to (start + 0, 19) +- Code(Zero) at (prev + 0, 10) to (start + 0, 19) + +Function name: ::fmt +Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 89, 01, 09, 00, 25, 05, 00, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 137, 9) to (start + 0, 37) +- Code(Counter(1)) at (prev + 0, 37) to (start + 0, 38) +- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 0, 6) + = (c1 + (c0 - c1)) + +Function name: issue_84561::main +Raw bytes (10): 0x[01, 01, 00, 01, 01, b2, 01, 01, 04, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 178, 1) to (start + 4, 2) + +Function name: issue_84561::test1 +Raw bytes (78): 0x[01, 01, 0e, 05, 06, 01, 05, 09, 36, 03, 09, 0d, 2e, 33, 0d, 09, 36, 03, 09, 11, 26, 2b, 11, 0d, 2e, 33, 0d, 09, 36, 03, 09, 09, 01, 98, 01, 01, 01, 0b, 05, 01, 0c, 00, 1e, 03, 01, 05, 00, 0b, 09, 00, 0c, 00, 1e, 33, 01, 0d, 01, 0b, 0d, 01, 0c, 00, 1e, 2b, 01, 05, 03, 0b, 11, 03, 0c, 00, 1e, 23, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 14 +- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(2), rhs = Expression(13, Sub) +- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2) +- expression 4 operands: lhs = Counter(3), rhs = Expression(11, Sub) +- expression 5 operands: lhs = Expression(12, Add), rhs = Counter(3) +- expression 6 operands: lhs = Counter(2), rhs = Expression(13, Sub) +- expression 7 operands: lhs = Expression(0, Add), rhs = Counter(2) +- expression 8 operands: lhs = Counter(4), rhs = Expression(9, Sub) +- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(4) +- expression 10 operands: lhs = Counter(3), rhs = Expression(11, Sub) +- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(3) +- expression 12 operands: lhs = Counter(2), rhs = Expression(13, Sub) +- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(2) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 152, 1) to (start + 1, 11) +- Code(Counter(1)) at (prev + 1, 12) to (start + 0, 30) +- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 11) + = (c1 + (c0 - c1)) +- Code(Counter(2)) at (prev + 0, 12) to (start + 0, 30) +- Code(Expression(12, Add)) at (prev + 1, 13) to (start + 1, 11) + = (c2 + ((c1 + (c0 - c1)) - c2)) +- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 30) +- Code(Expression(10, Add)) at (prev + 1, 5) to (start + 3, 11) + = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) +- Code(Counter(4)) at (prev + 3, 12) to (start + 0, 30) +- Code(Expression(8, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) + +Function name: issue_84561::test2 +Raw bytes (24): 0x[01, 01, 02, 05, 06, 01, 05, 03, 01, ae, 01, 01, 01, 10, 05, 01, 11, 00, 23, 03, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 174, 1) to (start + 1, 16) +- Code(Counter(1)) at (prev + 1, 17) to (start + 0, 35) +- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: issue_84561::test2::call_print +Raw bytes (10): 0x[01, 01, 00, 01, 01, a5, 01, 09, 02, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 165, 9) to (start + 2, 10) + +Function name: issue_84561::test3 +Raw bytes (437): 0x[01, 01, 41, 05, 09, 0d, 11, 15, 19, 12, 1d, 15, 19, 21, 25, 1e, 29, 21, 25, 31, 39, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 4d, 3f, 51, 42, 49, 45, 4d, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 92, 01, 55, 51, 59, 8f, 01, 5d, 92, 01, 55, 51, 59, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 71, fe, 01, 82, 02, 71, 69, 6d, 69, 6d, 82, 02, 71, 69, 6d, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, ee, 01, 81, 01, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 06, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 71, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 65 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Counter(3), rhs = Counter(4) +- expression 2 operands: lhs = Counter(5), rhs = Counter(6) +- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7) +- expression 4 operands: lhs = Counter(5), rhs = Counter(6) +- expression 5 operands: lhs = Counter(8), rhs = Counter(9) +- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(10) +- expression 7 operands: lhs = Counter(8), rhs = Counter(9) +- expression 8 operands: lhs = Counter(12), rhs = Counter(14) +- expression 9 operands: lhs = Counter(15), rhs = Counter(16) +- expression 10 operands: lhs = Expression(11, Sub), rhs = Counter(17) +- expression 11 operands: lhs = Counter(15), rhs = Counter(16) +- expression 12 operands: lhs = Expression(16, Sub), rhs = Counter(18) +- expression 13 operands: lhs = Counter(17), rhs = Counter(19) +- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(20) +- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(18) +- expression 16 operands: lhs = Counter(17), rhs = Counter(19) +- expression 17 operands: lhs = Counter(23), rhs = Expression(34, Sub) +- expression 18 operands: lhs = Expression(35, Add), rhs = Counter(23) +- expression 19 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 20 operands: lhs = Counter(20), rhs = Counter(22) +- expression 21 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 22 operands: lhs = Counter(20), rhs = Counter(22) +- expression 23 operands: lhs = Expression(35, Add), rhs = Counter(23) +- expression 24 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 25 operands: lhs = Counter(20), rhs = Counter(22) +- expression 26 operands: lhs = Expression(33, Add), rhs = Counter(24) +- expression 27 operands: lhs = Counter(23), rhs = Expression(34, Sub) +- expression 28 operands: lhs = Expression(35, Add), rhs = Counter(23) +- expression 29 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 30 operands: lhs = Counter(20), rhs = Counter(22) +- expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(25) +- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(24) +- expression 33 operands: lhs = Counter(23), rhs = Expression(34, Sub) +- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(23) +- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 36 operands: lhs = Counter(20), rhs = Counter(22) +- expression 37 operands: lhs = Counter(29), rhs = Expression(61, Sub) +- expression 38 operands: lhs = Expression(62, Add), rhs = Counter(30) +- expression 39 operands: lhs = Counter(28), rhs = Expression(63, Sub) +- expression 40 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 41 operands: lhs = Counter(26), rhs = Counter(27) +- expression 42 operands: lhs = Counter(28), rhs = Expression(63, Sub) +- expression 43 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 44 operands: lhs = Counter(26), rhs = Counter(27) +- expression 45 operands: lhs = Counter(26), rhs = Counter(27) +- expression 46 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 47 operands: lhs = Counter(26), rhs = Counter(27) +- expression 48 operands: lhs = Expression(62, Add), rhs = Counter(30) +- expression 49 operands: lhs = Counter(28), rhs = Expression(63, Sub) +- expression 50 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 51 operands: lhs = Counter(26), rhs = Counter(27) +- expression 52 operands: lhs = Expression(60, Add), rhs = Counter(31) +- expression 53 operands: lhs = Counter(29), rhs = Expression(61, Sub) +- expression 54 operands: lhs = Expression(62, Add), rhs = Counter(30) +- expression 55 operands: lhs = Counter(28), rhs = Expression(63, Sub) +- expression 56 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 57 operands: lhs = Counter(26), rhs = Counter(27) +- expression 58 operands: lhs = Expression(59, Sub), rhs = Counter(32) +- expression 59 operands: lhs = Expression(60, Add), rhs = Counter(31) +- expression 60 operands: lhs = Counter(29), rhs = Expression(61, Sub) +- expression 61 operands: lhs = Expression(62, Add), rhs = Counter(30) +- expression 62 operands: lhs = Counter(28), rhs = Expression(63, Sub) +- expression 63 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 64 operands: lhs = Counter(26), rhs = Counter(27) +Number of file 0 mappings: 51 +- Code(Counter(0)) at (prev + 6, 1) to (start + 3, 28) +- Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 4, 31) + = (c1 - c2) +- Code(Counter(3)) at (prev + 5, 5) to (start + 0, 31) +- Code(Expression(1, Sub)) at (prev + 1, 5) to (start + 0, 31) + = (c3 - c4) +- Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28) +- Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31) + = (c5 - c6) +- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15) + = ((c5 - c6) - c7) +- Code(Zero) at (prev + 0, 32) to (start + 0, 48) +- Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15) +- Code(Zero) at (prev + 3, 32) to (start + 0, 48) +- Code(Zero) at (prev + 0, 51) to (start + 0, 65) +- Code(Zero) at (prev + 0, 75) to (start + 0, 90) +- Code(Expression(7, Sub)) at (prev + 1, 5) to (start + 0, 15) + = (c8 - c9) +- Code(Zero) at (prev + 5, 9) to (start + 3, 16) +- Code(Zero) at (prev + 5, 13) to (start + 0, 27) +- Code(Zero) at (prev + 2, 13) to (start + 0, 28) +- Code(Expression(6, Sub)) at (prev + 4, 9) to (start + 5, 6) + = ((c8 - c9) - c10) +- Code(Counter(12)) at (prev + 6, 5) to (start + 3, 6) +- Code(Expression(8, Sub)) at (prev + 4, 5) to (start + 3, 6) + = (c12 - c14) +- Code(Counter(15)) at (prev + 4, 9) to (start + 4, 6) +- Code(Expression(11, Sub)) at (prev + 5, 8) to (start + 0, 15) + = (c15 - c16) +- Code(Counter(17)) at (prev + 1, 9) to (start + 3, 10) +- Code(Expression(10, Sub)) at (prev + 5, 9) to (start + 3, 10) + = ((c15 - c16) - c17) +- Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15) + = ((c17 - c19) + c18) +- Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19) +- Code(Zero) at (prev + 3, 13) to (start + 0, 29) +- Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19) + = (((c17 - c19) + c18) - c20) +- Code(Zero) at (prev + 3, 13) to (start + 0, 29) +- Code(Expression(33, Add)) at (prev + 3, 5) to (start + 0, 15) + = (c23 + (((c20 - c22) + c21) - c23)) +- Code(Expression(35, Add)) at (prev + 1, 12) to (start + 0, 19) + = ((c20 - c22) + c21) +- Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19) +- Code(Expression(34, Sub)) at (prev + 2, 13) to (start + 0, 19) + = (((c20 - c22) + c21) - c23) +- Code(Expression(32, Sub)) at (prev + 4, 5) to (start + 2, 19) + = ((c23 + (((c20 - c22) + c21) - c23)) - c24) +- Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19) +- Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19) + = (((c23 + (((c20 - c22) + c21) - c23)) - c24) - c25) +- Code(Expression(60, Add)) at (prev + 3, 5) to (start + 0, 15) + = (c29 + ((c28 + ((c26 - c27) - c28)) - c30)) +- Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) +- Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14) +- Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19) +- Code(Expression(62, Add)) at (prev + 2, 13) to (start + 0, 23) + = (c28 + ((c26 - c27) - c28)) +- Code(Expression(64, Sub)) at (prev + 1, 20) to (start + 0, 27) + = (c26 - c27) +- Code(Counter(28)) at (prev + 1, 21) to (start + 0, 27) +- Code(Expression(63, Sub)) at (prev + 2, 21) to (start + 0, 27) + = ((c26 - c27) - c28) +- Code(Expression(61, Sub)) at (prev + 4, 13) to (start + 0, 19) + = ((c28 + ((c26 - c27) - c28)) - c30) +- Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25) +- Code(Expression(59, Sub)) at (prev + 2, 5) to (start + 0, 15) + = ((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) +- Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34) + = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - c32) +- Code(Zero) at (prev + 2, 5) to (start + 0, 15) +- Code(Zero) at (prev + 3, 9) to (start + 0, 44) +- Code(Zero) at (prev + 2, 1) to (start + 0, 2) + diff --git a/tests/coverage-map/status-quo/issue-84561.rs b/tests/coverage-map/status-quo/issue-84561.rs new file mode 100644 index 0000000000000..facf5b5b4cfbe --- /dev/null +++ b/tests/coverage-map/status-quo/issue-84561.rs @@ -0,0 +1,182 @@ +// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results. + +// failure-status: 101 +#[derive(PartialEq, Eq)] +struct Foo(u32); +fn test3() { + let is_true = std::env::args().len() == 1; + let bar = Foo(1); + assert_eq!(bar, Foo(1)); + let baz = Foo(0); + assert_ne!(baz, Foo(1)); + println!("{:?}", Foo(1)); + println!("{:?}", bar); + println!("{:?}", baz); + + assert_eq!(Foo(1), Foo(1)); + assert_ne!(Foo(0), Foo(1)); + assert_eq!(Foo(2), Foo(2)); + let bar = Foo(0); + assert_ne!(bar, Foo(3)); + assert_ne!(Foo(0), Foo(4)); + assert_eq!(Foo(3), Foo(3), "with a message"); + println!("{:?}", bar); + println!("{:?}", Foo(1)); + + assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" }); + assert_ne!( + Foo(0) + , + Foo(5) + , + "{}" + , + if + is_true + { + "true message" + } else { + "false message" + } + ); + + let is_true = std::env::args().len() == 1; + + assert_eq!( + Foo(1), + Foo(1) + ); + assert_ne!( + Foo(0), + Foo(1) + ); + assert_eq!( + Foo(2), + Foo(2) + ); + let bar = Foo(1); + assert_ne!( + bar, + Foo(3) + ); + if is_true { + assert_ne!( + Foo(0), + Foo(4) + ); + } else { + assert_eq!( + Foo(3), + Foo(3) + ); + } + if is_true { + assert_ne!( + Foo(0), + Foo(4), + "with a message" + ); + } else { + assert_eq!( + Foo(3), + Foo(3), + "with a message" + ); + } + assert_ne!( + if is_true { + Foo(0) + } else { + Foo(1) + }, + Foo(5) + ); + assert_ne!( + Foo(5), + if is_true { + Foo(0) + } else { + Foo(1) + } + ); + assert_ne!( + if is_true { + assert_eq!( + Foo(3), + Foo(3) + ); + Foo(0) + } else { + assert_ne!( + if is_true { + Foo(0) + } else { + Foo(1) + }, + Foo(5) + ); + Foo(1) + }, + Foo(5), + "with a message" + ); + assert_eq!( + Foo(1), + Foo(3), + "this assert should fail" + ); + assert_eq!( + Foo(3), + Foo(3), + "this assert should not be reached" + ); +} + +impl std::fmt::Debug for Foo { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "try and succeed")?; + Ok(()) + } +} + +static mut DEBUG_LEVEL_ENABLED: bool = false; + +macro_rules! debug { + ($($arg:tt)+) => ( + if unsafe { DEBUG_LEVEL_ENABLED } { + println!($($arg)+); + } + ); +} + +fn test1() { + debug!("debug is enabled"); + debug!("debug is enabled"); + let _ = 0; + debug!("debug is enabled"); + unsafe { + DEBUG_LEVEL_ENABLED = true; + } + debug!("debug is enabled"); +} + +macro_rules! call_debug { + ($($arg:tt)+) => ( + fn call_print(s: &str) { + print!("{}", s); + } + + call_print("called from call_debug: "); + debug!($($arg)+); + ); +} + +fn test2() { + call_debug!("debug is enabled"); +} + +fn main() { + test1(); + test2(); + test3(); +} diff --git a/tests/coverage-map/status-quo/issue-93054.cov-map b/tests/coverage-map/status-quo/issue-93054.cov-map new file mode 100644 index 0000000000000..52fe7f58d15d8 --- /dev/null +++ b/tests/coverage-map/status-quo/issue-93054.cov-map @@ -0,0 +1,24 @@ +Function name: issue_93054::foo2 (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 00, 1d] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 22, 1) to (start + 0, 29) + +Function name: issue_93054::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 00, 0d] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 30, 1) to (start + 0, 13) + +Function name: issue_93054::make (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1a, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 26, 1) to (start + 2, 2) + diff --git a/tests/coverage-map/status-quo/issue-93054.rs b/tests/coverage-map/status-quo/issue-93054.rs new file mode 100644 index 0000000000000..da546cfeef854 --- /dev/null +++ b/tests/coverage-map/status-quo/issue-93054.rs @@ -0,0 +1,30 @@ +#![allow(dead_code, unreachable_code)] + +// Regression test for #93054: Functions using uninhabited types often only have a single, +// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. +// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. + +// compile-flags: --edition=2021 + +enum Never {} + +impl Never { + fn foo(self) { + match self {} + make().map(|never| match never {}); + } + + fn bar(&self) { + match *self {} + } +} + +async fn foo2(never: Never) { + match never {} +} + +fn make() -> Option { + None +} + +fn main() {} diff --git a/tests/coverage-map/status-quo/lazy_boolean.cov-map b/tests/coverage-map/status-quo/lazy_boolean.cov-map new file mode 100644 index 0000000000000..b18a964043355 --- /dev/null +++ b/tests/coverage-map/status-quo/lazy_boolean.cov-map @@ -0,0 +1,223 @@ +Function name: lazy_boolean::main +Raw bytes (646): 0x[01, 01, a8, 01, 01, 05, 09, 9a, 05, 9f, 05, 09, 05, 02, 05, 02, 9f, 05, 09, 05, 02, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 97, 05, 00, 09, 9a, 05, 9f, 05, 09, 05, 02, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 8f, 05, 00, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 87, 05, 00, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, ff, 04, 00, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 21, ea, 04, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, e7, 04, 25, 21, ea, 04, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 25, e2, 04, e7, 04, 25, 21, ea, 04, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 1c, 01, 03, 01, 07, 0f, 05, 07, 10, 04, 06, 02, 04, 06, 00, 07, 97, 05, 02, 09, 00, 11, 9f, 05, 02, 0d, 00, 12, 9a, 05, 02, 0d, 00, 12, 8f, 05, 03, 09, 00, 11, 33, 02, 0d, 00, 12, 92, 05, 02, 0d, 00, 12, 87, 05, 02, 09, 00, 11, 6f, 00, 14, 00, 19, 11, 00, 1d, 00, 22, ff, 04, 01, 09, 00, 11, ab, 01, 00, 14, 00, 19, 15, 00, 1d, 00, 22, cb, 01, 04, 09, 00, 10, fa, 04, 01, 05, 03, 06, 19, 03, 06, 00, 07, f7, 04, 03, 09, 00, 10, 1d, 01, 05, 03, 06, f2, 04, 05, 05, 03, 06, ef, 04, 05, 09, 00, 10, ea, 04, 00, 11, 02, 06, 21, 02, 06, 00, 07, e7, 04, 02, 08, 00, 0f, 25, 00, 10, 02, 06, e2, 04, 02, 0c, 02, 06, df, 04, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 168 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 2 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 5 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 7 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 8 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 9 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 10 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 11 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 12 operands: lhs = Expression(165, Add), rhs = Zero +- expression 13 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 14 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 15 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 16 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 17 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 18 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 19 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 20 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 21 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 22 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 23 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 24 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 25 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 26 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 27 operands: lhs = Expression(163, Add), rhs = Zero +- expression 28 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 29 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 30 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 31 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 32 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 33 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 34 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 35 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 36 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 37 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 38 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 39 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 40 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 41 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 42 operands: lhs = Expression(161, Add), rhs = Zero +- expression 43 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 44 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 45 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 46 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 47 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 48 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 49 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 50 operands: lhs = Expression(159, Add), rhs = Zero +- expression 51 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 52 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 53 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 54 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 55 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 56 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 57 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 58 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 59 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 60 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 61 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 62 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 63 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 64 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 65 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 66 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 67 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 68 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 69 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 70 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 71 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 72 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 73 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 74 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 75 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 76 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 77 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 78 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 79 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 80 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 81 operands: lhs = Expression(157, Add), rhs = Counter(7) +- expression 82 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 83 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 84 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 85 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 86 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 87 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 88 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 89 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 90 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 91 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 92 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 93 operands: lhs = Counter(7), rhs = Expression(156, Sub) +- expression 94 operands: lhs = Expression(157, Add), rhs = Counter(7) +- expression 95 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 96 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 97 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 98 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 99 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 100 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 101 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 102 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 103 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 104 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 105 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 106 operands: lhs = Expression(155, Add), rhs = Counter(8) +- expression 107 operands: lhs = Counter(7), rhs = Expression(156, Sub) +- expression 108 operands: lhs = Expression(157, Add), rhs = Counter(7) +- expression 109 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 110 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 111 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 112 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 113 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 114 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 115 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 116 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 117 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 118 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 119 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 120 operands: lhs = Counter(8), rhs = Expression(154, Sub) +- expression 121 operands: lhs = Expression(155, Add), rhs = Counter(8) +- expression 122 operands: lhs = Counter(7), rhs = Expression(156, Sub) +- expression 123 operands: lhs = Expression(157, Add), rhs = Counter(7) +- expression 124 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 125 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 126 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 127 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 128 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 129 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 130 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 131 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 132 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 133 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 134 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 135 operands: lhs = Expression(153, Add), rhs = Counter(9) +- expression 136 operands: lhs = Counter(8), rhs = Expression(154, Sub) +- expression 137 operands: lhs = Expression(155, Add), rhs = Counter(8) +- expression 138 operands: lhs = Counter(7), rhs = Expression(156, Sub) +- expression 139 operands: lhs = Expression(157, Add), rhs = Counter(7) +- expression 140 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 141 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 142 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 143 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 144 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 145 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 146 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 147 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 148 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 149 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 150 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 151 operands: lhs = Counter(9), rhs = Expression(152, Sub) +- expression 152 operands: lhs = Expression(153, Add), rhs = Counter(9) +- expression 153 operands: lhs = Counter(8), rhs = Expression(154, Sub) +- expression 154 operands: lhs = Expression(155, Add), rhs = Counter(8) +- expression 155 operands: lhs = Counter(7), rhs = Expression(156, Sub) +- expression 156 operands: lhs = Expression(157, Add), rhs = Counter(7) +- expression 157 operands: lhs = Counter(6), rhs = Expression(158, Sub) +- expression 158 operands: lhs = Expression(159, Add), rhs = Counter(6) +- expression 159 operands: lhs = Counter(5), rhs = Expression(160, Sub) +- expression 160 operands: lhs = Expression(161, Add), rhs = Counter(5) +- expression 161 operands: lhs = Counter(4), rhs = Expression(162, Sub) +- expression 162 operands: lhs = Expression(163, Add), rhs = Counter(4) +- expression 163 operands: lhs = Counter(3), rhs = Expression(164, Sub) +- expression 164 operands: lhs = Expression(165, Add), rhs = Counter(3) +- expression 165 operands: lhs = Counter(2), rhs = Expression(166, Sub) +- expression 166 operands: lhs = Expression(167, Add), rhs = Counter(2) +- expression 167 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 28 +- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15) +- Code(Counter(1)) at (prev + 7, 16) to (start + 4, 6) +- Code(Expression(0, Sub)) at (prev + 4, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(165, Add)) at (prev + 2, 9) to (start + 0, 17) + = (c2 + ((c1 + (c0 - c1)) - c2)) +- Code(Expression(167, Add)) at (prev + 2, 13) to (start + 0, 18) + = (c1 + (c0 - c1)) +- Code(Expression(166, Sub)) at (prev + 2, 13) to (start + 0, 18) + = ((c1 + (c0 - c1)) - c2) +- Code(Expression(163, Add)) at (prev + 3, 9) to (start + 0, 17) + = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) +- Code(Expression(12, Add)) at (prev + 2, 13) to (start + 0, 18) + = ((c2 + ((c1 + (c0 - c1)) - c2)) + Zero) +- Code(Expression(164, Sub)) at (prev + 2, 13) to (start + 0, 18) + = ((c2 + ((c1 + (c0 - c1)) - c2)) - c3) +- Code(Expression(161, Add)) at (prev + 2, 9) to (start + 0, 17) + = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) +- Code(Expression(27, Add)) at (prev + 0, 20) to (start + 0, 25) + = ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) + Zero) +- Code(Counter(4)) at (prev + 0, 29) to (start + 0, 34) +- Code(Expression(159, Add)) at (prev + 1, 9) to (start + 0, 17) + = (c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) +- Code(Expression(42, Add)) at (prev + 0, 20) to (start + 0, 25) + = ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) + Zero) +- Code(Counter(5)) at (prev + 0, 29) to (start + 0, 34) +- Code(Expression(50, Add)) at (prev + 4, 9) to (start + 0, 16) + = ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) + Zero) +- Code(Expression(158, Sub)) at (prev + 1, 5) to (start + 3, 6) + = ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6) +- Code(Counter(6)) at (prev + 3, 6) to (start + 0, 7) +- Code(Expression(157, Add)) at (prev + 3, 9) to (start + 0, 16) + = (c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) +- Code(Counter(7)) at (prev + 1, 5) to (start + 3, 6) +- Code(Expression(156, Sub)) at (prev + 5, 5) to (start + 3, 6) + = ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7) +- Code(Expression(155, Add)) at (prev + 5, 9) to (start + 0, 16) + = (c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) +- Code(Expression(154, Sub)) at (prev + 0, 17) to (start + 2, 6) + = ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8) +- Code(Counter(8)) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(153, Add)) at (prev + 2, 8) to (start + 0, 15) + = (c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) +- Code(Counter(9)) at (prev + 0, 16) to (start + 2, 6) +- Code(Expression(152, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) - c9) +- Code(Expression(151, Add)) at (prev + 3, 1) to (start + 0, 2) + = (c9 + ((c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) - c9)) + diff --git a/tests/coverage-map/status-quo/lazy_boolean.rs b/tests/coverage-map/status-quo/lazy_boolean.rs new file mode 100644 index 0000000000000..bb6219e851c8a --- /dev/null +++ b/tests/coverage-map/status-quo/lazy_boolean.rs @@ -0,0 +1,61 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let (mut a, mut b, mut c) = (0, 0, 0); + if is_true { + a = 1; + b = 10; + c = 100; + } + let + somebool + = + a < b + || + b < c + ; + let + somebool + = + b < a + || + b < c + ; + let somebool = a < b && b < c; + let somebool = b < a && b < c; + + if + ! + is_true + { + a = 2 + ; + } + + if + is_true + { + b = 30 + ; + } + else + { + c = 400 + ; + } + + if !is_true { + a = 2; + } + + if is_true { + b = 30; + } else { + c = 400; + } +} diff --git a/tests/coverage-map/status-quo/loop_break_value.cov-map b/tests/coverage-map/status-quo/loop_break_value.cov-map new file mode 100644 index 0000000000000..75018442d0757 --- /dev/null +++ b/tests/coverage-map/status-quo/loop_break_value.cov-map @@ -0,0 +1,8 @@ +Function name: loop_break_value::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 01, 0a, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 3, 1) to (start + 10, 2) + diff --git a/tests/coverage-map/status-quo/loop_break_value.rs b/tests/coverage-map/status-quo/loop_break_value.rs new file mode 100644 index 0000000000000..dbc4fad7a2316 --- /dev/null +++ b/tests/coverage-map/status-quo/loop_break_value.rs @@ -0,0 +1,13 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + let result + = + loop + { + break + 10 + ; + } + ; +} diff --git a/tests/coverage-map/status-quo/loops_branches.cov-map b/tests/coverage-map/status-quo/loops_branches.cov-map new file mode 100644 index 0000000000000..56fafc0a67b1f --- /dev/null +++ b/tests/coverage-map/status-quo/loops_branches.cov-map @@ -0,0 +1,193 @@ +Function name: ::fmt +Raw bytes (262): 0x[01, 01, 36, 05, 09, 0a, 02, 00, 00, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, d3, 01, d7, 01, 0d, 00, 11, 15, ca, 01, 00, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, ca, 01, 15, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, c6, 01, 1d, ca, 01, 15, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, be, 01, c2, 01, 00, 00, c6, 01, 1d, ca, 01, 15, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, bb, 01, 11, be, 01, c2, 01, 00, 00, c6, 01, 1d, ca, 01, 15, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, 25, b3, 01, b6, 01, 19, bb, 01, 11, be, 01, c2, 01, 00, 00, c6, 01, 1d, ca, 01, 15, cf, 01, 19, d3, 01, d7, 01, 0d, 00, 11, 15, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, ca, 01, 03, 0d, 00, 0e, cf, 01, 00, 12, 00, 17, 2b, 01, 10, 00, 14, c6, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, c2, 01, 01, 12, 00, 13, bb, 01, 01, 11, 00, 22, b6, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, af, 01, 01, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 54 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Expression(2, Sub), rhs = Expression(0, Sub) +- expression 2 operands: lhs = Zero, rhs = Zero +- expression 3 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 4 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 5 operands: lhs = Counter(3), rhs = Zero +- expression 6 operands: lhs = Counter(4), rhs = Counter(5) +- expression 7 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 8 operands: lhs = Counter(3), rhs = Zero +- expression 9 operands: lhs = Counter(4), rhs = Counter(5) +- expression 10 operands: lhs = Expression(50, Sub), rhs = Zero +- expression 11 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 12 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 13 operands: lhs = Counter(3), rhs = Zero +- expression 14 operands: lhs = Counter(4), rhs = Counter(5) +- expression 15 operands: lhs = Expression(50, Sub), rhs = Counter(5) +- expression 16 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 17 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 18 operands: lhs = Counter(3), rhs = Zero +- expression 19 operands: lhs = Counter(4), rhs = Counter(5) +- expression 20 operands: lhs = Expression(49, Sub), rhs = Counter(7) +- expression 21 operands: lhs = Expression(50, Sub), rhs = Counter(5) +- expression 22 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 23 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 24 operands: lhs = Counter(3), rhs = Zero +- expression 25 operands: lhs = Counter(4), rhs = Counter(5) +- expression 26 operands: lhs = Expression(47, Sub), rhs = Expression(48, Sub) +- expression 27 operands: lhs = Zero, rhs = Zero +- expression 28 operands: lhs = Expression(49, Sub), rhs = Counter(7) +- expression 29 operands: lhs = Expression(50, Sub), rhs = Counter(5) +- expression 30 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 31 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 32 operands: lhs = Counter(3), rhs = Zero +- expression 33 operands: lhs = Counter(4), rhs = Counter(5) +- expression 34 operands: lhs = Expression(46, Add), rhs = Counter(4) +- expression 35 operands: lhs = Expression(47, Sub), rhs = Expression(48, Sub) +- expression 36 operands: lhs = Zero, rhs = Zero +- expression 37 operands: lhs = Expression(49, Sub), rhs = Counter(7) +- expression 38 operands: lhs = Expression(50, Sub), rhs = Counter(5) +- expression 39 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 40 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 41 operands: lhs = Counter(3), rhs = Zero +- expression 42 operands: lhs = Counter(4), rhs = Counter(5) +- expression 43 operands: lhs = Counter(9), rhs = Expression(44, Add) +- expression 44 operands: lhs = Expression(45, Sub), rhs = Counter(6) +- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(4) +- expression 46 operands: lhs = Expression(47, Sub), rhs = Expression(48, Sub) +- expression 47 operands: lhs = Zero, rhs = Zero +- expression 48 operands: lhs = Expression(49, Sub), rhs = Counter(7) +- expression 49 operands: lhs = Expression(50, Sub), rhs = Counter(5) +- expression 50 operands: lhs = Expression(51, Add), rhs = Counter(6) +- expression 51 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) +- expression 52 operands: lhs = Counter(3), rhs = Zero +- expression 53 operands: lhs = Counter(4), rhs = Counter(5) +Number of file 0 mappings: 20 +- Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16) +- Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21) +- Code(Zero) at (prev + 1, 23) to (start + 0, 27) +- Code(Zero) at (prev + 0, 28) to (start + 0, 30) +- Code(Expression(0, Sub)) at (prev + 1, 14) to (start + 0, 15) + = (c1 - c2) +- Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 30) + = ((Zero - Zero) + (c1 - c2)) +- Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31) +- Code(Zero) at (prev + 1, 16) to (start + 1, 10) +- Code(Expression(50, Sub)) at (prev + 3, 13) to (start + 0, 14) + = (((c3 + Zero) + (c4 + c5)) - c6) +- Code(Expression(51, Add)) at (prev + 0, 18) to (start + 0, 23) + = ((c3 + Zero) + (c4 + c5)) +- Code(Expression(10, Add)) at (prev + 1, 16) to (start + 0, 20) + = ((((c3 + Zero) + (c4 + c5)) - c6) + Zero) +- Code(Expression(49, Sub)) at (prev + 1, 20) to (start + 0, 25) + = ((((c3 + Zero) + (c4 + c5)) - c6) - c5) +- Code(Zero) at (prev + 1, 27) to (start + 0, 31) +- Code(Zero) at (prev + 0, 32) to (start + 0, 34) +- Code(Expression(48, Sub)) at (prev + 1, 18) to (start + 0, 19) + = (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7) +- Code(Expression(46, Add)) at (prev + 1, 17) to (start + 0, 34) + = ((Zero - Zero) + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) +- Code(Expression(45, Sub)) at (prev + 0, 34) to (start + 0, 35) + = (((Zero - Zero) + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4) +- Code(Zero) at (prev + 1, 20) to (start + 1, 14) +- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) +- Code(Expression(43, Add)) at (prev + 1, 5) to (start + 0, 6) + = (c9 + ((((Zero - Zero) + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4) + c6)) + +Function name: ::fmt +Raw bytes (266): 0x[01, 01, 38, 01, 05, 02, 09, 0e, 12, 00, 00, 02, 09, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, d7, 01, db, 01, 05, 0d, 11, 15, ce, 01, 00, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, ce, 01, 11, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, ca, 01, 1d, ce, 01, 11, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, c2, 01, c6, 01, 00, 00, ca, 01, 1d, ce, 01, 11, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, bf, 01, 15, c2, 01, c6, 01, 00, 00, ca, 01, 1d, ce, 01, 11, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, ba, 01, df, 01, bf, 01, 15, c2, 01, c6, 01, 00, 00, ca, 01, 1d, ce, 01, 11, d3, 01, 19, d7, 01, db, 01, 05, 0d, 11, 15, 19, 25, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 12, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, ce, 01, 02, 0d, 00, 0e, d3, 01, 00, 12, 00, 17, 33, 01, 10, 00, 15, 00, 00, 16, 01, 0e, ca, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, c6, 01, 01, 12, 00, 13, bf, 01, 01, 11, 00, 22, ba, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, b7, 01, 01, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 56 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 2 operands: lhs = Expression(3, Sub), rhs = Expression(4, Sub) +- expression 3 operands: lhs = Zero, rhs = Zero +- expression 4 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 5 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 6 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 7 operands: lhs = Counter(1), rhs = Counter(3) +- expression 8 operands: lhs = Counter(4), rhs = Counter(5) +- expression 9 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 10 operands: lhs = Counter(1), rhs = Counter(3) +- expression 11 operands: lhs = Counter(4), rhs = Counter(5) +- expression 12 operands: lhs = Expression(51, Sub), rhs = Zero +- expression 13 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 14 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 15 operands: lhs = Counter(1), rhs = Counter(3) +- expression 16 operands: lhs = Counter(4), rhs = Counter(5) +- expression 17 operands: lhs = Expression(51, Sub), rhs = Counter(4) +- expression 18 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 19 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 20 operands: lhs = Counter(1), rhs = Counter(3) +- expression 21 operands: lhs = Counter(4), rhs = Counter(5) +- expression 22 operands: lhs = Expression(50, Sub), rhs = Counter(7) +- expression 23 operands: lhs = Expression(51, Sub), rhs = Counter(4) +- expression 24 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 25 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 26 operands: lhs = Counter(1), rhs = Counter(3) +- expression 27 operands: lhs = Counter(4), rhs = Counter(5) +- expression 28 operands: lhs = Expression(48, Sub), rhs = Expression(49, Sub) +- expression 29 operands: lhs = Zero, rhs = Zero +- expression 30 operands: lhs = Expression(50, Sub), rhs = Counter(7) +- expression 31 operands: lhs = Expression(51, Sub), rhs = Counter(4) +- expression 32 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 33 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 34 operands: lhs = Counter(1), rhs = Counter(3) +- expression 35 operands: lhs = Counter(4), rhs = Counter(5) +- expression 36 operands: lhs = Expression(47, Add), rhs = Counter(5) +- expression 37 operands: lhs = Expression(48, Sub), rhs = Expression(49, Sub) +- expression 38 operands: lhs = Zero, rhs = Zero +- expression 39 operands: lhs = Expression(50, Sub), rhs = Counter(7) +- expression 40 operands: lhs = Expression(51, Sub), rhs = Counter(4) +- expression 41 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 42 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 43 operands: lhs = Counter(1), rhs = Counter(3) +- expression 44 operands: lhs = Counter(4), rhs = Counter(5) +- expression 45 operands: lhs = Expression(46, Sub), rhs = Expression(55, Add) +- expression 46 operands: lhs = Expression(47, Add), rhs = Counter(5) +- expression 47 operands: lhs = Expression(48, Sub), rhs = Expression(49, Sub) +- expression 48 operands: lhs = Zero, rhs = Zero +- expression 49 operands: lhs = Expression(50, Sub), rhs = Counter(7) +- expression 50 operands: lhs = Expression(51, Sub), rhs = Counter(4) +- expression 51 operands: lhs = Expression(52, Add), rhs = Counter(6) +- expression 52 operands: lhs = Expression(53, Add), rhs = Expression(54, Add) +- expression 53 operands: lhs = Counter(1), rhs = Counter(3) +- expression 54 operands: lhs = Counter(4), rhs = Counter(5) +- expression 55 operands: lhs = Counter(6), rhs = Counter(9) +Number of file 0 mappings: 20 +- Code(Counter(0)) at (prev + 34, 5) to (start + 1, 17) +- Code(Zero) at (prev + 1, 18) to (start + 1, 10) +- Code(Expression(0, Sub)) at (prev + 2, 16) to (start + 0, 21) + = (c0 - c1) +- Code(Zero) at (prev + 1, 23) to (start + 0, 27) +- Code(Zero) at (prev + 0, 28) to (start + 0, 30) +- Code(Expression(4, Sub)) at (prev + 1, 14) to (start + 0, 15) + = ((c0 - c1) - c2) +- Code(Expression(2, Add)) at (prev + 1, 13) to (start + 0, 30) + = ((Zero - Zero) + ((c0 - c1) - c2)) +- Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31) +- Code(Expression(51, Sub)) at (prev + 2, 13) to (start + 0, 14) + = (((c1 + c3) + (c4 + c5)) - c6) +- Code(Expression(52, Add)) at (prev + 0, 18) to (start + 0, 23) + = ((c1 + c3) + (c4 + c5)) +- Code(Expression(12, Add)) at (prev + 1, 16) to (start + 0, 21) + = ((((c1 + c3) + (c4 + c5)) - c6) + Zero) +- Code(Zero) at (prev + 0, 22) to (start + 1, 14) +- Code(Expression(50, Sub)) at (prev + 2, 20) to (start + 0, 25) + = ((((c1 + c3) + (c4 + c5)) - c6) - c4) +- Code(Zero) at (prev + 1, 27) to (start + 0, 31) +- Code(Zero) at (prev + 0, 32) to (start + 0, 34) +- Code(Expression(49, Sub)) at (prev + 1, 18) to (start + 0, 19) + = (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7) +- Code(Expression(47, Add)) at (prev + 1, 17) to (start + 0, 34) + = ((Zero - Zero) + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) +- Code(Expression(46, Sub)) at (prev + 0, 34) to (start + 0, 35) + = (((Zero - Zero) + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5) +- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) +- Code(Expression(45, Add)) at (prev + 1, 5) to (start + 0, 6) + = ((((Zero - Zero) + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5) + (c6 + c9)) + +Function name: loops_branches::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 55, 1) to (start + 5, 2) + diff --git a/tests/coverage-map/status-quo/loops_branches.rs b/tests/coverage-map/status-quo/loops_branches.rs new file mode 100644 index 0000000000000..f3a343bcc1f42 --- /dev/null +++ b/tests/coverage-map/status-quo/loops_branches.rs @@ -0,0 +1,60 @@ +#![allow(unused_assignments, unused_variables, while_true)] + +// This test confirms that (1) unexecuted infinite loops are handled correctly by the +// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped. + +struct DebugTest; + +impl std::fmt::Debug for DebugTest { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + if true { + if false { + while true {} + } + write!(f, "cool")?; + } else { + } + + for i in 0..10 { + if true { + if false { + while true {} + } + write!(f, "cool")?; + } else { + } + } + Ok(()) + } +} + +struct DisplayTest; + +impl std::fmt::Display for DisplayTest { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + if false { + } else { + if false { + while true {} + } + write!(f, "cool")?; + } + for i in 0..10 { + if false { + } else { + if false { + while true {} + } + write!(f, "cool")?; + } + } + Ok(()) + } +} + +fn main() { + let debug_test = DebugTest; + println!("{:?}", debug_test); + let display_test = DisplayTest; + println!("{}", display_test); +} diff --git a/tests/coverage-map/status-quo/match_or_pattern.cov-map b/tests/coverage-map/status-quo/match_or_pattern.cov-map new file mode 100644 index 0000000000000..d63407a99c35f --- /dev/null +++ b/tests/coverage-map/status-quo/match_or_pattern.cov-map @@ -0,0 +1,83 @@ +Function name: match_or_pattern::main +Raw bytes (202): 0x[01, 01, 23, 01, 05, 05, 02, 09, 0d, 2f, 11, 09, 0d, 2b, 15, 2f, 11, 09, 0d, 15, 26, 2b, 15, 2f, 11, 09, 0d, 19, 1d, 57, 21, 19, 1d, 53, 25, 57, 21, 19, 1d, 25, 4e, 53, 25, 57, 21, 19, 1d, 29, 2d, 7f, 31, 29, 2d, 7b, 35, 7f, 31, 29, 2d, 35, 76, 7b, 35, 7f, 31, 29, 2d, 39, 3d, 8b, 01, 41, 39, 3d, 19, 01, 01, 01, 08, 0f, 05, 08, 10, 03, 06, 02, 03, 06, 00, 07, 07, 01, 0b, 00, 11, 11, 03, 1b, 00, 1d, 2f, 01, 0e, 00, 10, 2b, 02, 08, 00, 0f, 15, 00, 10, 03, 06, 26, 03, 06, 00, 07, 23, 01, 0b, 00, 11, 21, 01, 1b, 00, 1d, 57, 01, 0e, 00, 10, 53, 02, 08, 00, 0f, 25, 00, 10, 03, 06, 4e, 03, 06, 00, 07, 4b, 01, 0b, 00, 11, 31, 01, 1b, 00, 1d, 7f, 01, 0e, 00, 10, 7b, 02, 08, 00, 0f, 35, 00, 10, 03, 06, 76, 03, 06, 00, 07, 73, 01, 0b, 00, 11, 41, 01, 1b, 00, 1d, 8b, 01, 01, 0e, 00, 10, 87, 01, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 35 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Expression(11, Add), rhs = Counter(4) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +- expression 5 operands: lhs = Expression(10, Add), rhs = Counter(5) +- expression 6 operands: lhs = Expression(11, Add), rhs = Counter(4) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 8 operands: lhs = Counter(5), rhs = Expression(9, Sub) +- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(5) +- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(4) +- expression 11 operands: lhs = Counter(2), rhs = Counter(3) +- expression 12 operands: lhs = Counter(6), rhs = Counter(7) +- expression 13 operands: lhs = Expression(21, Add), rhs = Counter(8) +- expression 14 operands: lhs = Counter(6), rhs = Counter(7) +- expression 15 operands: lhs = Expression(20, Add), rhs = Counter(9) +- expression 16 operands: lhs = Expression(21, Add), rhs = Counter(8) +- expression 17 operands: lhs = Counter(6), rhs = Counter(7) +- expression 18 operands: lhs = Counter(9), rhs = Expression(19, Sub) +- expression 19 operands: lhs = Expression(20, Add), rhs = Counter(9) +- expression 20 operands: lhs = Expression(21, Add), rhs = Counter(8) +- expression 21 operands: lhs = Counter(6), rhs = Counter(7) +- expression 22 operands: lhs = Counter(10), rhs = Counter(11) +- expression 23 operands: lhs = Expression(31, Add), rhs = Counter(12) +- expression 24 operands: lhs = Counter(10), rhs = Counter(11) +- expression 25 operands: lhs = Expression(30, Add), rhs = Counter(13) +- expression 26 operands: lhs = Expression(31, Add), rhs = Counter(12) +- expression 27 operands: lhs = Counter(10), rhs = Counter(11) +- expression 28 operands: lhs = Counter(13), rhs = Expression(29, Sub) +- expression 29 operands: lhs = Expression(30, Add), rhs = Counter(13) +- expression 30 operands: lhs = Expression(31, Add), rhs = Counter(12) +- expression 31 operands: lhs = Counter(10), rhs = Counter(11) +- expression 32 operands: lhs = Counter(14), rhs = Counter(15) +- expression 33 operands: lhs = Expression(34, Add), rhs = Counter(16) +- expression 34 operands: lhs = Counter(14), rhs = Counter(15) +Number of file 0 mappings: 25 +- Code(Counter(0)) at (prev + 1, 1) to (start + 8, 15) +- Code(Counter(1)) at (prev + 8, 16) to (start + 3, 6) +- Code(Expression(0, Sub)) at (prev + 3, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 11) to (start + 0, 17) + = (c1 + (c0 - c1)) +- Code(Counter(4)) at (prev + 3, 27) to (start + 0, 29) +- Code(Expression(11, Add)) at (prev + 1, 14) to (start + 0, 16) + = (c2 + c3) +- Code(Expression(10, Add)) at (prev + 2, 8) to (start + 0, 15) + = ((c2 + c3) + c4) +- Code(Counter(5)) at (prev + 0, 16) to (start + 3, 6) +- Code(Expression(9, Sub)) at (prev + 3, 6) to (start + 0, 7) + = (((c2 + c3) + c4) - c5) +- Code(Expression(8, Add)) at (prev + 1, 11) to (start + 0, 17) + = (c5 + (((c2 + c3) + c4) - c5)) +- Code(Counter(8)) at (prev + 1, 27) to (start + 0, 29) +- Code(Expression(21, Add)) at (prev + 1, 14) to (start + 0, 16) + = (c6 + c7) +- Code(Expression(20, Add)) at (prev + 2, 8) to (start + 0, 15) + = ((c6 + c7) + c8) +- Code(Counter(9)) at (prev + 0, 16) to (start + 3, 6) +- Code(Expression(19, Sub)) at (prev + 3, 6) to (start + 0, 7) + = (((c6 + c7) + c8) - c9) +- Code(Expression(18, Add)) at (prev + 1, 11) to (start + 0, 17) + = (c9 + (((c6 + c7) + c8) - c9)) +- Code(Counter(12)) at (prev + 1, 27) to (start + 0, 29) +- Code(Expression(31, Add)) at (prev + 1, 14) to (start + 0, 16) + = (c10 + c11) +- Code(Expression(30, Add)) at (prev + 2, 8) to (start + 0, 15) + = ((c10 + c11) + c12) +- Code(Counter(13)) at (prev + 0, 16) to (start + 3, 6) +- Code(Expression(29, Sub)) at (prev + 3, 6) to (start + 0, 7) + = (((c10 + c11) + c12) - c13) +- Code(Expression(28, Add)) at (prev + 1, 11) to (start + 0, 17) + = (c13 + (((c10 + c11) + c12) - c13)) +- Code(Counter(16)) at (prev + 1, 27) to (start + 0, 29) +- Code(Expression(34, Add)) at (prev + 1, 14) to (start + 0, 16) + = (c14 + c15) +- Code(Expression(33, Add)) at (prev + 2, 1) to (start + 0, 2) + = ((c14 + c15) + c16) + diff --git a/tests/coverage-map/status-quo/match_or_pattern.rs b/tests/coverage-map/status-quo/match_or_pattern.rs new file mode 100644 index 0000000000000..ab7aee51d1bc4 --- /dev/null +++ b/tests/coverage-map/status-quo/match_or_pattern.rs @@ -0,0 +1,43 @@ +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut a: u8 = 0; + let mut b: u8 = 0; + if is_true { + a = 2; + b = 0; + } + match (a, b) { + // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`. + // This test confirms a fix for Issue #79569. + (0 | 1, 2 | 3) => {} + _ => {} + } + if is_true { + a = 0; + b = 0; + } + match (a, b) { + (0 | 1, 2 | 3) => {} + _ => {} + } + if is_true { + a = 2; + b = 2; + } + match (a, b) { + (0 | 1, 2 | 3) => {} + _ => {} + } + if is_true { + a = 0; + b = 2; + } + match (a, b) { + (0 | 1, 2 | 3) => {} + _ => {} + } +} diff --git a/tests/coverage-map/status-quo/nested_loops.cov-map b/tests/coverage-map/status-quo/nested_loops.cov-map new file mode 100644 index 0000000000000..35d92594e75e3 --- /dev/null +++ b/tests/coverage-map/status-quo/nested_loops.cov-map @@ -0,0 +1,51 @@ +Function name: nested_loops::main +Raw bytes (115): 0x[01, 01, 17, 01, 57, 05, 09, 03, 0d, 4e, 53, 03, 0d, 15, 19, 4b, 09, 4e, 53, 03, 0d, 15, 19, 46, 05, 4b, 09, 4e, 53, 03, 0d, 15, 19, 42, 19, 46, 05, 4b, 09, 4e, 53, 03, 0d, 15, 19, 05, 09, 11, 0d, 0d, 01, 01, 01, 02, 1b, 03, 04, 13, 00, 20, 4e, 01, 0d, 01, 18, 4b, 02, 12, 00, 17, 46, 01, 10, 00, 16, 05, 01, 11, 00, 16, 42, 01, 0e, 03, 16, 3e, 04, 11, 01, 1b, 11, 02, 15, 00, 21, 15, 01, 18, 02, 12, 19, 03, 0e, 00, 0f, 57, 02, 09, 00, 17, 5b, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 23 +- expression 0 operands: lhs = Counter(0), rhs = Expression(21, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) +- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(5), rhs = Counter(6) +- expression 6 operands: lhs = Expression(18, Add), rhs = Counter(2) +- expression 7 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) +- expression 8 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 9 operands: lhs = Counter(5), rhs = Counter(6) +- expression 10 operands: lhs = Expression(17, Sub), rhs = Counter(1) +- expression 11 operands: lhs = Expression(18, Add), rhs = Counter(2) +- expression 12 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) +- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 14 operands: lhs = Counter(5), rhs = Counter(6) +- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(6) +- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(1) +- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(2) +- expression 18 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) +- expression 19 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 20 operands: lhs = Counter(5), rhs = Counter(6) +- expression 21 operands: lhs = Counter(1), rhs = Counter(2) +- expression 22 operands: lhs = Counter(4), rhs = Counter(3) +Number of file 0 mappings: 13 +- Code(Counter(0)) at (prev + 1, 1) to (start + 2, 27) +- Code(Expression(0, Add)) at (prev + 4, 19) to (start + 0, 32) + = (c0 + (c1 + c2)) +- Code(Expression(19, Sub)) at (prev + 1, 13) to (start + 1, 24) + = ((c0 + (c1 + c2)) - c3) +- Code(Expression(18, Add)) at (prev + 2, 18) to (start + 0, 23) + = (((c0 + (c1 + c2)) - c3) + (c5 + c6)) +- Code(Expression(17, Sub)) at (prev + 1, 16) to (start + 0, 22) + = ((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) +- Code(Counter(1)) at (prev + 1, 17) to (start + 0, 22) +- Code(Expression(16, Sub)) at (prev + 1, 14) to (start + 3, 22) + = (((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) - c1) +- Code(Expression(15, Sub)) at (prev + 4, 17) to (start + 1, 27) + = ((((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) - c1) - c6) +- Code(Counter(4)) at (prev + 2, 21) to (start + 0, 33) +- Code(Counter(5)) at (prev + 1, 24) to (start + 2, 18) +- Code(Counter(6)) at (prev + 3, 14) to (start + 0, 15) +- Code(Expression(21, Add)) at (prev + 2, 9) to (start + 0, 23) + = (c1 + c2) +- Code(Expression(22, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c4 + c3) + diff --git a/tests/coverage-map/status-quo/nested_loops.rs b/tests/coverage-map/status-quo/nested_loops.rs new file mode 100644 index 0000000000000..4c7c784279650 --- /dev/null +++ b/tests/coverage-map/status-quo/nested_loops.rs @@ -0,0 +1,25 @@ +fn main() { + let is_true = std::env::args().len() == 1; + let mut countdown = 10; + + 'outer: while countdown > 0 { + let mut a = 100; + let mut b = 100; + for _ in 0..50 { + if a < 30 { + break; + } + a -= 5; + b -= 5; + if b < 90 { + a -= 10; + if is_true { + break 'outer; + } else { + a -= 2; + } + } + } + countdown -= 1; + } +} diff --git a/tests/coverage-map/status-quo/no_cov_crate.cov-map b/tests/coverage-map/status-quo/no_cov_crate.cov-map new file mode 100644 index 0000000000000..7ab5995dc2892 --- /dev/null +++ b/tests/coverage-map/status-quo/no_cov_crate.cov-map @@ -0,0 +1,78 @@ +Function name: no_cov_crate::add_coverage_1 +Raw bytes (9): 0x[01, 01, 00, 01, 01, 14, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 20, 1) to (start + 2, 2) + +Function name: no_cov_crate::add_coverage_2 +Raw bytes (9): 0x[01, 01, 00, 01, 01, 18, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 24, 1) to (start + 2, 2) + +Function name: no_cov_crate::add_coverage_not_called (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2) + +Function name: no_cov_crate::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 4d, 01, 0b, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 77, 1) to (start + 11, 2) + +Function name: no_cov_crate::nested_fns::outer +Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 05, 0c, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 49, 5) to (start + 12, 6) + +Function name: no_cov_crate::nested_fns::outer_both_covered +Raw bytes (9): 0x[01, 01, 00, 01, 01, 3f, 05, 0b, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 63, 5) to (start + 11, 6) + +Function name: no_cov_crate::nested_fns::outer_both_covered::inner +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 43, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 67, 9) to (start + 1, 23) +- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14) +- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10) + = (c1 + (c0 - c1)) + +Function name: no_cov_crate::nested_fns::outer_not_covered::inner +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 26, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 38, 9) to (start + 1, 23) +- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14) +- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10) + = (c1 + (c0 - c1)) + diff --git a/tests/coverage-map/status-quo/no_cov_crate.rs b/tests/coverage-map/status-quo/no_cov_crate.rs new file mode 100644 index 0000000000000..5b748aeefb767 --- /dev/null +++ b/tests/coverage-map/status-quo/no_cov_crate.rs @@ -0,0 +1,88 @@ +// Enables `no_coverage` on the entire crate +#![feature(no_coverage)] + +#[no_coverage] +fn do_not_add_coverage_1() { + println!("called but not covered"); +} + +fn do_not_add_coverage_2() { + #![no_coverage] + println!("called but not covered"); +} + +#[no_coverage] +#[allow(dead_code)] +fn do_not_add_coverage_not_called() { + println!("not called and not covered"); +} + +fn add_coverage_1() { + println!("called and covered"); +} + +fn add_coverage_2() { + println!("called and covered"); +} + +#[allow(dead_code)] +fn add_coverage_not_called() { + println!("not called but covered"); +} + +// FIXME: These test-cases illustrate confusing results of nested functions. +// See https://github.com/rust-lang/rust/issues/93319 +mod nested_fns { + #[no_coverage] + pub fn outer_not_covered(is_true: bool) { + fn inner(is_true: bool) { + if is_true { + println!("called and covered"); + } else { + println!("absolutely not covered"); + } + } + println!("called but not covered"); + inner(is_true); + } + + pub fn outer(is_true: bool) { + println!("called and covered"); + inner_not_covered(is_true); + + #[no_coverage] + fn inner_not_covered(is_true: bool) { + if is_true { + println!("called but not covered"); + } else { + println!("absolutely not covered"); + } + } + } + + pub fn outer_both_covered(is_true: bool) { + println!("called and covered"); + inner(is_true); + + fn inner(is_true: bool) { + if is_true { + println!("called and covered"); + } else { + println!("absolutely not covered"); + } + } + } +} + +fn main() { + let is_true = std::env::args().len() == 1; + + do_not_add_coverage_1(); + do_not_add_coverage_2(); + add_coverage_1(); + add_coverage_2(); + + nested_fns::outer_not_covered(is_true); + nested_fns::outer(is_true); + nested_fns::outer_both_covered(is_true); +} diff --git a/tests/coverage-map/status-quo/overflow.cov-map b/tests/coverage-map/status-quo/overflow.cov-map new file mode 100644 index 0000000000000..bfffd9b2ab515 --- /dev/null +++ b/tests/coverage-map/status-quo/overflow.cov-map @@ -0,0 +1,43 @@ +Function name: overflow::main +Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0f, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 8 +- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add) +- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1) +- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 27) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) + = (c0 + (c1 + (c2 + c3))) +- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) + = ((c0 + (c1 + (c2 + c3))) - c4) +- Code(Counter(1)) at (prev + 0, 27) to (start + 3, 10) +- Code(Expression(4, Sub)) at (prev + 3, 19) to (start + 0, 32) + = (((c0 + (c1 + (c2 + c3))) - c4) - c1) +- Code(Counter(2)) at (prev + 0, 33) to (start + 3, 10) +- Code(Counter(3)) at (prev + 3, 10) to (start + 0, 11) +- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23) + = (c1 + (c2 + c3)) +- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) + +Function name: overflow::might_overflow +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 18) +- Code(Counter(1)) at (prev + 1, 19) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 5, 2) + = (c1 + (c0 - c1)) + diff --git a/tests/coverage-map/status-quo/overflow.rs b/tests/coverage-map/status-quo/overflow.rs new file mode 100644 index 0000000000000..bbb65c1b35df6 --- /dev/null +++ b/tests/coverage-map/status-quo/overflow.rs @@ -0,0 +1,63 @@ +#![allow(unused_assignments)] +// failure-status: 101 + +fn might_overflow(to_add: u32) -> u32 { + if to_add > 5 { + println!("this will probably overflow"); + } + let add_to = u32::MAX - 5; + println!("does {} + {} overflow?", add_to, to_add); + let result = to_add + add_to; + println!("continuing after overflow check"); + result +} + +fn main() -> Result<(), u8> { + let mut countdown = 10; + while countdown > 0 { + if countdown == 1 { + let result = might_overflow(10); + println!("Result: {}", result); + } else if countdown < 5 { + let result = might_overflow(1); + println!("Result: {}", result); + } + countdown -= 1; + } + Ok(()) +} + +// Notes: +// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`, +// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`. +// 2. This test confirms the coverage generated when a program passes or fails a +// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case). +// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`, +// compiler-generated assertion failures are assumed to be a symptom of a program bug, not +// expected behavior. To simplify the coverage graphs and keep instrumented programs as +// small and fast as possible, `Assert` terminators are assumed to always succeed, and +// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not +// get its own coverage counter. +// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive. +// In this test, the final count for the statements after the `if` block in `might_overflow()` +// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending +// on the MIR graph and the structure of the code, this count could have been 3 (which might +// have been valid for the overflowed add `+`, but should have been 4 for the lines before +// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented +// via StatementKind::Counter at the end of the block, but (as in the case in this test), +// a CounterKind::Expression is always evaluated. In this case, the expression was based on +// a `Counter` incremented as part of the evaluation of the `if` expression, which was +// executed, and counted, 4 times, before reaching the overflow add. + +// If the program did not overflow, the coverage for `might_overflow()` would look like this: +// +// 4| |fn might_overflow(to_add: u32) -> u32 { +// 5| 4| if to_add > 5 { +// 6| 0| println!("this will probably overflow"); +// 7| 4| } +// 8| 4| let add_to = u32::MAX - 5; +// 9| 4| println!("does {} + {} overflow?", add_to, to_add); +// 10| 4| let result = to_add + add_to; +// 11| 4| println!("continuing after overflow check"); +// 12| 4| result +// 13| 4|} diff --git a/tests/coverage-map/status-quo/panic_unwind.cov-map b/tests/coverage-map/status-quo/panic_unwind.cov-map new file mode 100644 index 0000000000000..f6089ce55ae29 --- /dev/null +++ b/tests/coverage-map/status-quo/panic_unwind.cov-map @@ -0,0 +1,40 @@ +Function name: panic_unwind::main +Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 8 +- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add) +- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1) +- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 13, 1) to (start + 1, 27) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) + = (c0 + (c1 + (c2 + c3))) +- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) + = ((c0 + (c1 + (c2 + c3))) - c4) +- Code(Counter(1)) at (prev + 0, 27) to (start + 2, 10) +- Code(Expression(4, Sub)) at (prev + 2, 19) to (start + 0, 32) + = (((c0 + (c1 + (c2 + c3))) - c4) - c1) +- Code(Counter(2)) at (prev + 0, 33) to (start + 2, 10) +- Code(Counter(3)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23) + = (c1 + (c2 + c3)) +- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) + +Function name: panic_unwind::might_panic +Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 01, 14, 05, 02, 09, 01, 19, 02, 02, 0c, 03, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20) +- Code(Counter(1)) at (prev + 2, 9) to (start + 1, 25) +- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 3, 2) + = (c0 - c1) + diff --git a/tests/coverage-map/status-quo/panic_unwind.rs b/tests/coverage-map/status-quo/panic_unwind.rs new file mode 100644 index 0000000000000..638d2eb6aaaf8 --- /dev/null +++ b/tests/coverage-map/status-quo/panic_unwind.rs @@ -0,0 +1,31 @@ +#![allow(unused_assignments)] +// failure-status: 101 + +fn might_panic(should_panic: bool) { + if should_panic { + println!("panicking..."); + panic!("panics"); + } else { + println!("Don't Panic"); + } +} + +fn main() -> Result<(), u8> { + let mut countdown = 10; + while countdown > 0 { + if countdown == 1 { + might_panic(true); + } else if countdown < 5 { + might_panic(false); + } + countdown -= 1; + } + Ok(()) +} + +// Notes: +// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and +// `try_error_result.rs`. +// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the +// normal program exit cleanup, including writing out the current values of the coverage +// counters. diff --git a/tests/coverage-map/status-quo/partial_eq.cov-map b/tests/coverage-map/status-quo/partial_eq.cov-map new file mode 100644 index 0000000000000..dd61cd77ab619 --- /dev/null +++ b/tests/coverage-map/status-quo/partial_eq.cov-map @@ -0,0 +1,64 @@ +Function name: ::clone (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 0a, 00, 0f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 4, 10) to (start + 0, 15) + +Function name: ::cmp (unused) +Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 33, 00, 34, 00, 00, 35, 00, 36] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 4, 51) to (start + 0, 52) +- Code(Zero) at (prev + 0, 53) to (start + 0, 54) + +Function name: ::eq (unused) +Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 18, 00, 19, 00, 00, 20, 00, 21] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 4, 24) to (start + 0, 25) +- Code(Zero) at (prev + 0, 32) to (start + 0, 33) + +Function name: ::partial_cmp +Raw bytes (22): 0x[01, 01, 04, 07, 0b, 05, 09, 0f, 15, 0d, 11, 02, 01, 04, 27, 00, 28, 03, 00, 30, 00, 31] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 4 +- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(5) +- expression 3 operands: lhs = Counter(3), rhs = Counter(4) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 4, 39) to (start + 0, 40) +- Code(Expression(0, Add)) at (prev + 0, 48) to (start + 0, 49) + = ((c1 + c2) + ((c3 + c4) + c5)) + +Function name: ::fmt +Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 11, 00, 16] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 4, 17) to (start + 0, 22) + +Function name: ::new +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 05, 06, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 12, 5) to (start + 6, 6) + +Function name: partial_eq::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 05, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 21, 1) to (start + 5, 2) + diff --git a/tests/coverage-map/status-quo/partial_eq.rs b/tests/coverage-map/status-quo/partial_eq.rs new file mode 100644 index 0000000000000..dd8b42c18cea9 --- /dev/null +++ b/tests/coverage-map/status-quo/partial_eq.rs @@ -0,0 +1,46 @@ +// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the +// structure of this test. + +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Version { + major: usize, + minor: usize, + patch: usize, +} + +impl Version { + pub fn new(major: usize, minor: usize, patch: usize) -> Self { + Self { + major, + minor, + patch, + } + } +} + +fn main() { + let version_3_2_1 = Version::new(3, 2, 1); + let version_3_3_0 = Version::new(3, 3, 0); + + println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0); +} + +/* + +This test verifies a bug was fixed that otherwise generated this error: + +thread 'rustc' panicked at 'No counters provided the source_hash for function: + Instance { + def: Item(WithOptConstParam { + did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp), + const_param_did: None + }), + args: [] + }' +The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage +without a code region associated with any `Counter`. Code regions were associated with at least +one expression, which is allowed, but the `function_source_hash` was only passed to the codegen +(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the +`function_source_hash` without a code region, if necessary. + +*/ diff --git a/tests/coverage-map/status-quo/simple_loop.cov-map b/tests/coverage-map/status-quo/simple_loop.cov-map new file mode 100644 index 0000000000000..eb49c2324ccce --- /dev/null +++ b/tests/coverage-map/status-quo/simple_loop.cov-map @@ -0,0 +1,28 @@ +Function name: simple_loop::main +Raw bytes (59): 0x[01, 01, 0a, 01, 05, 27, 09, 05, 02, 23, 09, 27, 09, 05, 02, 1e, 00, 23, 09, 27, 09, 05, 02, 07, 01, 03, 01, 09, 10, 05, 0a, 05, 05, 06, 02, 05, 06, 00, 07, 23, 05, 0d, 02, 0e, 1e, 04, 0d, 00, 12, 09, 02, 0a, 03, 0a, 1b, 06, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 10 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(9, Add), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 3 operands: lhs = Expression(8, Add), rhs = Counter(2) +- expression 4 operands: lhs = Expression(9, Add), rhs = Counter(2) +- expression 5 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(2) +- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(2) +- expression 9 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 7 +- Code(Counter(0)) at (prev + 3, 1) to (start + 9, 16) +- Code(Counter(1)) at (prev + 10, 5) to (start + 5, 6) +- Code(Expression(0, Sub)) at (prev + 5, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(8, Add)) at (prev + 5, 13) to (start + 2, 14) + = ((c1 + (c0 - c1)) + c2) +- Code(Expression(7, Sub)) at (prev + 4, 13) to (start + 0, 18) + = (((c1 + (c0 - c1)) + c2) - c2) +- Code(Counter(2)) at (prev + 2, 10) to (start + 3, 10) +- Code(Expression(6, Add)) at (prev + 6, 1) to (start + 0, 2) + = ((((c1 + (c0 - c1)) + c2) - c2) + Zero) + diff --git a/tests/coverage-map/status-quo/simple_loop.rs b/tests/coverage-map/status-quo/simple_loop.rs new file mode 100644 index 0000000000000..6f7f23475b826 --- /dev/null +++ b/tests/coverage-map/status-quo/simple_loop.rs @@ -0,0 +1,35 @@ +#![allow(unused_assignments)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + + if + is_true + { + countdown + = + 10 + ; + } + + loop + { + if + countdown + == + 0 + { + break + ; + } + countdown + -= + 1 + ; + } +} diff --git a/tests/coverage-map/status-quo/simple_match.cov-map b/tests/coverage-map/status-quo/simple_match.cov-map new file mode 100644 index 0000000000000..d5389f04b2615 --- /dev/null +++ b/tests/coverage-map/status-quo/simple_match.cov-map @@ -0,0 +1,36 @@ +Function name: simple_match::main +Raw bytes (82): 0x[01, 01, 0e, 01, 05, 2f, 33, 05, 02, 09, 0d, 2b, 11, 2f, 33, 05, 02, 09, 0d, 26, 00, 2b, 11, 2f, 33, 05, 02, 09, 0d, 09, 00, 0a, 01, 03, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 2b, 05, 09, 00, 0d, 26, 05, 0d, 00, 16, 09, 02, 0d, 00, 0e, 23, 02, 11, 02, 12, 37, 04, 0d, 07, 0e, 0d, 0a, 0d, 00, 0f, 11, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 14 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(11, Add), rhs = Expression(12, Add) +- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 3 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(10, Add), rhs = Counter(4) +- expression 5 operands: lhs = Expression(11, Add), rhs = Expression(12, Add) +- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 8 operands: lhs = Expression(9, Sub), rhs = Zero +- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(4) +- expression 10 operands: lhs = Expression(11, Add), rhs = Expression(12, Add) +- expression 11 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 12 operands: lhs = Counter(2), rhs = Counter(3) +- expression 13 operands: lhs = Counter(2), rhs = Zero +Number of file 0 mappings: 10 +- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15) +- Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(10, Add)) at (prev + 5, 9) to (start + 0, 13) + = ((c1 + (c0 - c1)) + (c2 + c3)) +- Code(Expression(9, Sub)) at (prev + 5, 13) to (start + 0, 22) + = (((c1 + (c0 - c1)) + (c2 + c3)) - c4) +- Code(Counter(2)) at (prev + 2, 13) to (start + 0, 14) +- Code(Expression(8, Add)) at (prev + 2, 17) to (start + 2, 18) + = ((((c1 + (c0 - c1)) + (c2 + c3)) - c4) + Zero) +- Code(Expression(13, Add)) at (prev + 4, 13) to (start + 7, 14) + = (c2 + Zero) +- Code(Counter(3)) at (prev + 10, 13) to (start + 0, 15) +- Code(Counter(4)) at (prev + 3, 1) to (start + 0, 2) + diff --git a/tests/coverage-map/status-quo/simple_match.rs b/tests/coverage-map/status-quo/simple_match.rs new file mode 100644 index 0000000000000..be99e59a82685 --- /dev/null +++ b/tests/coverage-map/status-quo/simple_match.rs @@ -0,0 +1,43 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 1; + if is_true { + countdown = 0; + } + + for + _ + in + 0..2 + { + let z + ; + match + countdown + { + x + if + x + < + 1 + => + { + z = countdown + ; + let y = countdown + ; + countdown = 10 + ; + } + _ + => + {} + } + } +} diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/status-quo/sort_groups.cov-map new file mode 100644 index 0000000000000..7156a66cf8984 --- /dev/null +++ b/tests/coverage-map/status-quo/sort_groups.cov-map @@ -0,0 +1,68 @@ +Function name: sort_groups::generic_fn::<&str> +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) +- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: sort_groups::generic_fn::<()> +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) +- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: sort_groups::generic_fn:: +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) +- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: sort_groups::main +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 6, 1) to (start + 4, 13) +- Code(Zero) at (prev + 4, 14) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2) + = (c1 + (c0 - c1)) + +Function name: sort_groups::other_fn +Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 23, 1) to (start + 0, 17) + diff --git a/tests/coverage-map/status-quo/sort_groups.rs b/tests/coverage-map/status-quo/sort_groups.rs new file mode 100644 index 0000000000000..f89f9f3ec61fa --- /dev/null +++ b/tests/coverage-map/status-quo/sort_groups.rs @@ -0,0 +1,23 @@ +// compile-flags: --edition=2021 + +// Demonstrate that `sort_subviews.py` can sort instantiation groups into a +// predictable order, while preserving their heterogeneous contents. + +fn main() { + let cond = std::env::args().len() > 1; + generic_fn::<()>(cond); + generic_fn::<&'static str>(!cond); + if false { + generic_fn::(cond); + } + generic_fn::(cond); + other_fn(); +} + +fn generic_fn(cond: bool) { + if cond { + println!("{}", std::any::type_name::()); + } +} + +fn other_fn() {} diff --git a/tests/coverage-map/status-quo/test_harness.cov-map b/tests/coverage-map/status-quo/test_harness.cov-map new file mode 100644 index 0000000000000..b0e955dd142a5 --- /dev/null +++ b/tests/coverage-map/status-quo/test_harness.cov-map @@ -0,0 +1,24 @@ +Function name: test_harness::my_test +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 00, 10] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 10, 1) to (start + 0, 16) + +Function name: test_harness::my_test::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 09, 01, 00, 08] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 9, 1) to (start + 0, 8) + +Function name: test_harness::unused (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 00, 0f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 15) + diff --git a/tests/coverage-map/status-quo/test_harness.rs b/tests/coverage-map/status-quo/test_harness.rs new file mode 100644 index 0000000000000..12a755734c198 --- /dev/null +++ b/tests/coverage-map/status-quo/test_harness.rs @@ -0,0 +1,10 @@ +// Verify that the entry point injected by the test harness doesn't cause +// weird artifacts in the coverage report (e.g. issue #10749). + +// compile-flags: --test + +#[allow(dead_code)] +fn unused() {} + +#[test] +fn my_test() {} diff --git a/tests/coverage-map/status-quo/tight_inf_loop.cov-map b/tests/coverage-map/status-quo/tight_inf_loop.cov-map new file mode 100644 index 0000000000000..76884212c14fa --- /dev/null +++ b/tests/coverage-map/status-quo/tight_inf_loop.cov-map @@ -0,0 +1,12 @@ +Function name: tight_inf_loop::main +Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 1, 1) to (start + 1, 13) +- Code(Zero) at (prev + 2, 9) to (start + 0, 16) +- Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 1, 2) + = (c0 - c1) + diff --git a/tests/coverage-map/status-quo/tight_inf_loop.rs b/tests/coverage-map/status-quo/tight_inf_loop.rs new file mode 100644 index 0000000000000..cef99027aaa4f --- /dev/null +++ b/tests/coverage-map/status-quo/tight_inf_loop.rs @@ -0,0 +1,5 @@ +fn main() { + if false { + loop {} + } +} diff --git a/tests/coverage-map/status-quo/try_error_result.cov-map b/tests/coverage-map/status-quo/try_error_result.cov-map new file mode 100644 index 0000000000000..b52e78d1195ab --- /dev/null +++ b/tests/coverage-map/status-quo/try_error_result.cov-map @@ -0,0 +1,226 @@ +Function name: ::get_thing_2 +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 28, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 1a, 07, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 40, 5) to (start + 1, 24) +- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 20) +- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 26) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6) + = (c1 + (c0 - c1)) + +Function name: ::call +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 33, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 13, 07, 02, 05, 00, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 51, 5) to (start + 1, 24) +- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 20) +- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6) + = (c1 + (c0 - c1)) + +Function name: try_error_result::call +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 14, 05, 02, 09, 00, 10, 02, 02, 09, 00, 0f, 07, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20) +- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 16) +- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: try_error_result::main +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 70, 01, 02, 0c, 05, 03, 05, 00, 06, 02, 02, 05, 00, 0b, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 112, 1) to (start + 2, 12) +- Code(Counter(1)) at (prev + 3, 5) to (start + 0, 6) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 11) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + +Function name: try_error_result::test1 +Raw bytes (77): 0x[01, 01, 09, 01, 07, 05, 09, 03, 0d, 1d, 11, 16, 1d, 03, 0d, 1f, 0d, 11, 23, 15, 19, 0b, 01, 0c, 01, 02, 17, 03, 07, 09, 00, 0e, 16, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 0e, 01, 0d, 00, 2a, 15, 00, 2a, 00, 2b, 12, 04, 0d, 00, 2a, 19, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 1b, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 9 +- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(7), rhs = Counter(4) +- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(7) +- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(3) +- expression 7 operands: lhs = Counter(4), rhs = Expression(8, Add) +- expression 8 operands: lhs = Counter(5), rhs = Counter(6) +Number of file 0 mappings: 11 +- Code(Counter(0)) at (prev + 12, 1) to (start + 2, 23) +- Code(Expression(0, Add)) at (prev + 7, 9) to (start + 0, 14) + = (c0 + (c1 + c2)) +- Code(Expression(5, Sub)) at (prev + 2, 9) to (start + 4, 26) + = ((c0 + (c1 + c2)) - c3) +- Code(Counter(7)) at (prev + 6, 13) to (start + 0, 41) +- Code(Counter(4)) at (prev + 0, 41) to (start + 0, 42) +- Code(Expression(3, Sub)) at (prev + 1, 13) to (start + 0, 42) + = (c7 - c4) +- Code(Counter(5)) at (prev + 0, 42) to (start + 0, 43) +- Code(Expression(4, Sub)) at (prev + 4, 13) to (start + 0, 42) + = (((c0 + (c1 + c2)) - c3) - c7) +- Code(Counter(6)) at (prev + 0, 42) to (start + 0, 43) +- Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) +- Code(Expression(6, Add)) at (prev + 1, 1) to (start + 0, 2) + = ((c4 + (c5 + c6)) + c3) + +Function name: try_error_result::test2 +Raw bytes (373): 0x[01, 01, 41, 01, 07, 05, 09, 03, 0d, 41, 11, 52, 15, 41, 11, 4a, 1d, 4e, 19, 52, 15, 41, 11, 4e, 00, 52, 15, 41, 11, 4e, 19, 52, 15, 41, 11, 46, 00, 4a, 1d, 4e, 19, 52, 15, 41, 11, 6a, 25, 49, 21, 49, 21, 66, 00, 6a, 25, 49, 21, 9a, 01, 2d, 9e, 01, 29, a2, 01, 41, 03, 0d, a2, 01, 41, 03, 0d, 9e, 01, 29, a2, 01, 41, 03, 0d, 96, 01, 00, 9a, 01, 2d, 9e, 01, 29, a2, 01, 41, 03, 0d, ba, 01, 35, 45, 31, 45, 31, b6, 01, 00, ba, 01, 35, 45, 31, d2, 01, 3d, 4d, 39, 4d, 39, ce, 01, 00, d2, 01, 3d, 4d, 39, db, 01, 0d, 11, df, 01, e3, 01, f3, 01, 15, e7, 01, eb, 01, ef, 01, 19, 1d, 21, 25, f7, 01, fb, 01, 29, 2d, ff, 01, 83, 02, 31, 35, 39, 3d, 28, 01, 3c, 01, 03, 17, 03, 08, 09, 00, 0e, a2, 01, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 52, 00, 31, 03, 35, 15, 04, 11, 00, 12, 4e, 02, 11, 04, 12, 46, 05, 11, 00, 14, 2b, 00, 17, 00, 41, 19, 00, 41, 00, 42, 4a, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 43, 01, 0d, 00, 20, 66, 01, 11, 00, 14, 49, 00, 17, 00, 41, 21, 00, 41, 00, 42, 6a, 00, 43, 00, 60, 25, 00, 60, 00, 61, 63, 01, 0d, 00, 20, 96, 01, 04, 11, 00, 14, 9e, 01, 00, 17, 00, 42, 29, 00, 42, 00, 43, 9a, 01, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 93, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, ba, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, b3, 01, 01, 0d, 00, 20, ce, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, d2, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, cb, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, d7, 01, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 65 +- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(16), rhs = Counter(4) +- expression 4 operands: lhs = Expression(20, Sub), rhs = Counter(5) +- expression 5 operands: lhs = Counter(16), rhs = Counter(4) +- expression 6 operands: lhs = Expression(18, Sub), rhs = Counter(7) +- expression 7 operands: lhs = Expression(19, Sub), rhs = Counter(6) +- expression 8 operands: lhs = Expression(20, Sub), rhs = Counter(5) +- expression 9 operands: lhs = Counter(16), rhs = Counter(4) +- expression 10 operands: lhs = Expression(19, Sub), rhs = Zero +- expression 11 operands: lhs = Expression(20, Sub), rhs = Counter(5) +- expression 12 operands: lhs = Counter(16), rhs = Counter(4) +- expression 13 operands: lhs = Expression(19, Sub), rhs = Counter(6) +- expression 14 operands: lhs = Expression(20, Sub), rhs = Counter(5) +- expression 15 operands: lhs = Counter(16), rhs = Counter(4) +- expression 16 operands: lhs = Expression(17, Sub), rhs = Zero +- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(7) +- expression 18 operands: lhs = Expression(19, Sub), rhs = Counter(6) +- expression 19 operands: lhs = Expression(20, Sub), rhs = Counter(5) +- expression 20 operands: lhs = Counter(16), rhs = Counter(4) +- expression 21 operands: lhs = Expression(26, Sub), rhs = Counter(9) +- expression 22 operands: lhs = Counter(18), rhs = Counter(8) +- expression 23 operands: lhs = Counter(18), rhs = Counter(8) +- expression 24 operands: lhs = Expression(25, Sub), rhs = Zero +- expression 25 operands: lhs = Expression(26, Sub), rhs = Counter(9) +- expression 26 operands: lhs = Counter(18), rhs = Counter(8) +- expression 27 operands: lhs = Expression(38, Sub), rhs = Counter(11) +- expression 28 operands: lhs = Expression(39, Sub), rhs = Counter(10) +- expression 29 operands: lhs = Expression(40, Sub), rhs = Counter(16) +- expression 30 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 31 operands: lhs = Expression(40, Sub), rhs = Counter(16) +- expression 32 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 33 operands: lhs = Expression(39, Sub), rhs = Counter(10) +- expression 34 operands: lhs = Expression(40, Sub), rhs = Counter(16) +- expression 35 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 36 operands: lhs = Expression(37, Sub), rhs = Zero +- expression 37 operands: lhs = Expression(38, Sub), rhs = Counter(11) +- expression 38 operands: lhs = Expression(39, Sub), rhs = Counter(10) +- expression 39 operands: lhs = Expression(40, Sub), rhs = Counter(16) +- expression 40 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 41 operands: lhs = Expression(46, Sub), rhs = Counter(13) +- expression 42 operands: lhs = Counter(17), rhs = Counter(12) +- expression 43 operands: lhs = Counter(17), rhs = Counter(12) +- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero +- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(13) +- expression 46 operands: lhs = Counter(17), rhs = Counter(12) +- expression 47 operands: lhs = Expression(52, Sub), rhs = Counter(15) +- expression 48 operands: lhs = Counter(19), rhs = Counter(14) +- expression 49 operands: lhs = Counter(19), rhs = Counter(14) +- expression 50 operands: lhs = Expression(51, Sub), rhs = Zero +- expression 51 operands: lhs = Expression(52, Sub), rhs = Counter(15) +- expression 52 operands: lhs = Counter(19), rhs = Counter(14) +- expression 53 operands: lhs = Expression(54, Add), rhs = Counter(3) +- expression 54 operands: lhs = Counter(4), rhs = Expression(55, Add) +- expression 55 operands: lhs = Expression(56, Add), rhs = Expression(60, Add) +- expression 56 operands: lhs = Counter(5), rhs = Expression(57, Add) +- expression 57 operands: lhs = Expression(58, Add), rhs = Expression(59, Add) +- expression 58 operands: lhs = Counter(6), rhs = Counter(7) +- expression 59 operands: lhs = Counter(8), rhs = Counter(9) +- expression 60 operands: lhs = Expression(61, Add), rhs = Expression(62, Add) +- expression 61 operands: lhs = Counter(10), rhs = Counter(11) +- expression 62 operands: lhs = Expression(63, Add), rhs = Expression(64, Add) +- expression 63 operands: lhs = Counter(12), rhs = Counter(13) +- expression 64 operands: lhs = Counter(14), rhs = Counter(15) +Number of file 0 mappings: 40 +- Code(Counter(0)) at (prev + 60, 1) to (start + 3, 23) +- Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14) + = (c0 + (c1 + c2)) +- Code(Expression(40, Sub)) at (prev + 2, 9) to (start + 4, 26) + = ((c0 + (c1 + c2)) - c3) +- Code(Counter(16)) at (prev + 6, 13) to (start + 0, 47) +- Code(Counter(4)) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(20, Sub)) at (prev + 0, 49) to (start + 3, 53) + = (c16 - c4) +- Code(Counter(5)) at (prev + 4, 17) to (start + 0, 18) +- Code(Expression(19, Sub)) at (prev + 2, 17) to (start + 4, 18) + = ((c16 - c4) - c5) +- Code(Expression(17, Sub)) at (prev + 5, 17) to (start + 0, 20) + = ((((c16 - c4) - c5) - c6) - c7) +- Code(Expression(10, Add)) at (prev + 0, 23) to (start + 0, 65) + = (((c16 - c4) - c5) + Zero) +- Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66) +- Code(Expression(18, Sub)) at (prev + 0, 67) to (start + 0, 95) + = (((c16 - c4) - c5) - c6) +- Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96) +- Code(Expression(16, Add)) at (prev + 1, 13) to (start + 0, 32) + = (((((c16 - c4) - c5) - c6) - c7) + Zero) +- Code(Expression(25, Sub)) at (prev + 1, 17) to (start + 0, 20) + = ((c18 - c8) - c9) +- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 65) +- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66) +- Code(Expression(26, Sub)) at (prev + 0, 67) to (start + 0, 96) + = (c18 - c8) +- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97) +- Code(Expression(24, Add)) at (prev + 1, 13) to (start + 0, 32) + = (((c18 - c8) - c9) + Zero) +- Code(Expression(37, Sub)) at (prev + 4, 17) to (start + 0, 20) + = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) +- Code(Expression(39, Sub)) at (prev + 0, 23) to (start + 0, 66) + = (((c0 + (c1 + c2)) - c3) - c16) +- Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67) +- Code(Expression(38, Sub)) at (prev + 0, 68) to (start + 0, 97) + = ((((c0 + (c1 + c2)) - c3) - c16) - c10) +- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98) +- Code(Expression(36, Add)) at (prev + 1, 13) to (start + 0, 32) + = ((((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) + Zero) +- Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20) + = ((c17 - c12) - c13) +- Code(Counter(17)) at (prev + 0, 23) to (start + 1, 54) +- Code(Counter(12)) at (prev + 1, 54) to (start + 0, 55) +- Code(Expression(46, Sub)) at (prev + 1, 18) to (start + 0, 47) + = (c17 - c12) +- Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(44, Add)) at (prev + 1, 13) to (start + 0, 32) + = (((c17 - c12) - c13) + Zero) +- Code(Expression(51, Sub)) at (prev + 1, 17) to (start + 0, 20) + = ((c19 - c14) - c15) +- Code(Counter(19)) at (prev + 0, 23) to (start + 1, 54) +- Code(Counter(14)) at (prev + 2, 17) to (start + 0, 18) +- Code(Expression(52, Sub)) at (prev + 1, 18) to (start + 0, 47) + = (c19 - c14) +- Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18) +- Code(Expression(50, Add)) at (prev + 2, 13) to (start + 0, 32) + = (((c19 - c14) - c15) + Zero) +- Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) +- Code(Expression(53, Add)) at (prev + 1, 1) to (start + 0, 2) + = ((c4 + ((c5 + ((c6 + c7) + (c8 + c9))) + ((c10 + c11) + ((c12 + c13) + (c14 + c15))))) + c3) + diff --git a/tests/coverage-map/status-quo/try_error_result.rs b/tests/coverage-map/status-quo/try_error_result.rs new file mode 100644 index 0000000000000..557cbf22bfad4 --- /dev/null +++ b/tests/coverage-map/status-quo/try_error_result.rs @@ -0,0 +1,118 @@ +#![allow(unused_assignments)] +// failure-status: 1 + +fn call(return_error: bool) -> Result<(), ()> { + if return_error { + Err(()) + } else { + Ok(()) + } +} + +fn test1() -> Result<(), ()> { + let mut + countdown = 10 + ; + for + _ + in + 0..10 + { + countdown + -= 1 + ; + if + countdown < 5 + { + call(/*return_error=*/ true)?; + call(/*return_error=*/ false)?; + } + else + { + call(/*return_error=*/ false)?; + } + } + Ok(()) +} + +struct Thing1; +impl Thing1 { + fn get_thing_2(&self, return_error: bool) -> Result { + if return_error { + Err(()) + } else { + Ok(Thing2 {}) + } + } +} + +struct Thing2; +impl Thing2 { + fn call(&self, return_error: bool) -> Result { + if return_error { + Err(()) + } else { + Ok(57) + } + } +} + +fn test2() -> Result<(), ()> { + let thing1 = Thing1{}; + let mut + countdown = 10 + ; + for + _ + in + 0..10 + { + countdown + -= 1 + ; + if + countdown < 5 + { + thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail"); + thing1 + . + get_thing_2(/*return_error=*/ false) + ? + . + call(/*return_error=*/ true) + . + expect_err( + "call should fail" + ); + let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?; + assert_eq!(val, 57); + let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?; + assert_eq!(val, 57); + } + else + { + let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?; + assert_eq!(val, 57); + let val = thing1 + .get_thing_2(/*return_error=*/ false)? + .call(/*return_error=*/ false)?; + assert_eq!(val, 57); + let val = thing1 + .get_thing_2(/*return_error=*/ false) + ? + .call(/*return_error=*/ false) + ? + ; + assert_eq!(val, 57); + } + } + Ok(()) +} + +fn main() -> Result<(), ()> { + test1().expect_err("test1 should fail"); + test2() + ? + ; + Ok(()) +} diff --git a/tests/coverage-map/status-quo/unused.cov-map b/tests/coverage-map/status-quo/unused.cov-map new file mode 100644 index 0000000000000..c8b8f195fbd5b --- /dev/null +++ b/tests/coverage-map/status-quo/unused.cov-map @@ -0,0 +1,94 @@ +Function name: unused::foo:: +Raw bytes (42): 0x[01, 01, 04, 01, 0f, 05, 09, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 4 +- expression 0 operands: lhs = Counter(0), rhs = Expression(3, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 3, 1) to (start + 1, 18) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 17) + = (c0 + (c1 + c2)) +- Code(Expression(2, Sub)) at (prev + 1, 9) to (start + 0, 15) + = ((c0 + (c1 + c2)) - c3) +- Code(Counter(2)) at (prev + 0, 19) to (start + 0, 25) +- Code(Expression(3, Add)) at (prev + 1, 9) to (start + 0, 15) + = (c1 + c2) +- Code(Counter(3)) at (prev + 2, 1) to (start + 0, 2) + +Function name: unused::foo:: +Raw bytes (42): 0x[01, 01, 04, 01, 0f, 05, 09, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 4 +- expression 0 operands: lhs = Counter(0), rhs = Expression(3, Add) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 3, 1) to (start + 1, 18) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 17) + = (c0 + (c1 + c2)) +- Code(Expression(2, Sub)) at (prev + 1, 9) to (start + 0, 15) + = ((c0 + (c1 + c2)) - c3) +- Code(Counter(2)) at (prev + 0, 19) to (start + 0, 25) +- Code(Expression(3, Add)) at (prev + 1, 9) to (start + 0, 15) + = (c1 + c2) +- Code(Counter(3)) at (prev + 2, 1) to (start + 0, 2) + +Function name: unused::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 25, 01, 04, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 37, 1) to (start + 4, 2) + +Function name: unused::unused_func (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 01, 13, 01, 01, 0e, 00, 01, 0f, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 19, 1) to (start + 1, 14) +- Code(Zero) at (prev + 1, 15) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + +Function name: unused::unused_func2 (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 01, 19, 01, 01, 0e, 00, 01, 0f, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 25, 1) to (start + 1, 14) +- Code(Zero) at (prev + 1, 15) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + +Function name: unused::unused_func3 (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 01, 1f, 01, 01, 0e, 00, 01, 0f, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 31, 1) to (start + 1, 14) +- Code(Zero) at (prev + 1, 15) to (start + 2, 6) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + +Function name: unused::unused_template_func::<_> (unused) +Raw bytes (34): 0x[01, 01, 00, 06, 01, 0b, 01, 01, 12, 00, 02, 0b, 00, 11, 00, 01, 09, 00, 0f, 00, 00, 13, 00, 19, 00, 01, 09, 00, 0f, 00, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 11, 1) to (start + 1, 18) +- Code(Zero) at (prev + 2, 11) to (start + 0, 17) +- Code(Zero) at (prev + 1, 9) to (start + 0, 15) +- Code(Zero) at (prev + 0, 19) to (start + 0, 25) +- Code(Zero) at (prev + 1, 9) to (start + 0, 15) +- Code(Zero) at (prev + 2, 1) to (start + 0, 2) + diff --git a/tests/coverage-map/status-quo/unused.rs b/tests/coverage-map/status-quo/unused.rs new file mode 100644 index 0000000000000..d985af135470e --- /dev/null +++ b/tests/coverage-map/status-quo/unused.rs @@ -0,0 +1,41 @@ +#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)] + +fn foo(x: T) { + let mut i = 0; + while i < 10 { + i != 0 || i != 0; + i += 1; + } +} + +fn unused_template_func(x: T) { + let mut i = 0; + while i < 10 { + i != 0 || i != 0; + i += 1; + } +} + +fn unused_func(mut a: u32) { + if a != 0 { + a += 1; + } +} + +fn unused_func2(mut a: u32) { + if a != 0 { + a += 1; + } +} + +fn unused_func3(mut a: u32) { + if a != 0 { + a += 1; + } +} + +fn main() -> Result<(), u8> { + foo::(0); + foo::(0.0); + Ok(()) +} diff --git a/tests/coverage-map/status-quo/while.cov-map b/tests/coverage-map/status-quo/while.cov-map new file mode 100644 index 0000000000000..cfd2be96a0db9 --- /dev/null +++ b/tests/coverage-map/status-quo/while.cov-map @@ -0,0 +1,15 @@ +Function name: while::main +Raw bytes (28): 0x[01, 01, 02, 01, 05, 03, 05, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16) +- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 20) + = (c0 + c1) +- Code(Zero) at (prev + 0, 21) to (start + 1, 6) +- Code(Expression(1, Sub)) at (prev + 2, 1) to (start + 0, 2) + = ((c0 + c1) - c1) + diff --git a/tests/coverage-map/status-quo/while.rs b/tests/coverage-map/status-quo/while.rs new file mode 100644 index 0000000000000..781b90b35663e --- /dev/null +++ b/tests/coverage-map/status-quo/while.rs @@ -0,0 +1,5 @@ +fn main() { + let num = 9; + while num >= 10 { + } +} diff --git a/tests/coverage-map/status-quo/while_early_ret.cov-map b/tests/coverage-map/status-quo/while_early_ret.cov-map new file mode 100644 index 0000000000000..369ebe891f127 --- /dev/null +++ b/tests/coverage-map/status-quo/while_early_ret.cov-map @@ -0,0 +1,26 @@ +Function name: while_early_ret::main +Raw bytes (61): 0x[01, 01, 06, 01, 05, 03, 09, 0e, 05, 03, 09, 17, 09, 0d, 11, 09, 01, 04, 01, 01, 1b, 03, 03, 09, 02, 0a, 0e, 05, 0d, 02, 0e, 0a, 06, 15, 02, 16, 0d, 04, 15, 00, 1b, 11, 04, 15, 00, 1b, 05, 03, 0a, 03, 0a, 09, 06, 05, 00, 0b, 13, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 6 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2) +- expression 2 operands: lhs = Expression(3, Sub), rhs = Counter(1) +- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(2) +- expression 5 operands: lhs = Counter(3), rhs = Counter(4) +Number of file 0 mappings: 9 +- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 27) +- Code(Expression(0, Add)) at (prev + 3, 9) to (start + 2, 10) + = (c0 + c1) +- Code(Expression(3, Sub)) at (prev + 5, 13) to (start + 2, 14) + = ((c0 + c1) - c2) +- Code(Expression(2, Sub)) at (prev + 6, 21) to (start + 2, 22) + = (((c0 + c1) - c2) - c1) +- Code(Counter(3)) at (prev + 4, 21) to (start + 0, 27) +- Code(Counter(4)) at (prev + 4, 21) to (start + 0, 27) +- Code(Counter(1)) at (prev + 3, 10) to (start + 3, 10) +- Code(Counter(2)) at (prev + 6, 5) to (start + 0, 11) +- Code(Expression(4, Add)) at (prev + 1, 1) to (start + 0, 2) + = ((c3 + c4) + c2) + diff --git a/tests/coverage-map/status-quo/while_early_ret.rs b/tests/coverage-map/status-quo/while_early_ret.rs new file mode 100644 index 0000000000000..b2f0eee2cc0f4 --- /dev/null +++ b/tests/coverage-map/status-quo/while_early_ret.rs @@ -0,0 +1,42 @@ +#![allow(unused_assignments)] +// failure-status: 1 + +fn main() -> Result<(), u8> { + let mut countdown = 10; + while + countdown + > + 0 + { + if + countdown + < + 5 + { + return + if + countdown + > + 8 + { + Ok(()) + } + else + { + Err(1) + } + ; + } + countdown + -= + 1 + ; + } + Ok(()) +} + +// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and +// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux +// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program +// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical +// to the coverage test for early returns, but this is a limitation that should be fixed. diff --git a/tests/coverage-map/status-quo/yield.cov-map b/tests/coverage-map/status-quo/yield.cov-map new file mode 100644 index 0000000000000..16caa2db343bb --- /dev/null +++ b/tests/coverage-map/status-quo/yield.cov-map @@ -0,0 +1,72 @@ +Function name: yield::main +Raw bytes (118): 0x[01, 01, 11, 01, 00, 05, 09, 0d, 00, 0d, 11, 32, 15, 0d, 11, 11, 15, 2e, 00, 32, 15, 0d, 11, 2e, 00, 32, 15, 0d, 11, 19, 1d, 21, 00, 25, 29, 2d, 00, 10, 01, 07, 01, 01, 16, 03, 06, 0b, 00, 2e, 0d, 01, 27, 00, 29, 07, 01, 0e, 00, 34, 0b, 02, 0b, 00, 2e, 32, 01, 22, 00, 27, 2e, 00, 2c, 00, 2e, 1b, 01, 0e, 00, 34, 1f, 03, 09, 00, 16, 2b, 07, 0b, 00, 2e, 21, 01, 27, 00, 29, 37, 01, 0e, 00, 34, 3b, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 3f, 01, 0e, 00, 34, 43, 02, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 17 +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(3), rhs = Zero +- expression 3 operands: lhs = Counter(3), rhs = Counter(4) +- expression 4 operands: lhs = Expression(12, Sub), rhs = Counter(5) +- expression 5 operands: lhs = Counter(3), rhs = Counter(4) +- expression 6 operands: lhs = Counter(4), rhs = Counter(5) +- expression 7 operands: lhs = Expression(11, Sub), rhs = Zero +- expression 8 operands: lhs = Expression(12, Sub), rhs = Counter(5) +- expression 9 operands: lhs = Counter(3), rhs = Counter(4) +- expression 10 operands: lhs = Expression(11, Sub), rhs = Zero +- expression 11 operands: lhs = Expression(12, Sub), rhs = Counter(5) +- expression 12 operands: lhs = Counter(3), rhs = Counter(4) +- expression 13 operands: lhs = Counter(6), rhs = Counter(7) +- expression 14 operands: lhs = Counter(8), rhs = Zero +- expression 15 operands: lhs = Counter(9), rhs = Counter(10) +- expression 16 operands: lhs = Counter(11), rhs = Zero +Number of file 0 mappings: 16 +- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 22) +- Code(Expression(0, Add)) at (prev + 6, 11) to (start + 0, 46) + = (c0 + Zero) +- Code(Counter(3)) at (prev + 1, 39) to (start + 0, 41) +- Code(Expression(1, Add)) at (prev + 1, 14) to (start + 0, 52) + = (c1 + c2) +- Code(Expression(2, Add)) at (prev + 2, 11) to (start + 0, 46) + = (c3 + Zero) +- Code(Expression(12, Sub)) at (prev + 1, 34) to (start + 0, 39) + = (c3 - c4) +- Code(Expression(11, Sub)) at (prev + 0, 44) to (start + 0, 46) + = ((c3 - c4) - c5) +- Code(Expression(6, Add)) at (prev + 1, 14) to (start + 0, 52) + = (c4 + c5) +- Code(Expression(7, Add)) at (prev + 3, 9) to (start + 0, 22) + = (((c3 - c4) - c5) + Zero) +- Code(Expression(10, Add)) at (prev + 7, 11) to (start + 0, 46) + = (((c3 - c4) - c5) + Zero) +- Code(Counter(8)) at (prev + 1, 39) to (start + 0, 41) +- Code(Expression(13, Add)) at (prev + 1, 14) to (start + 0, 52) + = (c6 + c7) +- Code(Expression(14, Add)) at (prev + 2, 11) to (start + 0, 46) + = (c8 + Zero) +- Code(Counter(11)) at (prev + 1, 39) to (start + 0, 41) +- Code(Expression(15, Add)) at (prev + 1, 14) to (start + 0, 52) + = (c9 + c10) +- Code(Expression(16, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c11 + Zero) + +Function name: yield::main::{closure#0} +Raw bytes (14): 0x[01, 01, 00, 02, 01, 08, 1c, 01, 10, 05, 02, 10, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 8, 28) to (start + 1, 16) +- Code(Counter(1)) at (prev + 2, 16) to (start + 1, 6) + +Function name: yield::main::{closure#1} +Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 1c, 01, 10, 05, 02, 09, 00, 10, 09, 01, 09, 00, 10, 0d, 01, 10, 01, 06] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 22, 28) to (start + 1, 16) +- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 16) +- Code(Counter(2)) at (prev + 1, 9) to (start + 0, 16) +- Code(Counter(3)) at (prev + 1, 16) to (start + 1, 6) + diff --git a/tests/coverage-map/status-quo/yield.rs b/tests/coverage-map/status-quo/yield.rs new file mode 100644 index 0000000000000..361275c921585 --- /dev/null +++ b/tests/coverage-map/status-quo/yield.rs @@ -0,0 +1,37 @@ +#![feature(generators, generator_trait)] +#![allow(unused_assignments)] + +use std::ops::{Generator, GeneratorState}; +use std::pin::Pin; + +fn main() { + let mut generator = || { + yield 1; + return "foo"; + }; + + match Pin::new(&mut generator).resume(()) { + GeneratorState::Yielded(1) => {} + _ => panic!("unexpected value from resume"), + } + match Pin::new(&mut generator).resume(()) { + GeneratorState::Complete("foo") => {} + _ => panic!("unexpected value from resume"), + } + + let mut generator = || { + yield 1; + yield 2; + yield 3; + return "foo"; + }; + + match Pin::new(&mut generator).resume(()) { + GeneratorState::Yielded(1) => {} + _ => panic!("unexpected value from resume"), + } + match Pin::new(&mut generator).resume(()) { + GeneratorState::Yielded(2) => {} + _ => panic!("unexpected value from resume"), + } +} From 98fa0c93ee031277e64eaee11fe9dbfe2147f532 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 5 Sep 2023 11:10:00 +0200 Subject: [PATCH 59/73] unconstrained region vars: do not ICE ICE baby --- .../src/traits/outlives_bounds.rs | 14 ++++------ .../implied-bounds-unconstrained-1.rs | 28 +++++++++++++++++++ .../implied-bounds-unconstrained-2.rs | 20 +++++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs create mode 100644 tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs index 339baf611f3c3..32bbd626d4e49 100644 --- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs @@ -57,16 +57,12 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> { let ty = OpportunisticRegionResolver::new(self).fold_ty(ty); // We do not expect existential variables in implied bounds. - // We may however encounter unconstrained lifetime variables in invalid - // code. See #110161 for context. + // We may however encounter unconstrained lifetime variables + // in very rare cases. + // + // See `ui/implied-bounds/implied-bounds-unconstrained-2.rs` for + // an example. assert!(!ty.has_non_region_infer()); - if ty.has_infer() { - self.tcx.sess.delay_span_bug( - self.tcx.def_span(body_id), - "skipped implied_outlives_bounds due to unconstrained lifetimes", - ); - return vec![]; - } let mut canonical_var_values = OriginalQueryValues::default(); let canonical_ty = diff --git a/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs b/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs new file mode 100644 index 0000000000000..025e5176ff7ee --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs @@ -0,0 +1,28 @@ +// check-pass + +// Regression test for #112832. +pub trait QueryDb { + type Db; +} + +pub struct QueryTable { + db: DB, + storage: Q, +} + +// We normalize `::Db` to `>::SendDb` +// using the where-bound. 'd is an unconstrained region variable which previously +// triggered an assert. +impl QueryTable::Db> where Q: for<'d> AsyncQueryFunction<'d> {} + +pub trait AsyncQueryFunction<'d>: QueryDb>::SendDb> { + type SendDb: 'd; +} + +pub trait QueryStorageOpsAsync +where + Q: for<'d> AsyncQueryFunction<'d>, +{ +} + +fn main() {} diff --git a/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs b/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs new file mode 100644 index 0000000000000..976054facee5e --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs @@ -0,0 +1,20 @@ +// check-pass + +// Another minimized regression test for #112832. +trait Trait { + type Assoc; +} + +trait Sub<'a>: Trait>::SubAssoc> { + type SubAssoc; +} + +// By using the where-clause we normalize `::Assoc` to +// `>::SubAssoc` where `'a` is an unconstrained region +// variable. +fn foo(x: ::Assoc) +where + for<'a> T: Sub<'a>, +{} + +fn main() {} From bdfa08a3459870e7abdd5442ac8e9d20e64cc288 Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Tue, 5 Sep 2023 10:04:25 +0000 Subject: [PATCH 60/73] llvm-wrapper: adapt for LLVM API change No functional changes intended. Adapts the wrapper for https://github.com/llvm/llvm-project/commit/bbe8cd13335300958b04db5318c31ff52714f96f. Found by our experimental rust + llvm @ HEAD CI: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/22055#018a6495-8dd9-41df-9381-5e7b0009ce0a/274-575 --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 6af5c24c458a6..8f8f1d8c04feb 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1202,7 +1202,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, Ret->ModuleMap[module->identifier] = mem_buffer; +#if LLVM_VERSION_GE(18, 0) + if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index)) { +#else if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) { +#endif LLVMRustSetLastError(toString(std::move(Err)).c_str()); return nullptr; } From d454cab405ee018833d63fcf149b5f215cb0213c Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 4 Sep 2023 23:04:38 +0300 Subject: [PATCH 61/73] support `{disable,enable}-patch-binaries-for-nix` in configure.py Signed-off-by: onur-ozkan --- src/bootstrap/configure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 15e8c1eb9f8d9..f469dbea6dbee 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -58,6 +58,7 @@ def v(*args): o("missing-tools", "dist.missing-tools", "allow failures when building tools") o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++") o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard") +o("patch-binaries-for-nix", "build.patch-binaries-for-nix", "whether patch binaries for usage with Nix toolchains") v("llvm-cflags", "llvm.cflags", "build LLVM with these extra compiler flags") v("llvm-cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags") From 4684ffaf2ac5c7bb1467baf4e7f01469488c8ef2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 5 Sep 2023 17:20:31 +0200 Subject: [PATCH 62/73] if -> when --- library/core/src/intrinsics.rs | 4 ++-- library/core/src/ptr/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index f7469008d7c00..639e33762cf6b 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2706,12 +2706,12 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us /// Behavior is undefined if any of the following conditions are violated: /// /// * `src` must be [valid] for reads of `count * size_of::()` bytes, and must remain valid even -/// if `dst` is written for `count * size_of::()` bytes. (This means if the memory ranges +/// when `dst` is written for `count * size_of::()` bytes. (This means if the memory ranges /// overlap, the two pointers must not be subject to aliasing restrictions relative to each /// other.) /// /// * `dst` must be [valid] for writes of `count * size_of::()` bytes, and must remain valid even -/// if `src` is read for `count * size_of::()` bytes. +/// when `src` is read for `count * size_of::()` bytes. /// /// * Both `src` and `dst` must be properly aligned. /// diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 69d775075f369..452800516f713 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -795,7 +795,7 @@ pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { /// /// Behavior is undefined if any of the following conditions are violated: /// -/// * Both `x` and `y` must be [valid] for both reads and writes. They must remain valid even if the +/// * Both `x` and `y` must be [valid] for both reads and writes. They must remain valid even when the /// other pointer is written. (This means if the memory ranges overlap, the two pointers must not /// be subject to aliasing restrictions relative to each other.) /// From 2db01be5844ded1139eb4fb5f1434d0090b6ba38 Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Wed, 30 Aug 2023 16:50:07 -0700 Subject: [PATCH 63/73] Adjust StableMIR interface to return and not crash Invoking StableMir::run() on a crate that has any compilation error was crashing the entire process. Instead, return a `CompilerError` so the user knows compilation did not succeed. I believe ICE will also be converted to `CompilerError`. I'm also adding a return value to the callback, because I think it will be handy for users (at least it was for my current task of implementing a tool to validate stable-mir). However, if people disagree, I can remove that. --- compiler/rustc_smir/src/rustc_internal/mod.rs | 35 +++++++++++++------ compiler/rustc_smir/src/rustc_smir/mod.rs | 9 ++++- compiler/rustc_smir/src/stable_mir/mod.rs | 4 +++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 2e219e17a5f6e..4496a58327eba 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -7,6 +7,7 @@ use std::fmt::Debug; use std::ops::Index; use crate::rustc_internal; +use crate::stable_mir::CompilerError; use crate::{ rustc_smir::Tables, stable_mir::{self, with}, @@ -17,6 +18,7 @@ use rustc_middle::mir::interpret::AllocId; use rustc_middle::ty::TyCtxt; use rustc_session::EarlyErrorHandler; pub use rustc_span::def_id::{CrateNum, DefId}; +use rustc_span::ErrorGuaranteed; fn with_tables(mut f: impl FnMut(&mut Tables<'_>) -> R) -> R { let mut ret = None; @@ -189,27 +191,38 @@ pub(crate) fn opaque(value: &T) -> Opaque { Opaque(format!("{value:?}")) } -pub struct StableMir { +pub struct StableMir +where + T: Send, +{ args: Vec, - callback: fn(TyCtxt<'_>), + callback: fn(TyCtxt<'_>) -> T, + result: Option, } -impl StableMir { +impl StableMir +where + T: Send, +{ /// Creates a new `StableMir` instance, with given test_function and arguments. - pub fn new(args: Vec, callback: fn(TyCtxt<'_>)) -> Self { - StableMir { args, callback } + pub fn new(args: Vec, callback: fn(TyCtxt<'_>) -> T) -> Self { + StableMir { args, callback, result: None } } /// Runs the compiler against given target and tests it with `test_function` - pub fn run(&mut self) { + pub fn run(mut self) -> Result { rustc_driver::catch_fatal_errors(|| { - RunCompiler::new(&self.args.clone(), self).run().unwrap(); + RunCompiler::new(&self.args.clone(), &mut self).run().unwrap(); }) - .unwrap(); + .map_err(|e| >::into(e))?; + Ok(self.result.unwrap()) } } -impl Callbacks for StableMir { +impl Callbacks for StableMir +where + T: Send, +{ /// Called after analysis. Return value instructs the compiler whether to /// continue the compilation afterwards (defaults to `Compilation::Continue`) fn after_analysis<'tcx>( @@ -219,7 +232,9 @@ impl Callbacks for StableMir { queries: &'tcx Queries<'tcx>, ) -> Compilation { queries.global_ctxt().unwrap().enter(|tcx| { - rustc_internal::run(tcx, || (self.callback)(tcx)); + rustc_internal::run(tcx, || { + self.result = Some((self.callback)(tcx)); + }); }); // No need to keep going. Compilation::Stop diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index b4c150c591c48..827b51e8a3658 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -10,12 +10,13 @@ use crate::rustc_internal::{self, opaque}; use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx}; use crate::stable_mir::ty::{FloatTy, GenericParamDef, IntTy, Movability, RigidTy, TyKind, UintTy}; -use crate::stable_mir::{self, Context}; +use crate::stable_mir::{self, CompilerError, Context}; use rustc_hir as hir; use rustc_middle::mir::interpret::{alloc_range, AllocId}; use rustc_middle::mir::{self, ConstantKind}; use rustc_middle::ty::{self, Ty, TyCtxt, Variance}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use rustc_span::ErrorGuaranteed; use rustc_target::abi::FieldIdx; use tracing::debug; @@ -1452,3 +1453,9 @@ impl<'tcx> Stable<'tcx> for rustc_span::Span { opaque(self) } } + +impl From for CompilerError { + fn from(_error: ErrorGuaranteed) -> Self { + CompilerError + } +} diff --git a/compiler/rustc_smir/src/stable_mir/mod.rs b/compiler/rustc_smir/src/stable_mir/mod.rs index bfc2c15a42eb0..281d5aafb4cc3 100644 --- a/compiler/rustc_smir/src/stable_mir/mod.rs +++ b/compiler/rustc_smir/src/stable_mir/mod.rs @@ -56,6 +56,10 @@ pub type TraitDecls = Vec; /// A list of impl trait decls. pub type ImplTraitDecls = Vec; +/// An error type used to represent an error that has already been reported by the compiler. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct CompilerError; + /// Holds information about a crate. #[derive(Clone, PartialEq, Eq, Debug)] pub struct Crate { From 3b01f65aa5cd19fe02b1bfd4e7e60390d8ef83fc Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Thu, 31 Aug 2023 16:53:28 -0700 Subject: [PATCH 64/73] Diferentiate between ICE and compilation error --- compiler/rustc_smir/src/rustc_internal/mod.rs | 14 ++++++++------ compiler/rustc_smir/src/rustc_smir/mod.rs | 2 +- compiler/rustc_smir/src/stable_mir/mod.rs | 7 ++++++- tests/ui-fulldeps/stable-mir/crate-info.rs | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 4496a58327eba..1c5a0924f4a95 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -18,7 +18,6 @@ use rustc_middle::mir::interpret::AllocId; use rustc_middle::ty::TyCtxt; use rustc_session::EarlyErrorHandler; pub use rustc_span::def_id::{CrateNum, DefId}; -use rustc_span::ErrorGuaranteed; fn with_tables(mut f: impl FnMut(&mut Tables<'_>) -> R) -> R { let mut ret = None; @@ -211,11 +210,14 @@ where /// Runs the compiler against given target and tests it with `test_function` pub fn run(mut self) -> Result { - rustc_driver::catch_fatal_errors(|| { - RunCompiler::new(&self.args.clone(), &mut self).run().unwrap(); - }) - .map_err(|e| >::into(e))?; - Ok(self.result.unwrap()) + let compiler_result = rustc_driver::catch_fatal_errors(|| { + RunCompiler::new(&self.args.clone(), &mut self).run() + }); + match compiler_result { + Ok(Ok(())) => Ok(self.result.unwrap()), + Ok(Err(_)) => Err(CompilerError::CompilationFailed), + Err(_) => Err(CompilerError::ICE), + } } } diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 827b51e8a3658..3909c3d85ebfa 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -1456,6 +1456,6 @@ impl<'tcx> Stable<'tcx> for rustc_span::Span { impl From for CompilerError { fn from(_error: ErrorGuaranteed) -> Self { - CompilerError + CompilerError::CompilationFailed } } diff --git a/compiler/rustc_smir/src/stable_mir/mod.rs b/compiler/rustc_smir/src/stable_mir/mod.rs index 281d5aafb4cc3..bdbbab68e396a 100644 --- a/compiler/rustc_smir/src/stable_mir/mod.rs +++ b/compiler/rustc_smir/src/stable_mir/mod.rs @@ -58,7 +58,12 @@ pub type ImplTraitDecls = Vec; /// An error type used to represent an error that has already been reported by the compiler. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct CompilerError; +pub enum CompilerError { + /// Internal compiler error (I.e.: Compiler crashed). + ICE, + /// Compilation failed. + CompilationFailed, +} /// Holds information about a crate. #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 00dce3e004e63..5439a884637e5 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -136,7 +136,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_internal::StableMir::new(args, test_stable_mir).run(); + rustc_internal::StableMir::new(args, test_stable_mir).run().unwrap(); } fn generate_input(path: &str) -> std::io::Result<()> { From 1a8a5d0a296f24b5184a3997e6dbedb2d31c079a Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Thu, 31 Aug 2023 20:40:48 -0700 Subject: [PATCH 65/73] SMIR: Allow users to pick if compilation continues Currently we stop compilation, but some users might want to keep going. This is needed for us to test against rustc tests. Other tools, such as Kani, also implements parts of their logic as a backend so it is important for compilation to continue. --- compiler/rustc_smir/src/rustc_internal/mod.rs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 1c5a0924f4a95..26127c5eb854b 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -196,6 +196,7 @@ where { args: Vec, callback: fn(TyCtxt<'_>) -> T, + after_analysis: Compilation, result: Option, } @@ -205,16 +206,27 @@ where { /// Creates a new `StableMir` instance, with given test_function and arguments. pub fn new(args: Vec, callback: fn(TyCtxt<'_>) -> T) -> Self { - StableMir { args, callback, result: None } + StableMir { args, callback, result: None, after_analysis: Compilation::Stop } + } + + /// Configure object to stop compilation after callback is called. + pub fn stop_compilation(&mut self) -> &mut Self { + self.after_analysis = Compilation::Stop; + self + } + + /// Configure object to continue compilation after callback is called. + pub fn continue_compilation(&mut self) -> &mut Self { + self.after_analysis = Compilation::Continue; + self } /// Runs the compiler against given target and tests it with `test_function` - pub fn run(mut self) -> Result { - let compiler_result = rustc_driver::catch_fatal_errors(|| { - RunCompiler::new(&self.args.clone(), &mut self).run() - }); + pub fn run(&mut self) -> Result { + let compiler_result = + rustc_driver::catch_fatal_errors(|| RunCompiler::new(&self.args.clone(), self).run()); match compiler_result { - Ok(Ok(())) => Ok(self.result.unwrap()), + Ok(Ok(())) => Ok(self.result.take().unwrap()), Ok(Err(_)) => Err(CompilerError::CompilationFailed), Err(_) => Err(CompilerError::ICE), } @@ -238,7 +250,7 @@ where self.result = Some((self.callback)(tcx)); }); }); - // No need to keep going. - Compilation::Stop + // Let users define if they want to stop compilation. + self.after_analysis } } From d10d8290ac50b5ea8c0ca72bf216cf414b2ada24 Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Fri, 1 Sep 2023 21:12:46 -0700 Subject: [PATCH 66/73] Add tests and use ControlFlow --- compiler/rustc_smir/src/rustc_internal/mod.rs | 59 +++++++------- compiler/rustc_smir/src/rustc_smir/mod.rs | 2 +- compiler/rustc_smir/src/stable_mir/mod.rs | 7 +- .../stable-mir/compilation-result.rs | 77 +++++++++++++++++++ tests/ui-fulldeps/stable-mir/crate-info.rs | 5 +- 5 files changed, 115 insertions(+), 35 deletions(-) create mode 100644 tests/ui-fulldeps/stable-mir/compilation-result.rs diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 26127c5eb854b..73b8e060dd830 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -4,7 +4,7 @@ //! until stable MIR is complete. use std::fmt::Debug; -use std::ops::Index; +use std::ops::{ControlFlow, Index}; use crate::rustc_internal; use crate::stable_mir::CompilerError; @@ -190,52 +190,44 @@ pub(crate) fn opaque(value: &T) -> Opaque { Opaque(format!("{value:?}")) } -pub struct StableMir +pub struct StableMir where - T: Send, + B: Send, + C: Send, { args: Vec, - callback: fn(TyCtxt<'_>) -> T, - after_analysis: Compilation, - result: Option, + callback: fn(TyCtxt<'_>) -> ControlFlow, + result: Option>, } -impl StableMir +impl StableMir where - T: Send, + B: Send, + C: Send, { /// Creates a new `StableMir` instance, with given test_function and arguments. - pub fn new(args: Vec, callback: fn(TyCtxt<'_>) -> T) -> Self { - StableMir { args, callback, result: None, after_analysis: Compilation::Stop } - } - - /// Configure object to stop compilation after callback is called. - pub fn stop_compilation(&mut self) -> &mut Self { - self.after_analysis = Compilation::Stop; - self - } - - /// Configure object to continue compilation after callback is called. - pub fn continue_compilation(&mut self) -> &mut Self { - self.after_analysis = Compilation::Continue; - self + pub fn new(args: Vec, callback: fn(TyCtxt<'_>) -> ControlFlow) -> Self { + StableMir { args, callback, result: None } } /// Runs the compiler against given target and tests it with `test_function` - pub fn run(&mut self) -> Result { + pub fn run(&mut self) -> Result> { let compiler_result = rustc_driver::catch_fatal_errors(|| RunCompiler::new(&self.args.clone(), self).run()); - match compiler_result { - Ok(Ok(())) => Ok(self.result.take().unwrap()), - Ok(Err(_)) => Err(CompilerError::CompilationFailed), - Err(_) => Err(CompilerError::ICE), + match (compiler_result, self.result.take()) { + (Ok(Ok(())), Some(ControlFlow::Continue(value))) => Ok(value), + (Ok(Ok(())), Some(ControlFlow::Break(value))) => Err(CompilerError::Interrupted(value)), + (Ok(Ok(_)), None) => Err(CompilerError::Skipped), + (Ok(Err(_)), _) => Err(CompilerError::CompilationFailed), + (Err(_), _) => Err(CompilerError::ICE), } } } -impl Callbacks for StableMir +impl Callbacks for StableMir where - T: Send, + B: Send, + C: Send, { /// Called after analysis. Return value instructs the compiler whether to /// continue the compilation afterwards (defaults to `Compilation::Continue`) @@ -249,8 +241,11 @@ where rustc_internal::run(tcx, || { self.result = Some((self.callback)(tcx)); }); - }); - // Let users define if they want to stop compilation. - self.after_analysis + if self.result.as_ref().is_some_and(|val| val.is_continue()) { + Compilation::Continue + } else { + Compilation::Stop + } + }) } } diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 3909c3d85ebfa..52ba4bd4e579d 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -1454,7 +1454,7 @@ impl<'tcx> Stable<'tcx> for rustc_span::Span { } } -impl From for CompilerError { +impl From for CompilerError { fn from(_error: ErrorGuaranteed) -> Self { CompilerError::CompilationFailed } diff --git a/compiler/rustc_smir/src/stable_mir/mod.rs b/compiler/rustc_smir/src/stable_mir/mod.rs index bdbbab68e396a..f9eafd9de7ad8 100644 --- a/compiler/rustc_smir/src/stable_mir/mod.rs +++ b/compiler/rustc_smir/src/stable_mir/mod.rs @@ -58,11 +58,16 @@ pub type ImplTraitDecls = Vec; /// An error type used to represent an error that has already been reported by the compiler. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum CompilerError { +pub enum CompilerError { /// Internal compiler error (I.e.: Compiler crashed). ICE, /// Compilation failed. CompilationFailed, + /// Compilation was interrupted. + Interrupted(T), + /// Compilation skipped. This happens when users invoke rustc to retrieve information such as + /// --version. + Skipped, } /// Holds information about a crate. diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs new file mode 100644 index 0000000000000..23a9e2a064cb6 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -0,0 +1,77 @@ +// run-pass +// Test StableMIR behavior when different results are given + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] + +extern crate rustc_middle; +extern crate rustc_smir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::{rustc_internal, stable_mir}; +use std::io::Write; +use std::ops::ControlFlow; + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "input_compilation_result_test.rs"; + generate_input(&path).unwrap(); + let args = vec!["rustc".to_string(), path.to_string()]; + test_continue(args.clone()); + test_break(args.clone()); + test_failed(args.clone()); + test_skipped(args); +} + +fn test_continue(args: Vec) { + let continue_fn = |_: TyCtxt| ControlFlow::Continue::<(), bool>(true); + let result = rustc_internal::StableMir::new(args, continue_fn).run(); + assert_eq!(result, Ok(true)); +} + +fn test_break(args: Vec) { + let continue_fn = |_: TyCtxt| ControlFlow::Break::(false); + let result = rustc_internal::StableMir::new(args, continue_fn).run(); + assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false))); +} + +fn test_skipped(mut args: Vec) { + args.push("--version".to_string()); + let unreach_fn = |_: TyCtxt| -> ControlFlow<()> { unreachable!() }; + let result = rustc_internal::StableMir::new(args, unreach_fn).run(); + assert_eq!(result, Err(stable_mir::CompilerError::Skipped)); +} + +fn test_failed(mut args: Vec) { + args.push("--cfg=broken".to_string()); + let unreach_fn = |_: TyCtxt| -> ControlFlow<()> { unreachable!() }; + let result = rustc_internal::StableMir::new(args, unreach_fn).run(); + assert_eq!(result, Err(stable_mir::CompilerError::CompilationFailed)); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + // This should trigger a compilation failure when enabled. + #[cfg(broken)] + mod broken_mod {{ + fn call_invalid() {{ + invalid_fn(); + }} + }} + + fn main() {{}} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 5439a884637e5..182f97373ea44 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -18,11 +18,12 @@ use rustc_middle::ty::TyCtxt; use rustc_smir::{rustc_internal, stable_mir}; use std::assert_matches::assert_matches; use std::io::Write; +use std::ops::ControlFlow; const CRATE_NAME: &str = "input"; /// This function uses the Stable MIR APIs to get information about the test crate. -fn test_stable_mir(tcx: TyCtxt<'_>) { +fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { // Get the local crate using stable_mir API. let local = stable_mir::local_crate(); assert_eq!(&local.name, CRATE_NAME); @@ -108,6 +109,8 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { stable_mir::mir::Terminator::Assert { .. } => {} other => panic!("{other:?}"), } + + ControlFlow::Continue(()) } // Use internal API to find a function in a crate. From fba61a8233e9f7bf76942298492b3667bfd3c5ae Mon Sep 17 00:00:00 2001 From: David Koloski Date: Tue, 5 Sep 2023 18:33:11 +0000 Subject: [PATCH 67/73] Update LLVM submodule to 17.0.0-rc4 --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 50eecd007f6bf..0537f6354cffe 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 50eecd007f6bf135ad60493bc62102739038d59a +Subproject commit 0537f6354cffe546cbf47f6dc9c7f82e49e86cfb From 13f17e1a936e781aaa639f33a58fc9c0b2866671 Mon Sep 17 00:00:00 2001 From: ezekiel Date: Tue, 5 Sep 2023 22:29:07 +0200 Subject: [PATCH 68/73] replace doc occurrences of ItemLikeVisitor ItemLikeVisitor was removed, and the visit strategy was moved to `rustc_hir::intravisit` --- compiler/rustc_hir/src/intravisit.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 172f557f8e2ae..d9195a374c24a 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -152,7 +152,7 @@ pub mod nested_filter { /// visit fn bodies for fns that it encounters, and closure bodies, but /// skip over nested item-like things. /// - /// See the comments on `ItemLikeVisitor` for more details on the overall + /// See the comments at [`rustc_hir::intravisit`] for more details on the overall /// visit strategy. pub trait NestedFilter<'hir> { type Map: Map<'hir>; @@ -229,8 +229,8 @@ pub trait Visitor<'v>: Sized { /// `Self::NestedFilter` is `nested_filter::None`, this method does /// nothing. **You probably don't want to override this method** -- /// instead, override [`Self::NestedFilter`] or use the "shallow" or - /// "deep" visit patterns described on - /// `itemlikevisit::ItemLikeVisitor`. The only reason to override + /// "deep" visit patterns described at + /// [`rustc_hir::intravisit`]. The only reason to override /// this method is if you want a nested pattern but cannot supply a /// [`Map`]; see `nested_visit_map` for advice. fn visit_nested_item(&mut self, id: ItemId) { From 00010eda8b2828da967a562c093c6723889203ae Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 3 Sep 2023 10:58:13 +0800 Subject: [PATCH 69/73] Fix error report for size overflow from transmute --- .../src/traits/error_reporting/mod.rs | 10 ++++++ compiler/rustc_transmute/src/layout/tree.rs | 3 ++ compiler/rustc_transmute/src/lib.rs | 4 +++ .../src/maybe_transmutable/mod.rs | 2 ++ .../transmute/issue-115402-overflow-size.rs | 27 +++++++++++++++ .../issue-115402-overflow-size.stderr | 33 +++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 tests/ui/transmute/issue-115402-overflow-size.rs create mode 100644 tests/ui/transmute/issue-115402-overflow-size.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 457d5420ca3c9..746a38f956ab3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2920,6 +2920,16 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { rustc_transmute::Reason::DstIsTooBig => { format!("The size of `{src}` is smaller than the size of `{dst}`") } + rustc_transmute::Reason::SrcSizeOverflow => { + format!( + "values of the type `{src}` are too big for the current architecture" + ) + } + rustc_transmute::Reason::DstSizeOverflow => { + format!( + "values of the type `{dst}` are too big for the current architecture" + ) + } rustc_transmute::Reason::DstHasStricterAlignment { src_min_align, dst_min_align, diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index e8ddb0a43962f..49f24f66b24ad 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -189,6 +189,8 @@ pub(crate) mod rustc { Unspecified, /// This error will be surfaced elsewhere by rustc, so don't surface it. UnknownLayout, + /// Overflow size + SizeOverflow, TypeError(ErrorGuaranteed), } @@ -196,6 +198,7 @@ pub(crate) mod rustc { fn from(err: &LayoutError<'tcx>) -> Self { match err { LayoutError::Unknown(..) | LayoutError::ReferencesError(..) => Self::UnknownLayout, + LayoutError::SizeOverflow(..) => Self::SizeOverflow, err => unimplemented!("{:?}", err), } } diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 05ad4a4a12ab3..af2ad54748025 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -64,6 +64,10 @@ pub enum Reason { SrcLayoutUnknown, /// The layout of dst is unknown DstLayoutUnknown, + /// The size of src is overflow + SrcSizeOverflow, + /// The size of dst is overflow + DstSizeOverflow, } #[cfg(feature = "rustc")] diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index b223a90f7514b..c0141f1f84149 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -85,6 +85,8 @@ mod rustc { (_, Err(Err::UnknownLayout)) => Answer::No(Reason::DstLayoutUnknown), (Err(Err::Unspecified), _) => Answer::No(Reason::SrcIsUnspecified), (_, Err(Err::Unspecified)) => Answer::No(Reason::DstIsUnspecified), + (Err(Err::SizeOverflow), _) => Answer::No(Reason::SrcSizeOverflow), + (_, Err(Err::SizeOverflow)) => Answer::No(Reason::DstSizeOverflow), (Ok(src), Ok(dst)) => { MaybeTransmutableQuery { src, dst, scope, assume, context }.answer() } diff --git a/tests/ui/transmute/issue-115402-overflow-size.rs b/tests/ui/transmute/issue-115402-overflow-size.rs new file mode 100644 index 0000000000000..91168041ed693 --- /dev/null +++ b/tests/ui/transmute/issue-115402-overflow-size.rs @@ -0,0 +1,27 @@ +#![crate_type = "lib"] +#![feature(transmutability)] +mod assert { + use std::mem::BikeshedIntrinsicFrom; + struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom, + { + } +} + +fn main() { + pub union Uninit { + a: [u8; usize::MAX], + } + + #[repr(C)] + struct ExplicitlyPadded(Uninit); + + assert::is_maybe_transmutable::<(), ExplicitlyPadded>(); + //~^ ERROR `()` cannot be safely transmuted into `ExplicitlyPadded` + + assert::is_maybe_transmutable::(); + //~^ ERROR `ExplicitlyPadded` cannot be safely transmuted into `()` +} diff --git a/tests/ui/transmute/issue-115402-overflow-size.stderr b/tests/ui/transmute/issue-115402-overflow-size.stderr new file mode 100644 index 0000000000000..08d180f6427ea --- /dev/null +++ b/tests/ui/transmute/issue-115402-overflow-size.stderr @@ -0,0 +1,33 @@ +error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded` in the defining scope of `assert::Context` + --> $DIR/issue-115402-overflow-size.rs:22:41 + | +LL | assert::is_maybe_transmutable::<(), ExplicitlyPadded>(); + | ^^^^^^^^^^^^^^^^ values of the type `ExplicitlyPadded` are too big for the current architecture + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/issue-115402-overflow-size.rs:9:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` + +error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` in the defining scope of `assert::Context` + --> $DIR/issue-115402-overflow-size.rs:25:55 + | +LL | assert::is_maybe_transmutable::(); + | ^^ values of the type `ExplicitlyPadded` are too big for the current architecture + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/issue-115402-overflow-size.rs:9:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. From 83ae1e6d35c6f7d4ecabc190c5d79f669ef4b2bd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Sep 2023 08:04:20 +0200 Subject: [PATCH 70/73] give josh more time to start --- src/tools/miri/miri-script/src/commands.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index b7031d9a3ee22..e7a5b55919521 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -102,8 +102,8 @@ impl Command { cmd.stdout(process::Stdio::null()); cmd.stderr(process::Stdio::null()); let josh = cmd.spawn().context("failed to start josh-proxy, make sure it is installed")?; - // Give it some time so hopefully the port is open. (10ms was not enough.) - thread::sleep(time::Duration::from_millis(100)); + // Give it some time so hopefully the port is open. (100ms was not enough.) + thread::sleep(time::Duration::from_millis(200)); // Create a wrapper that stops it on drop. struct Josh(process::Child); From 2416eae1098d2963a2c5b05612324083e54b0dd2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Sep 2023 08:04:24 +0200 Subject: [PATCH 71/73] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index b40e7f83f4f4a..3f8d9f5a7242c 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -a989e25f1b87949a886eab3da10324d14189fe95 +aeddd2ddfd35bb385dd36476fab326f40d57a131 From fe614712dded0a861fbcbf654663128318eb6dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 4 Sep 2023 23:12:30 +0200 Subject: [PATCH 72/73] Extract parallel operations in `rustc_data_structures::sync` into a new `parallel` submodule --- compiler/rustc_data_structures/src/sync.rs | 176 +--------------- .../src/sync/parallel.rs | 188 ++++++++++++++++++ 2 files changed, 193 insertions(+), 171 deletions(-) create mode 100644 compiler/rustc_data_structures/src/sync/parallel.rs diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index e82b0f6d49673..a12889c5e2b16 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -41,12 +41,9 @@ //! [^2] `MTLockRef` is a typedef. pub use crate::marker::*; -use parking_lot::Mutex; -use std::any::Any; use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; use std::ops::{Deref, DerefMut}; -use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; mod lock; pub use lock::{Lock, LockGuard}; @@ -54,6 +51,11 @@ pub use lock::{Lock, LockGuard}; mod worker_local; pub use worker_local::{Registry, WorkerLocal}; +mod parallel; +#[cfg(parallel_compiler)] +pub use parallel::scope; +pub use parallel::{join, par_for_each_in, par_map, parallel_guard}; + pub use std::sync::atomic::Ordering; pub use std::sync::atomic::Ordering::SeqCst; @@ -105,37 +107,6 @@ mod mode { pub use mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode}; -/// A guard used to hold panics that occur during a parallel section to later by unwound. -/// This is used for the parallel compiler to prevent fatal errors from non-deterministically -/// hiding errors by ensuring that everything in the section has completed executing before -/// continuing with unwinding. It's also used for the non-parallel code to ensure error message -/// output match the parallel compiler for testing purposes. -pub struct ParallelGuard { - panic: Mutex>>, -} - -impl ParallelGuard { - pub fn run(&self, f: impl FnOnce() -> R) -> Option { - catch_unwind(AssertUnwindSafe(f)) - .map_err(|err| { - *self.panic.lock() = Some(err); - }) - .ok() - } -} - -/// This gives access to a fresh parallel guard in the closure and will unwind any panics -/// caught in it after the closure returns. -#[inline] -pub fn parallel_guard(f: impl FnOnce(&ParallelGuard) -> R) -> R { - let guard = ParallelGuard { panic: Mutex::new(None) }; - let ret = f(&guard); - if let Some(panic) = guard.panic.into_inner() { - resume_unwind(panic); - } - ret -} - cfg_if! { if #[cfg(not(parallel_compiler))] { use std::ops::Add; @@ -227,44 +198,6 @@ cfg_if! { pub type AtomicU32 = Atomic; pub type AtomicU64 = Atomic; - pub fn join(oper_a: A, oper_b: B) -> (RA, RB) - where A: FnOnce() -> RA, - B: FnOnce() -> RB - { - let (a, b) = parallel_guard(|guard| { - let a = guard.run(oper_a); - let b = guard.run(oper_b); - (a, b) - }); - (a.unwrap(), b.unwrap()) - } - - #[macro_export] - macro_rules! parallel { - ($($blocks:block),*) => {{ - $crate::sync::parallel_guard(|guard| { - $(guard.run(|| $blocks);)* - }); - }} - } - - pub fn par_for_each_in(t: T, mut for_each: impl FnMut(T::Item) + Sync + Send) { - parallel_guard(|guard| { - t.into_iter().for_each(|i| { - guard.run(|| for_each(i)); - }); - }) - } - - pub fn par_map>( - t: T, - mut map: impl FnMut(<::IntoIter as Iterator>::Item) -> R, - ) -> C { - parallel_guard(|guard| { - t.into_iter().filter_map(|i| guard.run(|| map(i))).collect() - }) - } - pub use std::rc::Rc as Lrc; pub use std::rc::Weak as Weak; pub use std::cell::Ref as ReadGuard; @@ -370,105 +303,6 @@ cfg_if! { use std::thread; - #[inline] - pub fn join(oper_a: A, oper_b: B) -> (RA, RB) - where - A: FnOnce() -> RA + DynSend, - B: FnOnce() -> RB + DynSend, - { - if mode::is_dyn_thread_safe() { - let oper_a = FromDyn::from(oper_a); - let oper_b = FromDyn::from(oper_b); - let (a, b) = rayon::join(move || FromDyn::from(oper_a.into_inner()()), move || FromDyn::from(oper_b.into_inner()())); - (a.into_inner(), b.into_inner()) - } else { - let (a, b) = parallel_guard(|guard| { - let a = guard.run(oper_a); - let b = guard.run(oper_b); - (a, b) - }); - (a.unwrap(), b.unwrap()) - } - } - - // This function only works when `mode::is_dyn_thread_safe()`. - pub fn scope<'scope, OP, R>(op: OP) -> R - where - OP: FnOnce(&rayon::Scope<'scope>) -> R + DynSend, - R: DynSend, - { - let op = FromDyn::from(op); - rayon::scope(|s| FromDyn::from(op.into_inner()(s))).into_inner() - } - - /// Runs a list of blocks in parallel. The first block is executed immediately on - /// the current thread. Use that for the longest running block. - #[macro_export] - macro_rules! parallel { - (impl $fblock:block [$($c:expr,)*] [$block:expr $(, $rest:expr)*]) => { - parallel!(impl $fblock [$block, $($c,)*] [$($rest),*]) - }; - (impl $fblock:block [$($blocks:expr,)*] []) => { - ::rustc_data_structures::sync::scope(|s| { - $(let block = rustc_data_structures::sync::FromDyn::from(|| $blocks); - s.spawn(move |_| block.into_inner()());)* - (|| $fblock)(); - }); - }; - ($fblock:block, $($blocks:block),*) => { - if rustc_data_structures::sync::is_dyn_thread_safe() { - // Reverse the order of the later blocks since Rayon executes them in reverse order - // when using a single thread. This ensures the execution order matches that - // of a single threaded rustc. - parallel!(impl $fblock [] [$($blocks),*]); - } else { - $crate::sync::parallel_guard(|guard| { - guard.run(|| $fblock); - $(guard.run(|| $blocks);)* - }); - } - }; - } - - use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelIterator}; - - pub fn par_for_each_in + IntoParallelIterator>( - t: T, - for_each: impl Fn(I) + DynSync + DynSend - ) { - parallel_guard(|guard| { - if mode::is_dyn_thread_safe() { - let for_each = FromDyn::from(for_each); - t.into_par_iter().for_each(|i| { - guard.run(|| for_each(i)); - }); - } else { - t.into_iter().for_each(|i| { - guard.run(|| for_each(i)); - }); - } - }); - } - - pub fn par_map< - I, - T: IntoIterator + IntoParallelIterator, - R: std::marker::Send, - C: FromIterator + FromParallelIterator - >( - t: T, - map: impl Fn(I) -> R + DynSync + DynSend - ) -> C { - parallel_guard(|guard| { - if mode::is_dyn_thread_safe() { - let map = FromDyn::from(map); - t.into_par_iter().filter_map(|i| guard.run(|| map(i))).collect() - } else { - t.into_iter().filter_map(|i| guard.run(|| map(i))).collect() - } - }) - } - /// This makes locks panic if they are already held. /// It is only useful when you are running in a single thread const ERROR_CHECKING: bool = false; diff --git a/compiler/rustc_data_structures/src/sync/parallel.rs b/compiler/rustc_data_structures/src/sync/parallel.rs new file mode 100644 index 0000000000000..1944ddfb710d8 --- /dev/null +++ b/compiler/rustc_data_structures/src/sync/parallel.rs @@ -0,0 +1,188 @@ +//! This module defines parallel operations that are implemented in +//! one way for the serial compiler, and another way the parallel compiler. + +#![allow(dead_code)] + +use parking_lot::Mutex; +use std::any::Any; +use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; + +#[cfg(not(parallel_compiler))] +pub use disabled::*; +#[cfg(parallel_compiler)] +pub use enabled::*; + +/// A guard used to hold panics that occur during a parallel section to later by unwound. +/// This is used for the parallel compiler to prevent fatal errors from non-deterministically +/// hiding errors by ensuring that everything in the section has completed executing before +/// continuing with unwinding. It's also used for the non-parallel code to ensure error message +/// output match the parallel compiler for testing purposes. +pub struct ParallelGuard { + panic: Mutex>>, +} + +impl ParallelGuard { + pub fn run(&self, f: impl FnOnce() -> R) -> Option { + catch_unwind(AssertUnwindSafe(f)) + .map_err(|err| { + *self.panic.lock() = Some(err); + }) + .ok() + } +} + +/// This gives access to a fresh parallel guard in the closure and will unwind any panics +/// caught in it after the closure returns. +#[inline] +pub fn parallel_guard(f: impl FnOnce(&ParallelGuard) -> R) -> R { + let guard = ParallelGuard { panic: Mutex::new(None) }; + let ret = f(&guard); + if let Some(panic) = guard.panic.into_inner() { + resume_unwind(panic); + } + ret +} + +mod disabled { + use crate::sync::parallel_guard; + + #[macro_export] + #[cfg(not(parallel_compiler))] + macro_rules! parallel { + ($($blocks:block),*) => {{ + $crate::sync::parallel_guard(|guard| { + $(guard.run(|| $blocks);)* + }); + }} + } + + pub fn join(oper_a: A, oper_b: B) -> (RA, RB) + where + A: FnOnce() -> RA, + B: FnOnce() -> RB, + { + let (a, b) = parallel_guard(|guard| { + let a = guard.run(oper_a); + let b = guard.run(oper_b); + (a, b) + }); + (a.unwrap(), b.unwrap()) + } + + pub fn par_for_each_in(t: T, mut for_each: impl FnMut(T::Item)) { + parallel_guard(|guard| { + t.into_iter().for_each(|i| { + guard.run(|| for_each(i)); + }); + }) + } + + pub fn par_map>( + t: T, + mut map: impl FnMut(<::IntoIter as Iterator>::Item) -> R, + ) -> C { + parallel_guard(|guard| t.into_iter().filter_map(|i| guard.run(|| map(i))).collect()) + } +} + +#[cfg(parallel_compiler)] +mod enabled { + use crate::sync::{mode, parallel_guard, DynSend, DynSync, FromDyn}; + + /// Runs a list of blocks in parallel. The first block is executed immediately on + /// the current thread. Use that for the longest running block. + #[macro_export] + macro_rules! parallel { + (impl $fblock:block [$($c:expr,)*] [$block:expr $(, $rest:expr)*]) => { + parallel!(impl $fblock [$block, $($c,)*] [$($rest),*]) + }; + (impl $fblock:block [$($blocks:expr,)*] []) => { + ::rustc_data_structures::sync::scope(|s| { + $(let block = rustc_data_structures::sync::FromDyn::from(|| $blocks); + s.spawn(move |_| block.into_inner()());)* + (|| $fblock)(); + }); + }; + ($fblock:block, $($blocks:block),*) => { + if rustc_data_structures::sync::is_dyn_thread_safe() { + // Reverse the order of the later blocks since Rayon executes them in reverse order + // when using a single thread. This ensures the execution order matches that + // of a single threaded rustc. + parallel!(impl $fblock [] [$($blocks),*]); + } else { + $crate::sync::parallel_guard(|guard| { + guard.run(|| $fblock); + $(guard.run(|| $blocks);)* + }); + } + }; + } + + // This function only works when `mode::is_dyn_thread_safe()`. + pub fn scope<'scope, OP, R>(op: OP) -> R + where + OP: FnOnce(&rayon::Scope<'scope>) -> R + DynSend, + R: DynSend, + { + let op = FromDyn::from(op); + rayon::scope(|s| FromDyn::from(op.into_inner()(s))).into_inner() + } + + #[inline] + pub fn join(oper_a: A, oper_b: B) -> (RA, RB) + where + A: FnOnce() -> RA + DynSend, + B: FnOnce() -> RB + DynSend, + { + if mode::is_dyn_thread_safe() { + let oper_a = FromDyn::from(oper_a); + let oper_b = FromDyn::from(oper_b); + let (a, b) = rayon::join( + move || FromDyn::from(oper_a.into_inner()()), + move || FromDyn::from(oper_b.into_inner()()), + ); + (a.into_inner(), b.into_inner()) + } else { + super::disabled::join(oper_a, oper_b) + } + } + + use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelIterator}; + + pub fn par_for_each_in + IntoParallelIterator>( + t: T, + for_each: impl Fn(I) + DynSync + DynSend, + ) { + parallel_guard(|guard| { + if mode::is_dyn_thread_safe() { + let for_each = FromDyn::from(for_each); + t.into_par_iter().for_each(|i| { + guard.run(|| for_each(i)); + }); + } else { + t.into_iter().for_each(|i| { + guard.run(|| for_each(i)); + }); + } + }); + } + + pub fn par_map< + I, + T: IntoIterator + IntoParallelIterator, + R: std::marker::Send, + C: FromIterator + FromParallelIterator, + >( + t: T, + map: impl Fn(I) -> R + DynSync + DynSend, + ) -> C { + parallel_guard(|guard| { + if mode::is_dyn_thread_safe() { + let map = FromDyn::from(map); + t.into_par_iter().filter_map(|i| guard.run(|| map(i))).collect() + } else { + t.into_iter().filter_map(|i| guard.run(|| map(i))).collect() + } + }) + } +} From b87067643257deddb36977b03e1b5497b2935595 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Sep 2023 08:11:31 +0200 Subject: [PATCH 73/73] fmt --- src/tools/miri/src/concurrency/data_race.rs | 5 +++-- src/tools/miri/src/concurrency/thread.rs | 2 +- src/tools/miri/src/shims/os_str.rs | 5 +++-- src/tools/miri/src/shims/unix/macos/foreign_items.rs | 10 ++-------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/tools/miri/src/concurrency/data_race.rs b/src/tools/miri/src/concurrency/data_race.rs index 513cec1f6c374..073b8b6a66130 100644 --- a/src/tools/miri/src/concurrency/data_race.rs +++ b/src/tools/miri/src/concurrency/data_race.rs @@ -1030,8 +1030,9 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> { // for details. // We avoid `get_ptr_alloc` since we do *not* want to run the access hooks -- the actual // access will happen later. - let (alloc_id, _offset, _prov) = - this.ptr_try_get_alloc_id(place.ptr()).expect("there are no zero-sized atomic accesses"); + let (alloc_id, _offset, _prov) = this + .ptr_try_get_alloc_id(place.ptr()) + .expect("there are no zero-sized atomic accesses"); if this.get_alloc_mutability(alloc_id)? == Mutability::Not { // FIXME: make this prettier, once these messages have separate title/span/help messages. throw_ub_format!( diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 295d86fd24021..ef4e7df3aba93 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -7,8 +7,8 @@ use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; use std::task::Poll; use std::time::{Duration, SystemTime}; -use log::trace; use either::Either; +use log::trace; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; diff --git a/src/tools/miri/src/shims/os_str.rs b/src/tools/miri/src/shims/os_str.rs index f6e76545a4d8d..62ce2ee58ae69 100644 --- a/src/tools/miri/src/shims/os_str.rs +++ b/src/tools/miri/src/shims/os_str.rs @@ -159,8 +159,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let arg_type = Ty::new_array(this.tcx.tcx, this.tcx.types.u16, size); let arg_place = this.allocate(this.layout_of(arg_type).unwrap(), memkind)?; - let (written, _) = - self.write_os_str_to_wide_str(os_str, arg_place.ptr(), size, /*truncate*/ false).unwrap(); + let (written, _) = self + .write_os_str_to_wide_str(os_str, arg_place.ptr(), size, /*truncate*/ false) + .unwrap(); assert!(written); Ok(arg_place.ptr()) } diff --git a/src/tools/miri/src/shims/unix/macos/foreign_items.rs b/src/tools/miri/src/shims/unix/macos/foreign_items.rs index 3524fd70bcf85..0ee3cea05d508 100644 --- a/src/tools/miri/src/shims/unix/macos/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/macos/foreign_items.rs @@ -112,17 +112,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // Access to command-line arguments "_NSGetArgc" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; - this.write_pointer( - this.machine.argc.expect("machine must be initialized"), - dest, - )?; + this.write_pointer(this.machine.argc.expect("machine must be initialized"), dest)?; } "_NSGetArgv" => { let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; - this.write_pointer( - this.machine.argv.expect("machine must be initialized"), - dest, - )?; + this.write_pointer(this.machine.argv.expect("machine must be initialized"), dest)?; } "_NSGetExecutablePath" => { let [buf, bufsize] =